1import { ContextModuleSourceMapsMiddleware } from '../ContextModuleSourceMapsMiddleware'; 2 3it(`should return a noop response for the sourcemap`, () => { 4 const middleware = new ContextModuleSourceMapsMiddleware(); 5 6 const writeHead = jest.fn(); 7 const end = jest.fn(); 8 middleware.getHandler()( 9 { 10 url: '/app/ctx%3Fctx=abcde1234TERSE.map?platform=web', 11 method: 'GET', 12 } as any, 13 { 14 writeHead, 15 end, 16 } as any, 17 jest.fn() 18 ); 19 20 expect(writeHead).toBeCalledWith(200, { 21 'Content-Type': 'application/json', 22 }); 23 24 expect(end).toBeCalledWith('{}'); 25}); 26it(`should skip unrelated requests`, () => { 27 const middleware = new ContextModuleSourceMapsMiddleware(); 28 29 const writeHead = jest.fn(); 30 const end = jest.fn(); 31 const next = jest.fn(); 32 middleware.getHandler()( 33 { 34 url: '/app/ctx.map?platform=web', 35 method: 'GET', 36 } as any, 37 { 38 writeHead, 39 end, 40 } as any, 41 next 42 ); 43 44 expect(writeHead).not.toBeCalled(); 45 expect(end).not.toBeCalled(); 46 47 expect(next).toBeCalled(); 48}); 49