packager-worker-for-buck: refactor and fix source map output

Reviewed By: davidaurelio

Differential Revision: D6385199

fbshipit-source-id: f104f7b000dde131b57b671d14d4ec4e0d30d7a2
This commit is contained in:
Jean Lauliac
2017-11-22 05:05:53 -08:00
committed by Facebook Github Bot
parent b9e7006cc6
commit 7fd5aa84a1
2 changed files with 79 additions and 16 deletions

View File

@@ -24,6 +24,10 @@ jest.mock('fs');
const fs = require('fs');
describe('fs mock', () => {
beforeEach(() => {
(fs: $FlowFixMe).mock.clear();
});
describe('writeFileSync()', () => {
it('stores content correctly', () => {
fs.writeFileSync('/test', 'foobar', 'utf8');
@@ -55,4 +59,28 @@ describe('fs mock', () => {
expect(content).toEqual('foobar');
});
});
describe('createWriteStream()', () => {
it('writes content', done => {
const stream = fs.createWriteStream('/test');
stream.write('hello, ');
stream.write('world');
stream.end('!');
process.nextTick(() => {
const content = fs.readFileSync('/test', 'utf8');
expect(content).toEqual('hello, world!');
done();
});
});
});
describe('writeSync()', () => {
it('writes content', () => {
const fd = fs.openSync('/test', 'w');
fs.writeSync(fd, 'hello, world!');
fs.closeSync(fd);
const content = fs.readFileSync('/test', 'utf8');
expect(content).toEqual('hello, world!');
});
});
});