UNPKG

@jest-mock/express

Version:

A lightweight Jest mock for unit testing Express

237 lines 10.7 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); // Tested Module const response_1 = __importDefault(require("../../../response/response")); describe('response - Defaults for "stream.Writable" (accepts no arguments and return default values)', () => { test('res.writable is a boolean', () => { const { res } = (0, response_1.default)(); expect(res.writable).toBeDefined(); expect(res.writable).toEqual(false); }); test('res.writableEnded is a boolean', () => { const { res } = (0, response_1.default)(); expect(res.writableEnded).toBeDefined(); expect(res.writableEnded).toEqual(false); }); test('res.writableFinished is a boolean', () => { const { res } = (0, response_1.default)(); expect(res.writableFinished).toBeDefined(); expect(res.writableFinished).toEqual(false); }); test('res.writableHighWaterMark is a number', () => { const { res } = (0, response_1.default)(); expect(res.writableHighWaterMark).toBeDefined(); expect(res.writableHighWaterMark).toEqual(0); }); test('res.writableLength is a number', () => { const { res } = (0, response_1.default)(); expect(res.writableLength).toBeDefined(); expect(res.writableLength).toEqual(0); }); test('res.writableObjectMode is a boolean', () => { const { res } = (0, response_1.default)(); expect(res.writableObjectMode).toBeDefined(); expect(res.writableObjectMode).toEqual(false); }); test('res.writableCorked is a number', () => { const { res } = (0, response_1.default)(); expect(res.writableCorked).toBeDefined(); expect(res.writableCorked).toEqual(0); }); test('res.destroyed is a boolean', () => { const { res } = (0, response_1.default)(); expect(res.destroyed).toBeDefined(); expect(res.destroyed).toEqual(false); }); test('res._write is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res._write).toBeDefined(); expect(typeof res._write).toBe('function'); expect(res._write.getMockName()).toBe('_write mock default'); }); test('res._write is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res._write({}, 'base64', jest.fn())).toBeUndefined(); }); test('res._writev is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res._writev).toBeDefined(); expect(typeof res._writev).toBe('function'); expect(res._writev.getMockName()).toBe('_writev mock default'); }); test('res._writev is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res._writev && res._writev([], jest.fn())).toBeUndefined(); }); test('res._destroy is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res._destroy).toBeDefined(); expect(typeof res._destroy).toBe('function'); expect(res._destroy.getMockName()).toBe('_destroy mock default'); }); test('res._destroy is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res._destroy(null, jest.fn())).toBeUndefined(); }); test('res._final is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res._final).toBeDefined(); expect(typeof res._final).toBe('function'); expect(res._final.getMockName()).toBe('_final mock default'); }); test('res._final is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res._final(jest.fn())).toBeUndefined(); }); test('res.write is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.write).toBeDefined(); expect(typeof res.write).toBe('function'); expect(res.write.getMockName()).toBe('write mock default'); }); test('res.write is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.write({}, jest.fn())).toBeUndefined(); }); test('res.setDefaultEncoding is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.setDefaultEncoding).toBeDefined(); expect(typeof res.setDefaultEncoding).toBe('function'); expect(res.setDefaultEncoding.getMockName()).toBe('setDefaultEncoding mock default'); }); test('res.setDefaultEncoding is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.setDefaultEncoding('base64')).toBe(res); }); test('res.end is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.end).toBeDefined(); expect(typeof res.end).toBe('function'); expect(res.end.getMockName()).toBe('end mock default'); }); test('res.end is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.end()).toBeUndefined(); }); test('res.cork is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.cork).toBeDefined(); expect(typeof res.cork).toBe('function'); expect(res.cork.getMockName()).toBe('cork mock default'); }); test('res.cork is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.cork()).toBeUndefined(); }); test('res.uncork is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.uncork).toBeDefined(); expect(typeof res.uncork).toBe('function'); expect(res.uncork.getMockName()).toBe('uncork mock default'); }); test('res.uncork is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.uncork()).toBeUndefined(); }); test('res.destroy is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.destroy).toBeDefined(); expect(typeof res.destroy).toBe('function'); expect(res.destroy.getMockName()).toBe('destroy mock default'); }); test('res.destroy is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.destroy()).toBeUndefined(); }); test('res.addListener is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.addListener).toBeDefined(); expect(typeof res.addListener).toBe('function'); expect(res.addListener.getMockName()).toBe('addListener mock default'); }); test('res.addListener is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.addListener('test', jest.fn())).toBe(res); }); test('res.emit is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.emit).toBeDefined(); expect(typeof res.emit).toBe('function'); expect(res.emit.getMockName()).toBe('emit mock default'); }); test('res.emit is not chainable', () => { const { res } = (0, response_1.default)(); // it does not return itself (is not chainable) expect(res.emit('test')).toBeUndefined(); }); test('res.on is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.on).toBeDefined(); expect(typeof res.on).toBe('function'); expect(res.on.getMockName()).toBe('on mock default'); }); test('res.on is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.on('close', jest.fn())).toBe(res); }); test('res.once is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.once).toBeDefined(); expect(typeof res.once).toBe('function'); expect(res.once.getMockName()).toBe('once mock default'); }); test('res.once is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.once('pipe', jest.fn())).toBe(res); }); test('res.prependListener is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.prependListener).toBeDefined(); expect(typeof res.prependListener).toBe('function'); expect(res.prependListener.getMockName()).toBe('prependListener mock default'); }); test('res.prependListener is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.prependListener('drain', jest.fn())).toBe(res); }); test('res.prependOnceListener is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.prependOnceListener).toBeDefined(); expect(typeof res.prependOnceListener).toBe('function'); expect(res.prependOnceListener.getMockName()).toBe('prependOnceListener mock default'); }); test('res.prependOnceListener is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.prependOnceListener('unpipe', jest.fn())).toBe(res); }); test('res.removeListener is a mocked function', () => { const { res } = (0, response_1.default)(); expect(res.removeListener).toBeDefined(); expect(typeof res.removeListener).toBe('function'); expect(res.removeListener.getMockName()).toBe('removeListener mock default'); }); test('res.removeListener is chainable', () => { const { res } = (0, response_1.default)(); // it returns itself (is chainable) expect(res.removeListener('error', jest.fn())).toBe(res); }); }); //# sourceMappingURL=defaults.stream.Writable.test.js.map