Skip to content

Commit

Permalink
Fix flow options
Browse files Browse the repository at this point in the history
Also added tests to ensure we can parse JSX.
  • Loading branch information
fkling committed Dec 3, 2018
1 parent 1cbe93d commit 2fd2429
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion parser/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultOptions = {
esproposal_export_star_as: true,
esproposal_optional_chaining: true,
esproposal_nullish_coalescing: true,
token: true,
tokens: true,
types: true,
};

Expand Down
48 changes: 28 additions & 20 deletions src/__tests__/Worker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,39 @@ describe('Worker API', () => {
});
});

it('uses babylon if configured as such', done => {
const transformPath = getTransformForParser('babylon');
const sourcePath = getSourceFile();
const emitter = worker([transformPath]);

emitter.send({files: [sourcePath]});
emitter.once('message', (data) => {
expect(data.status).toBe('ok');
expect(getFileContent(sourcePath)).toBe('changed');
done();
['flow', 'babylon'].forEach(parser => {
it(`uses ${parser} if configured as such`, done => {
const transformPath = getTransformForParser(parser);
const sourcePath = getSourceFile();
const emitter = worker([transformPath]);

emitter.send({files: [sourcePath]});
emitter.once('message', (data) => {
expect(data.status).toBe('ok');
expect(getFileContent(sourcePath)).toBe('changed');
done();
});
});
});

it('uses flow if configured as such', done => {
const transformPath = getTransformForParser('flow');
const sourcePath = getSourceFile();
const emitter = worker([transformPath]);

emitter.send({files: [sourcePath]});
emitter.once('message', (data) => {
expect(data.status).toBe('ok');
expect(getFileContent(sourcePath)).toBe('changed');
done();
['babylon', 'flow', 'tsx'].forEach(parser => {
it(`can parse JSX with ${parser}`, done => {
const transformPath = getTransformForParser(parser);
const sourcePath = createTempFileWith(
'var component = <div>{foobar}</div>;'
);
const emitter = worker([transformPath]);

emitter.send({files: [sourcePath]});
emitter.once('message', (data) => {
expect(data.status).toBe('ok');
expect(getFileContent(sourcePath)).toBe('changed');
done();
});
});
});

});


});

0 comments on commit 2fd2429

Please sign in to comment.