-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adopt
ts-jest
26.4.4 (#665)
- Loading branch information
Showing
6 changed files
with
78 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,59 @@ | ||
describe('AngularJestTransformer', () => { | ||
import { TsJestTransformer } from 'ts-jest/dist/ts-jest-transformer'; | ||
|
||
describe('NgJestTransformer', () => { | ||
describe('getCacheKey', () => { | ||
it('should be different for each argument value', () => { | ||
// eslint-disable-next-line | ||
const tr = require('../'); | ||
test('should call getCacheKey method from parent class TsJestTransformer', () => { | ||
TsJestTransformer.prototype.getCacheKey = jest.fn(); | ||
const input = { | ||
fileContent: 'export default "foo"', | ||
fileName: 'foo.ts', | ||
jestConfigStr: '{"foo": "bar"}', | ||
// eslint-disable-next-line | ||
options: { config: { foo: 'bar' } as any, instrument: false, rootDir: '/foo' }, | ||
}; | ||
const keys = [ | ||
tr.getCacheKey(input.fileContent, input.fileName, input.jestConfigStr, input.options), | ||
tr.getCacheKey(input.fileContent, 'bar.ts', input.jestConfigStr, input.options), | ||
tr.getCacheKey(input.fileContent, input.fileName, '{}', { ...input.options, instrument: true }), | ||
tr.getCacheKey(input.fileContent, input.fileName, '{}', { ...input.options, rootDir: '/bar' }), | ||
]; | ||
// each key should have correct length | ||
for (const key of keys) { | ||
expect(key).toHaveLength(32); | ||
} | ||
// eslint-disable-next-line | ||
const tr = require('../'); | ||
|
||
tr.getCacheKey(input.fileContent, input.fileName, input.jestConfigStr, input.options); | ||
|
||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
expect(TsJestTransformer.prototype.getCacheKey).toHaveBeenCalledWith( | ||
input.fileContent, | ||
input.fileName, | ||
input.jestConfigStr, | ||
input.options, | ||
); | ||
}); | ||
}); | ||
|
||
describe('configsFor', () => { | ||
test( | ||
'should return the same config set for same values with different jest config objects' + | ||
' but their serialized versions are the same', | ||
() => { | ||
const obj1 = { | ||
config: { cwd: '/foo/.', rootDir: '/bar//dummy/..', globals: {}, testMatch: [], testRegex: [] }, | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const obj2 = { ...obj1, config: { ...obj1.config, globals: Object.create(null) } }; | ||
// eslint-disable-next-line | ||
const cs1 = require('../').configsFor(obj1); | ||
// eslint-disable-next-line | ||
const cs2 = require('../').configsFor(obj2); | ||
|
||
expect(cs2).toBe(cs1); | ||
}, | ||
); | ||
|
||
test('should return the same config set for same values with jest config objects', () => { | ||
const obj1 = { config: { cwd: '/foo/.', rootDir: '/bar//dummy/..', globals: {}, testMatch: [], testRegex: [] } }; | ||
const obj2 = { ...obj1 }; | ||
// eslint-disable-next-line | ||
const cs1 = require('../').configsFor(obj1); | ||
// eslint-disable-next-line | ||
const cs2 = require('../').configsFor(obj2); | ||
|
||
expect(cs2).toBe(cs1); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters