Skip to content

Commit

Permalink
Refactor test cases to check json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollado committed Sep 22, 2015
1 parent d437679 commit 947b6f6
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ describe('Model without attributes', function() {
});

it('as json', function() {
expect(renderer.toJSON()).to.deep.equal(
{
modelName: modelName,
attrs: {}
});
var json = renderer.toJSON();
var expected = {
modelName: modelName,
attrs: {}
};

expect(json).to.deep.equal(expected);
expect(JSON.stringify).to.not.throw();
});

it('as string', function() {
Expand All @@ -44,15 +47,17 @@ describe('Model with attributes', function() {
});

it('as json', function() {
expect(renderer.toJSON()).to.deep.equal(
{
modelName: modelName,
attrs: {
a: {},
b: {},
c: {}
}
});
var json = renderer.toJSON();
var expected = {
modelName: modelName,
attrs: {
a: {},
b: {},
c: {}
}
};
expect(json).to.deep.equal(expected);
expect(JSON.stringify).to.not.throw();
});

it('as string', function() {
Expand All @@ -71,15 +76,17 @@ describe('Model with ID key', function() {
});

it('as json', function() {
expect(renderer.toJSON()).to.deep.equal(
{
modelName: modelName,
attrs: {
id: {
primaryKey: true
},
}
});
var json = renderer.toJSON();
var expected = {
modelName: modelName,
attrs: {
id: {
primaryKey: true
},
}
};
expect(json).to.deep.equal(expected);
expect(JSON.stringify).to.not.throw();
});

it('as string', function() {
Expand Down

0 comments on commit 947b6f6

Please sign in to comment.