Skip to content

Commit

Permalink
fixup! fixup! fixup! Formats explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
skad0 committed Mar 16, 2017
1 parent 97c2adc commit ba0ec5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const fieldByFormat = {
const generators = {
json5: (obj, space) => JSON5.stringify(obj, null, space),
json: (obj, space) => JSON.stringify(obj, null, space),
commonjs: (obj, space) => `module.exports = ${JSON.stringify(obj, null, space)};\n`,
es2015: (obj, space) => `export default ${JSON.stringify(obj, null, space)};\n`
commonjs: (obj, space) => `module.exports = ${JSON5.stringify(obj, null, space)};\n`,
es2015: (obj, space) => `export default ${JSON5.stringify(obj, null, space)};\n`
};
// Aliases
generators.es6 = generators.es2015;
Expand Down
18 changes: 9 additions & 9 deletions test/stringify/enb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@ test('should throws error if no format given', t => {
});

test('should stringify enb declaration with commonJS', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb', exportType: 'commonjs' }),
`module.exports = ${JSON.stringify(obj, null, 4)};\n`
`module.exports = ${JSON5.stringify(obj, null, 4)};\n`
);
});

test('should stringify enb declaration with es6', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb', exportType: 'es6' }),
`export default ${JSON.stringify(obj, null, 4)};\n`
`export default ${JSON5.stringify(obj, null, 4)};\n`
);
});

test('should stringify enb declaration with es2105', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb', exportType: 'es2015' }),
`export default ${JSON.stringify(obj, null, 4)};\n`
`export default ${JSON5.stringify(obj, null, 4)};\n`
);
});

test('should stringify enb declaration with JSON', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb', exportType: 'json' }),
JSON.stringify(obj, null, 4)
);
});

test('should stringify enb declaration with JSON5', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb', exportType: 'json5' }),
JSON5.stringify(obj, null, 4)
);
});

test('should stringify enb declaration with JSON5 if no exportType given', t => {
t.deepEqual(
t.is(
stringify(cell, { format: 'enb' }),
JSON5.stringify(obj, null, 4)
);
Expand Down

0 comments on commit ba0ec5a

Please sign in to comment.