Skip to content

Commit

Permalink
feat(test): fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
R11manish committed Mar 8, 2024
1 parent 5bc97c2 commit 773cf36
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 28 deletions.
15 changes: 8 additions & 7 deletions test/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Auth } from '../src/auth/auth';
import { getMeshSDK } from '../.mesh';
import { AuthMockService } from '../__mocks__/auth.mock';
import { authStub } from './stubs/auth.stub';
import { AuthType } from '../src/types';
import { GraphQLClient } from 'graphql-request';
import { getSdk } from '../.mesh';

let auth: Auth;

beforeAll(() => {
auth = new Auth(getMeshSDK());
auth = new Auth(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand All @@ -29,7 +30,7 @@ describe('AUTH SERVICE TESTING', () => {

expect(async () => {
await auth.checkUsernameAvailability(authStub({ username: '' }).username);
}).rejects.toThrow(' should be atleast 3 length');
}).rejects.toThrow(' should be atleast 2 length');
expect(checkUsernameAvailabilityMock).toHaveBeenCalled();
});

Expand Down Expand Up @@ -149,7 +150,7 @@ describe('AUTH SERVICE TESTING', () => {
signature: authStub({ signature: '' }).signature,
wallet: authStub().wallet,
}),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(addWalletConfirmationtMock).toHaveBeenCalled();
});
Expand Down Expand Up @@ -219,7 +220,7 @@ describe('AUTH SERVICE TESTING', () => {
authStub().chain,
authStub({ signature: '' }).signature,
),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(loginWalletlMock).toHaveBeenCalled();
});
Expand All @@ -241,7 +242,7 @@ describe('AUTH SERVICE TESTING', () => {
await auth.refreshToken(
authStub({ existingRefreshToken: '' }).existingRefreshToken,
),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(refreshTokenMock).toHaveBeenCalled();
});
Expand All @@ -267,7 +268,7 @@ describe('AUTH SERVICE TESTING', () => {
authStub({ email: '' }).email,
AuthType.EMAIL,
),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(unregisterAuthMethodMock).toHaveBeenCalled();
});
Expand Down
7 changes: 4 additions & 3 deletions test/data-model.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { getMeshSDK } from '../.mesh';
import { getSdk } from '../.mesh';
import { DataModel } from '../src/data-model/data-model';
import {
dataModelCreateStub,
dataModelStub,
dataModelMetaDataStub,
} from './stubs/dataModel.stub';
import { DataModelMockService } from '../__mocks__/dataModel.mock';
import { GraphQLClient } from 'graphql-request';

let dataModel: DataModel;

beforeAll(() => {
dataModel = new DataModel(getMeshSDK());
dataModel = new DataModel(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down Expand Up @@ -38,7 +39,7 @@ describe('DATA MODEL CLASS METHODS TESTING', () => {
...dataModelCreateStub(),
title: '',
}),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');
expect(createDataModelMock).toHaveBeenCalled();
});

Expand Down
5 changes: 3 additions & 2 deletions test/dataRequestsTemplate.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getMeshSDK } from '../.mesh';
import { GraphQLClient } from 'graphql-request';
import { getSdk } from '../.mesh';
import { DataRequestTemplateMockService } from '../__mocks__/dataRequestTemplate.mock';
import { DataRequestTemplate } from '../src/dataRequestsTemplate/dataRequestsTemplate';
import {
Expand All @@ -9,7 +10,7 @@ import {
let dataRequestTemplate: DataRequestTemplate;

beforeAll(() => {
dataRequestTemplate = new DataRequestTemplate(getMeshSDK());
dataRequestTemplate = new DataRequestTemplate(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down
7 changes: 4 additions & 3 deletions test/organization.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getMeshSDK } from '../.mesh';
import { GraphQLClient } from 'graphql-request';
import { getSdk } from '../.mesh';
import { OrganizationMockService } from '../__mocks__/organization.mock';
import { Organization } from '../src/organization/organization';
import {
Expand All @@ -14,7 +15,7 @@ import {
let organization: Organization;

beforeAll(() => {
organization = new Organization(getMeshSDK());
organization = new Organization(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand All @@ -41,7 +42,7 @@ describe('ORGANIZATION SERVICE TESTING', () => {
await organization.createOrganization(
organizationCreateStub({ username: '' }),
),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(createOrganizationMock).toHaveBeenCalled();
});
Expand Down
7 changes: 4 additions & 3 deletions test/pda.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { PDAStatus } from '../src/types';
import { PDA } from '../src/pda/pda';
import { getMeshSDK } from '../.mesh';
import { getSdk } from '../.mesh';
import { pdaCreateStub, pdaStub } from './stubs/pda.stub';
import { PDAMockService } from '../__mocks__/pda.mock';
import { GraphQLClient } from 'graphql-request';

let pda: PDA;

beforeAll(() => {
pda = new PDA(getMeshSDK());
pda = new PDA(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand All @@ -29,7 +30,7 @@ describe('PDA SERVICE TESTING', () => {

expect(
async () => await pda.createPDA(pdaCreateStub({ title: '' })),
).rejects.toThrow(' should be atleast 3 length');
).rejects.toThrow(' should be atleast 2 length');

expect(createPDAMutationMock).toHaveBeenCalled();
});
Expand Down
5 changes: 3 additions & 2 deletions test/proof.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Proof } from '../src/proof/proof';
import { getMeshSDK } from '../.mesh';
import { getSdk } from '../.mesh';
import {
proofStub,
createProofMessage,
Expand All @@ -8,11 +8,12 @@ import {
} from './stubs/proof.stub';
import { ProofMockService } from '../__mocks__/proof.mock';
import { pdaStub } from './stubs/pda.stub';
import { GraphQLClient } from 'graphql-request';

let proof: Proof;

beforeAll(() => {
proof = new Proof(getMeshSDK());
proof = new Proof(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down
5 changes: 3 additions & 2 deletions test/request.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Request } from '../src/request/request';
import { getMeshSDK } from '../.mesh';
import { getSdk } from '../.mesh';
import { RequestMockService } from '../__mocks__/request.mock';
import { requestStub } from './stubs/request.stub';
import { GraphQLClient } from 'graphql-request';

let request: Request;

beforeAll(() => {
request = new Request(getMeshSDK());
request = new Request(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down
7 changes: 4 additions & 3 deletions test/transaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Transaction } from '../src/transaction/transaction';
import { getMeshSDK } from '../.mesh';
import { getSdk } from '../.mesh';
import { TransactionMockService } from '../__mocks__/transaction.mock';
import { transactionStub } from './stubs/transaction.stub';
import { GraphQLClient } from 'graphql-request';

let transaction: Transaction;

beforeAll(() => {
transaction = new Transaction(getMeshSDK());
transaction = new Transaction(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down Expand Up @@ -34,7 +35,7 @@ describe('TRANSACTION SERVICE TESTING', () => {
it('get transaction by id => throw error', async () => {
const { getTransactionMock } = TransactionMockService(transaction);
expect(async () => await transaction.getTransaction('34')).rejects.toThrow(
'34 should be atleast 3 length',
' should be atleast 2 length',
);
expect(getTransactionMock).toHaveBeenCalled();
});
Expand Down
5 changes: 3 additions & 2 deletions test/user.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getMeshSDK } from '../.mesh';
import { GraphQLClient } from 'graphql-request';
import { getSdk } from '../.mesh';
import { UserMockService } from '../__mocks__/user.mock';
import { UserIdentifierType } from '../src/types';
import { User } from '../src/user/user';
Expand All @@ -7,7 +8,7 @@ import { userStub, walletStub } from './stubs/user.stub';
let user: User;

beforeAll(() => {
user = new User(getMeshSDK());
user = new User(getSdk(new GraphQLClient('')));
});

afterAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('UTILS TESTING', () => {
it('string validator', () => {
const result = isStringValid('test pda');
expect(result).toBeDefined();
expect(() => isStringValid('')).toThrow(' should be atleast 3 length');
expect(() => isStringValid('')).toThrow(' should be atleast 2 length');
});

it('etherum validator', () => {
Expand Down

0 comments on commit 773cf36

Please sign in to comment.