mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
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:
committed by
Facebook Github Bot
parent
b9e7006cc6
commit
7fd5aa84a1
@@ -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!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user