Last active
February 22, 2020 15:49
-
-
Save Farenheith/94f7b9672cb91d9931f1134a2f34f244 to your computer and use it in GitHub Desktop.
Simple test for example-stream.ts
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'; | |
describe.only('streamExample()', () => { | |
beforeEach(() => { | |
stub(zlib, 'createGzip').returns('createGZip result' as any); | |
}); | |
it('should pipe the given stream to a gzip writer', async () => { | |
const stream = { | |
pipe: stub().returns('piped stream' as any), | |
}; | |
const result = streamExample(stream as any); | |
expect(zlib.createGzip).to.have.been.calledOnceWithExactly(); | |
expect(stream.pipe).to.have.been.calledOnceWithExactly('createGZip result'); | |
expect(result).to.be.eq('piped stream'); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment