Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api test mock registrations #6040

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions services/121-service/test/mocks/seed-mock.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { TransactionStatusEnum } from '@121-service/src/payments/transactions/enums/transaction-status.enum';
import { SeedScript } from '@121-service/src/scripts/seed-script.enum';
import { adminOwnerDto } from '@121-service/test/fixtures/user-owner';
import { getTransactions } from '@121-service/test/helpers/program.helper';
import { getRegistrations } from '@121-service/test/helpers/registration.helper';
import {
getAccessToken,
resetDB,
} from '@121-service/test/helpers/utility.helper';
import {
programIdOCW,
programIdPV,
} from '@121-service/test/registrations/pagination/pagination-data';

describe('Mock registrations', () => {
it('does mock nlrc multiple still seed registrations and transactions', async () => {
// Arrange
console.time('before');
jannisvisser marked this conversation as resolved.
Show resolved Hide resolved
jannisvisser marked this conversation as resolved.
Show resolved Hide resolved
await resetDB(SeedScript.nlrcMultipleMock);
console.timeEnd('before');
jannisvisser marked this conversation as resolved.
Show resolved Hide resolved
const accessToken = await getAccessToken();
const payment = 1;
// Assert
const programs = [
{ programId: programIdOCW, paymentNr: payment },
{ programId: programIdPV, paymentNr: payment },
];

for (const { programId, paymentNr } of programs) {
const registrationsResponse = await getRegistrations({
programId,
accessToken,
});

const transactionsResponse = await getTransactions(
programId,
paymentNr,
null,
accessToken,
);

// Assert
expect(registrationsResponse.body.data.length).toBe(4);
expect(transactionsResponse.body.length).toBe(4);
expect(transactionsResponse.text).toContain(
TransactionStatusEnum.success,
);
expect(transactionsResponse.body[0].user).toMatchObject(adminOwnerDto);
jannisvisser marked this conversation as resolved.
Show resolved Hide resolved
}
});
});
Loading