Skip to content

Commit

Permalink
feature(estree-to-babel) add tokens support
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 16, 2019
1 parent b7c1e64 commit f4d033b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/estree-to-babel.js
Expand Up @@ -16,13 +16,15 @@ const isNull = (a) => a === null;
module.exports = (node) => {
const {
comments = [],
tokens,
...program
} = node;

const ast = {
type: 'File',
program,
comments,
tokens,
};

traverse(ast, {
Expand Down
14 changes: 7 additions & 7 deletions test/estree-to-babel.js
Expand Up @@ -58,7 +58,7 @@ test('estree-to-babel: property', (t) => {

update('property', result);

t.deepEqual(result, fixture.ast.property, 'should equal');
t.jsonEqual(result, fixture.ast.property, 'should equal');
t.end();
});

Expand All @@ -68,7 +68,7 @@ test('estree-to-babel: object-method', (t) => {

update('object-method', result);

t.deepEqual(result, fixture.ast.objectMethod, 'should equal');
t.jsonEqual(result, fixture.ast.objectMethod, 'should equal');
t.end();
});

Expand All @@ -78,7 +78,7 @@ test('estree-to-babel: string-literal', (t) => {

update('string-literal', result);

t.deepEqual(result, fixture.ast.stringLiteral, 'should equal');
t.jsonEqual(result, fixture.ast.stringLiteral, 'should equal');
t.end();
});

Expand All @@ -88,7 +88,7 @@ test('estree-to-babel: numeric-literal', (t) => {

update('numeric-literal', result);

t.deepEqual(result, fixture.ast.numericLiteral, 'should equal');
t.jsonEqual(result, fixture.ast.numericLiteral, 'should equal');
t.end();
});

Expand All @@ -98,7 +98,7 @@ test('estree-to-babel: null literal', (t) => {

update('null-literal', result);

t.deepEqual(result, fixture.ast.nullLiteral, 'should equal');
t.jsonEqual(result, fixture.ast.nullLiteral, 'should equal');
t.end();
});

Expand All @@ -108,7 +108,7 @@ test('estree-to-babel: comments', (t) => {

update('comments', result);

t.deepEqual(result, fixture.ast.comments, 'should equal');
t.jsonEqual(result, fixture.ast.comments, 'should equal');
t.end();
});

Expand All @@ -118,7 +118,7 @@ test('estree-to-babel: class method', (t) => {

update('class-method', result);

t.deepEqual(result, fixture.ast.classMethod, 'should equal');
t.jsonEqual(result, fixture.ast.classMethod, 'should equal');
t.end();
});

2 changes: 1 addition & 1 deletion test/fixture/class-method.json
Expand Up @@ -220,4 +220,4 @@
"sourceType": "script"
},
"comments": []
}
}

0 comments on commit f4d033b

Please sign in to comment.