diff --git a/src/index.js b/src/index.js index be5f938..41277e9 100644 --- a/src/index.js +++ b/src/index.js @@ -78,6 +78,8 @@ export default ({ types: t }) => { 'genMockFromModule', 'mock', 'unmock', + 'doMock', + 'dontMock', ]; if (!( diff --git a/test/jest.test.js b/test/jest.test.js index d143e67..8fd1f23 100644 --- a/test/jest.test.js +++ b/test/jest.test.js @@ -41,6 +41,29 @@ describe('jest functions', () => { }); }); + describe('jest.doMock', () => { + it('should resolve the path based on the root config', () => { + const code = 'jest.doMock("c1", () => {});'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.doMock("./test/examples/components/c1", () => {});'); + }); + + it('should alias the path', () => { + const code = 'jest.doMock("utils", () => {});'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.doMock("./src/mylib/subfolder/utils", () => {});'); + }); + + it('should not change the path', () => { + const code = 'jest.doMock("./utils", () => {});'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.doMock("./utils", () => {});'); + }); + }); + describe('jest.unmock', () => { it('should resolve the path based on the root config', () => { const code = 'jest.unmock("c1");'; @@ -64,6 +87,29 @@ describe('jest functions', () => { }); }); + describe('jest.dontMock', () => { + it('should resolve the path based on the root config', () => { + const code = 'jest.dontMock("c1");'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.dontMock("./test/examples/components/c1");'); + }); + + it('should alias the path', () => { + const code = 'jest.dontMock("utils");'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.dontMock("./src/mylib/subfolder/utils");'); + }); + + it('should not change the path', () => { + const code = 'jest.dontMock("./utils");'; + const result = transform(code, transformerOpts); + + expect(result.code).toBe('jest.dontMock("./utils");'); + }); + }); + describe('jest.genMockFromModule', () => { it('should resolve the path based on the root config', () => { const code = 'jest.genMockFromModule("c1");';