Skip to content

Commit

Permalink
Merge pull request #1114 from UKGovernmentBEIS/dependabot/npm_and_yar…
Browse files Browse the repository at this point in the history
…n/golevelup/ts-jest-0.5.5

build(deps-dev): bump @golevelup/ts-jest from 0.3.3 to 0.5.5
  • Loading branch information
holderj authored Sep 18, 2024
2 parents 60de0fa + 53c2fe6 commit 0103229
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 52 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"body-parser": "^1.20.3"
},
"devDependencies": {
"@golevelup/ts-jest": "^0.3.3",
"@golevelup/ts-jest": "^0.5.5",
"@nestjs/schematics": "^8.0.11",
"@nestjs/testing": "^10.4.1",
"@types/bull": "^4.10.0",
Expand Down
4 changes: 2 additions & 2 deletions src/common/slug-generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('SlugGenerator', () => {

describe('when a slug does not exist', () => {
it('generates a slug without a number', async () => {
service.findBySlug.mockImplementation(undefined);
service.findBySlug.mockResolvedValue(undefined);

const generator = new SlugGenerator(service, 'Some Name');

Expand Down Expand Up @@ -51,7 +51,7 @@ describe('SlugGenerator', () => {

describe('when a slug does not exist', () => {
it('generates a slug without a number', async () => {
service.findBySlug.mockImplementation(undefined);
service.findBySlug.mockResolvedValue(undefined);

const generator = new SlugGenerator(service, 'Some Name');

Expand Down
9 changes: 6 additions & 3 deletions src/decisions/admin/decisions.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ describe('DecisionsController', () => {
2020,
2024,
datasets,
i18nService,
[],
i18nService,
);
expect(
DecisionDatasetsPresenter.prototype.present,
Expand Down Expand Up @@ -270,8 +270,8 @@ describe('DecisionsController', () => {
2020,
2024,
datasets,
i18nService,
allProfessions,
i18nService,
);
expect(
DecisionDatasetsPresenter.prototype.present,
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('DecisionsController', () => {
const datasets = decisionDatasetFactory.buildList(3);
const allOrganisations = organisationFactory.buildList(3);

decisionDatasetsService.allForOrganisation.mockResolvedValue(datasets);
decisionDatasetsService.all.mockResolvedValue(datasets);
organisationVersionsService.allLive.mockResolvedValue(allOrganisations);

const filter: FilterDto = {
Expand Down Expand Up @@ -393,6 +393,9 @@ describe('DecisionsController', () => {

decisionDatasetsService.allForOrganisation.mockResolvedValue(datasets);
organisationVersionsService.allLive.mockResolvedValue(allOrganisations);
professionVersionsService.allWithLatestVersionForOrganisation.mockResolvedValue(
allProfessions,
);

const filter: FilterDto = {
keywords: 'example keywords',
Expand Down
1 change: 1 addition & 0 deletions src/decisions/admin/new.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ describe('NewController', () => {
.mockReturnValue({ start: 2020, end: 2024 });

professionVersionsService.allLive.mockResolvedValue(professionVersions);
organisationVersionsService.allLive.mockResolvedValue(organisations);

(
NewDecisionDatasetPresenter.prototype.present as jest.Mock
Expand Down
14 changes: 10 additions & 4 deletions src/decisions/admin/presenters/decision-datasets.presenter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ describe('DecisionDatasetsPresenter', () => {

expect(getUserOrganisationSpy).toHaveBeenCalledWith(user, i18nService);

expect(ListEntryPresenter.headings).toBeCalledWith(false, i18nService);
expect(ListEntryPresenter.prototype.tableRow).toBeCalledTimes(3);
expect(ListEntryPresenter.headings).toHaveBeenCalledWith(
i18nService,
'single-organisation',
);
expect(ListEntryPresenter.prototype.tableRow).toHaveBeenCalledTimes(3);

expect(OrganisationsCheckboxPresenter).toHaveBeenCalledWith(
allOrganisations,
Expand Down Expand Up @@ -274,8 +277,11 @@ describe('DecisionDatasetsPresenter', () => {

expect(getUserOrganisationSpy).toHaveBeenCalledWith(user, i18nService);

expect(ListEntryPresenter.headings).toBeCalledWith(true, i18nService);
expect(ListEntryPresenter.prototype.tableRow).toBeCalledTimes(3);
expect(ListEntryPresenter.headings).toHaveBeenCalledWith(
i18nService,
'overview',
);
expect(ListEntryPresenter.prototype.tableRow).toHaveBeenCalledTimes(3);

expect(OrganisationsCheckboxPresenter).toHaveBeenCalledWith(
allOrganisations,
Expand Down
2 changes: 2 additions & 0 deletions src/decisions/admin/publication.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ describe('PublicationController', () => {
year: 2016,
});

decisionDatasetsService.find.mockResolvedValue(dataset);

await controller.create(
'example-profession-id',
'example-organisation-id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ describe('OrganisationArchiveController', () => {
version,
);

organisationVersionsService.create.mockResolvedValue(version);

await controller.delete(req, res, organisation.id, version.id);

expect(checkCanViewOrganisationSpy).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ describe('OrganisationPublicationController', () => {
organisation: organisation,
});

organisationsService.find.mockResolvedValue(organisation);
organisationVersionsService.create.mockResolvedValue(version);

const res = createMock<Response>({});

const req = createDefaultMockRequest({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ describe('OrganisationUnarchiveController', () => {
organisationVersionsService.findByIdWithOrganisation.mockResolvedValue(
version,
);
organisationVersionsService.create.mockResolvedValue(version);
organisationsService.find.mockResolvedValue(organisation);

await controller.create(req, res, organisation.id, version.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ describe('OrganisationVersionsController', () => {
version,
);

organisationVersionsService.create.mockResolvedValue(version);

organisationVersionsService.hasLiveVersion.mockResolvedValue(true);

await controller.create(response, request, 'some-uuid');
Expand Down
15 changes: 15 additions & 0 deletions src/organisations/admin/organisations.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ describe('OrganisationsController', () => {
const nations = Nation.all();
const industries = industryFactory.buildList(5);

industriesService.all.mockResolvedValue(industries);
organisationVersionsService.searchWithLatestVersion.mockResolvedValue(
organisations,
);

(
OrganisationsPresenter.prototype as DeepMocked<OrganisationsPresenter>
).present.mockReturnValue(templateParams);
Expand Down Expand Up @@ -187,6 +192,11 @@ describe('OrganisationsController', () => {
const nations = Nation.all();
const industries = industryFactory.buildList(5);

industriesService.all.mockResolvedValue(industries);
organisationVersionsService.searchWithLatestVersion.mockResolvedValue(
[organisations[1], organisations[3]],
);

(
OrganisationsPresenter.prototype as DeepMocked<OrganisationsPresenter>
).present.mockReturnValue(templateParams);
Expand Down Expand Up @@ -260,6 +270,11 @@ describe('OrganisationsController', () => {
const nations = Nation.all();
const industries = industryFactory.buildList(5);

industriesService.all.mockResolvedValue(industries);
organisationVersionsService.searchWithLatestVersion.mockResolvedValue([
userOrganisation,
]);

const request = createDefaultMockRequest();
(getActingUser as jest.Mock).mockReturnValue(
userFactory.build({
Expand Down
4 changes: 4 additions & 0 deletions src/professions/admin/confirmation.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ describe('ConfirmationController', () => {
});

const profession = professionFactory.build();
const version = professionVersionFactory
.justCreated('version-id')
.build({ profession: profession });

professionsService.findWithVersions.mockResolvedValue(profession);
professionVersionsService.findWithProfession.mockResolvedValue(version);

await controller.create(res, req, 'profession-id', 'version-id');

Expand Down
2 changes: 2 additions & 0 deletions src/professions/admin/profession-archive.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ describe('ProfessionArchiveController', () => {
version,
);

professionVersionsService.create.mockResolvedValue(version);

const request = createDefaultMockRequest({
user: userFactory.build(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ describe('ProfessionPublicationController', () => {
version,
);

professionVersionsService.create.mockResolvedValue(version);

(getPublicationBlockers as jest.Mock).mockReturnValue([]);

await controller.create(req, res, profession.id, version.id);
Expand Down
2 changes: 2 additions & 0 deletions src/professions/admin/profession-versions.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ describe('ProfessionVersionsController', () => {
version,
);

professionVersionsService.create.mockResolvedValue(version);

const res = createMock<Response>();
const req = createDefaultMockRequest({ user: userFactory.build() });

Expand Down
4 changes: 4 additions & 0 deletions src/professions/admin/registration.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ describe(RegistrationController, () => {

it('checks the user has permission to update the Profession', async () => {
const profession = professionFactory.justCreated('profession-id').build();
const version = professionVersionFactory
.justCreated('version-id')
.build({ profession: profession });

professionsService.findWithVersions.mockResolvedValue(profession);
professionVersionsService.findWithProfession.mockResolvedValue(version);

const request = createDefaultMockRequest({
user: userFactory.build(),
Expand Down
3 changes: 3 additions & 0 deletions src/professions/search/search.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ describe('SearchController', () => {
const industry1 = industryFactory.build();
const industry2 = industryFactory.build();

const industries = [industry1, industry2];
industriesService.all.mockResolvedValue(industries);

await controller.index(
{
keywords: 'example search',
Expand Down
Loading

0 comments on commit 0103229

Please sign in to comment.