Skip to content

Commit 0d759a7

Browse files
committed
Fixed some tests on tag and model
1 parent 2bb0582 commit 0d759a7

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

test/models/model.spec.coffee

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,41 @@ getModel = (attribs) ->
1414
return model
1515

1616
describe 'When a model is being created without attributes', ->
17-
model = null
18-
17+
1918
beforeEach ->
20-
model = getModel()
19+
@model = getModel()
2120

2221
it 'should not have any attributes', ->
23-
model.attributes.should.eql({})
22+
@model.attributes.should.eql({})
2423

2524
describe 'When toJSON() is called', ->
2625
beforeEach ->
27-
jsonObject = model.toJSON()
26+
@jsonObject = @model.toJSON()
2827

2928
it 'should return an empty object', ->
30-
jsonObject.should.eql({})
29+
@jsonObject.should.eql({})
3130

3231
describe 'When a model is created with attributes', ->
33-
model = null
3432

3533
beforeEach ->
36-
model = new Model(two: false)
34+
@model = new Model(two: false)
3735

3836
it 'should have the correct attributes', ->
39-
model.attributes.should.eql two: false
37+
@model.attributes.should.eql two: false
4038

4139
describe 'When toJSON() is called', ->
42-
modelJson = null
4340

4441
beforeEach ->
45-
modelJson = model.toJSON()
42+
@modelJson = @model.toJSON()
4643

4744
it 'should return the attributes object', ->
48-
modelJson.should.eql({ 'two': false })
45+
@modelJson.should.eql({ 'two': false })
4946

5047
describe 'when save() is called', ->
5148

52-
model = getModel({'one': true})
53-
54-
model.save 'testCollection', ->
49+
beforeEach ->
50+
@model = getModel({'one': true})
51+
@model.save 'testCollection', ->
5552

5653
it 'should call save() on the base object', ->
5754
callsToSave.should.have.length(1)

test/models/tag.spec.coffee

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,39 @@ getTag = () ->
2121
return tag
2222

2323
describe 'When creating a new tag', ->
24-
tag = null
2524

2625
beforeEach ->
27-
tag = new Tag()
26+
@tag = new Tag()
2827

2928
it 'should have default attributes', ->
30-
should.strictEqual(tag.attributes._id, undefined)
31-
should.strictEqual(tag.attributes.user, undefined)
32-
should.strictEqual(tag.attributes.event, undefined)
33-
should.exist(tag.attributes.generatedOn)
34-
should.exist(tag.attributes.code)
29+
should.strictEqual(@tag.attributes._id, undefined)
30+
should.strictEqual(@tag.attributes.user, undefined)
31+
should.strictEqual(@tag.attributes.event, undefined)
32+
should.exist(@tag.attributes.generatedOn)
33+
should.exist(@tag.attributes.code)
3534

3635
describe 'When creating a tag with attributes', ->
37-
tag = null
38-
36+
3937
beforeEach ->
40-
tag = new Tag(expectedAttributes)
38+
@tag = new Tag(expectedAttributes)
4139

4240
it 'should set the correct id', ->
43-
tag.attributes._id.should.equal(expectedAttributes._id)
41+
@tag.attributes._id.should.equal(expectedAttributes._id)
4442

4543
it 'should set the correct generatedOn date', ->
46-
tag.attributes.generatedOn.should.equal(expectedAttributes.generatedOn)
44+
@tag.attributes.generatedOn.should.eql(expectedAttributes.generatedOn)
4745

4846
it 'should set the correct code', ->
49-
tag.attributes.code.should.equal(expectedAttributes.code)
47+
@tag.attributes.code.should.equal(expectedAttributes.code)
5048

5149
it 'should set the correct user', ->
52-
tag.attributes.user.should.equal(expectedAttributes.user)
50+
console.log @tag.attributes.user
51+
52+
console.log expectedAttributes.user
53+
@tag.attributes.user.should.eql(expectedAttributes.user)
5354

5455
it 'should set the correct event', ->
55-
tag.attributes.event.should.equal(expectedAttributes.event)
56+
@tag.attributes.event.should.eql(expectedAttributes.event)
5657

5758
describe 'when calling save() on a tag', ->
5859
getTag().save ->

0 commit comments

Comments
 (0)