/
hoisting.test.ts
50 lines (44 loc) · 1.66 KB
/
hoisting.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { allValidPackageSets } from '../__helpers__/templates'
import { configureTestCase } from '../__helpers__/test-case'
describe('Hoisting', () => {
describe('jest.mock() & jest.unmock()', () => {
const testCase = configureTestCase('hoisting/mock-unmock', {
writeIo: true,
})
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot('output-mockUnmock')
expect(result.ioFor('mock-unmock.spec.ts')).toMatchSnapshot('io-mockUnmock')
})
})
})
describe('jest.enableAutomock()', () => {
const testCase = configureTestCase('hoisting/enable-automock', { writeIo: true })
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot('output-enableAutomock')
expect(result.ioFor('enable-automock.spec.ts')).toMatchSnapshot('io-enableAutomock')
})
})
})
describe('jest.disableAutomock()', () => {
const testCase = configureTestCase('hoisting/disable-automock', {
writeIo: true,
jestConfig: {
automock: true,
}
})
testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot('output-disableAutomock')
expect(result.ioFor('disable-automock.spec.ts')).toMatchSnapshot('io-disableAutomock')
})
})
})
})