1import { logNodeInstallWarning } from '../createAsync'; 2 3const asMock = <T extends (...args: any[]) => any>(fn: T): jest.MockedFunction<T> => 4 fn as jest.MockedFunction<T>; 5 6const originalConsoleLog = console.log; 7beforeAll(() => { 8 console.log = jest.fn(); 9}); 10afterAll(() => { 11 console.log = originalConsoleLog; 12}); 13 14describe(logNodeInstallWarning, () => { 15 beforeEach(() => { 16 asMock(console.log).mockClear(); 17 }); 18 it(`logs correct cd`, () => { 19 logNodeInstallWarning('/foo/bar', 'npm', false); 20 21 expect(console.log).toHaveBeenNthCalledWith(2, expect.stringContaining('cd /foo/bar/')); 22 expect(console.log).toHaveBeenNthCalledWith(3, expect.stringContaining('npm install')); 23 }); 24 it(`logs correct cd for same directory`, () => { 25 logNodeInstallWarning('', 'yarn', false); 26 27 expect(console.log).toHaveBeenNthCalledWith(2, expect.stringContaining('cd ./')); 28 expect(console.log).toHaveBeenNthCalledWith(3, expect.stringContaining('yarn install')); 29 }); 30}); 31