Skip to content

Commit

Permalink
add stringify test for v1
Browse files Browse the repository at this point in the history
  • Loading branch information
skad0 committed Oct 12, 2016
1 parent 7ff38c5 commit a0e31cd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
7 changes: 7 additions & 0 deletions test/stringify/common.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const test = require('ava');

const stringify = require('../../lib/stringify');

test('should throws error if no format given', t => {
t.throws(() => stringify({ entity: { block: 'block' }, tech: null }), 'You must declare target format');
});
4 changes: 0 additions & 4 deletions test/stringify/enb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const test = require('ava');

const stringify = require('../../lib/stringify');

test('should throws error if no format given', t => {
t.throws(() => stringify({ entity: { block: 'block' }, tech: null }), 'You must declare target format');
});

test('should stringify enb declaration', t => {
const obj = [{ block: 'block', elem: 'elem', mod: 'mod', val: 'val' }];
t.deepEqual(
Expand Down
25 changes: 25 additions & 0 deletions test/stringify/v1.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const test = require('ava');

const stringify = require('../../lib/stringify');

test('should stringify enb declaration', t => {
const obj = [{
name: 'block',
elems: [{
name: 'elem',
mods: [{
name: 'mod',
vals: [{
name: 'val'
}]
}]
}]
}];
t.deepEqual(
stringify(
{ entity: { block: 'block', elem: 'elem', modName: 'mod', modVal: 'val' }, tech: null },
{ format: 'v1' }
),
'exports.blocks = ' + JSON.stringify(obj, null, 4) + ';\n'
);
});

0 comments on commit a0e31cd

Please sign in to comment.