Skip to content

Commit 031b13a

Browse files
committed
chore: fix broken unit tests
1 parent 8347113 commit 031b13a

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

apps/generator-cli/src/app/services/config.service.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {Test} from '@nestjs/testing';
22
import {ConfigService} from './config.service';
3-
import {mocked} from 'ts-jest/utils';
43
import {LOGGER} from '../constants';
54

65
jest.mock('fs-extra');
76
// eslint-disable-next-line @typescript-eslint/no-var-requires
8-
const fs = mocked(require('fs-extra'), true)
7+
const fs = jest.mocked(require('fs-extra'), true)
98

109
describe('ConfigService', () => {
1110

@@ -41,7 +40,7 @@ describe('ConfigService', () => {
4140
})
4241

4342
it.each([
44-
['$schema', 'node_modules/@openapitools/openapi-generator-cli/config.schema.json'],
43+
['$schema', './node_modules/@openapitools/openapi-generator-cli/config.schema.json'],
4544
['spaces', 2],
4645
['generator-cli', {version: undefined}],
4746
])('the key "%s" returns %s as default', (key, expectedValue) => {

apps/generator-cli/src/app/services/generator.service.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Test} from '@nestjs/testing';
22
import {GeneratorService} from './generator.service';
3-
import {mocked} from 'ts-jest/utils';
43
import {LOGGER} from '../constants';
54
import {VersionManagerService} from './version-manager.service';
65
import {ConfigService} from './config.service';
@@ -9,11 +8,11 @@ jest.mock('fs-extra');
98
jest.mock('glob');
109
jest.mock('concurrently');
1110
// eslint-disable-next-line @typescript-eslint/no-var-requires
12-
const fs = mocked(require('fs-extra'), true)
11+
const fs = jest.mocked(require('fs-extra'), true)
1312
// eslint-disable-next-line @typescript-eslint/no-var-requires
14-
const glob = mocked(require('glob'), true)
13+
const glob = jest.mocked(require('glob'), true)
1514
// eslint-disable-next-line @typescript-eslint/no-var-requires
16-
const concurrently = mocked(require('concurrently'), true)
15+
const concurrently = jest.mocked(require('concurrently'), true)
1716

1817
describe('GeneratorService', () => {
1918

apps/generator-cli/src/app/services/pass-through.service.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Test } from '@nestjs/testing'
22
import * as chalk from 'chalk'
33
import { Command, createCommand } from 'commander'
4-
import { mocked } from 'ts-jest/utils'
54
import { COMMANDER_PROGRAM, LOGGER } from '../constants'
65
import { GeneratorService } from './generator.service'
76
import { PassThroughService } from './pass-through.service'
87
import { VersionManagerService } from './version-manager.service'
98

109
jest.mock('child_process')
1110
// eslint-disable-next-line @typescript-eslint/no-var-requires
12-
const childProcess = mocked(require('child_process'), true)
11+
const childProcess = jest.mocked(require('child_process'), true)
1312

1413
describe('PassThroughService', () => {
1514

apps/generator-cli/src/app/services/version-manager.service.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { Test } from '@nestjs/testing';
22
import { Version, VersionManagerService } from './version-manager.service';
33
import { HttpService } from '@nestjs/common';
44
import { of } from 'rxjs';
5-
import { mocked } from 'ts-jest/utils';
65
import { LOGGER } from '../constants';
76
import * as chalk from 'chalk';
87
import { ConfigService } from './config.service';
98
import { resolve } from 'path';
109
import * as os from 'os';
1110
import { TestingModule } from '@nestjs/testing/testing-module';
11+
import * as path from "path";
1212

1313
jest.mock('fs-extra');
1414
// eslint-disable-next-line @typescript-eslint/no-var-requires
15-
const fs = mocked(require('fs-extra'), true);
15+
const fs = jest.mocked(require('fs-extra'), true);
1616

1717
describe('VersionManagerService', () => {
1818

@@ -440,9 +440,8 @@ describe('VersionManagerService', () => {
440440
expect(fs.ensureDirSync).toHaveBeenNthCalledWith(1, fixture.storage);
441441
});
442442

443-
444443
it('creates a temporary directory', () => {
445-
expect(fs.mkdtempSync).toHaveBeenNthCalledWith(1, '/tmp/generator-cli-');
444+
expect(fs.mkdtempSync).toHaveBeenNthCalledWith(1, path.join(os.tmpdir(), 'generator-cli-'));
446445
});
447446

448447
it('creates the correct write stream', () => {

0 commit comments

Comments
 (0)