This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
import { stub } from 'sinon'; | |
import * as zlib from 'zlib'; | |
import { streamExample } from '../src/stream-example'; | |
import { Readable, Writable } from 'stream'; | |
describe('streamExample()', () => { | |
let data: any[]; | |
let writable: Writable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Readable } from 'stream'; | |
import { createGzip } from 'zlib'; | |
export function streamExample(stream: Readable) { | |
return stream | |
.pipe(createGzip()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
import { match, stub } from 'sinon'; | |
import { doubleConsole } from '../src/double-console'; | |
describe.only('doubleConsole()', () => { | |
let callbackSetImmediate: any; | |
let callbackSetTimeout: any; | |
beforeEach(() => { | |
stub(global, 'setImmediate').callsFake((x) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
import { SinonFakeTimers, useFakeTimers, stub, match } from 'sinon'; | |
import { doubleConsole } from '../src/double-console'; | |
describe.only('doubleConsole()', () => { | |
let clock: SinonFakeTimers; | |
beforeEach(() => { | |
clock = useFakeTimers(); | |
stub(global, 'setImmediate').callThrough(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function doubleConsole() { | |
console.log('Now you see me'); | |
setTimeout(() => console.log("Now you don't"), 100); | |
setImmediate(() => console.log("Now still")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UntestableClass from 'untestable-class'; | |
export interface NowTestableClassType { | |
someMethod(p: number): string; | |
} | |
export const NowTestableClass = UntestableClass as new (constructorParam: string) => NowTestableClassType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { nowTestableOldFunction } from './untestable-wrapper'; | |
export function doSomethingUntestable() { | |
return nowTestableOldFunction(123); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
import * as wrapper from '../src/untestable-wrapper'; | |
import untestableOldFunction = require('untestable-old-function'); | |
describe('untestable-wrapper', () => { | |
it('should export untestableOldFunction as nowTestableOldFunction', () => { | |
expect(wrapper.nowTestableOldFunction).to.be.eq(untestableOldFunction); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import untestableOldFunction = require('untestable-old-function'); | |
export const nowTestableOldFunction = untestableOldFunction as (p: number) => string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import untestableOldFunction = require('untestable-old-function'); | |
export function doSomethingUntestable() { | |
return untestableOldFunction(123); | |
} |