Skip to content

Commit 0ed2ccd

Browse files
committed
Reorganized file to put tests first
1 parent fd7216d commit 0ed2ccd

File tree

4 files changed

+42
-40
lines changed

4 files changed

+42
-40
lines changed

test/data/adapters/inMemory_test.coffee

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
vows = require 'vows'
22
should = require 'should'
33
InMemoryDataAdapter = require '../../../data/adapters/inMemory'
4-
sampleObjects = [
5-
{ 'test': true, 'numeric': 52, 'items': ['one', 'two'] },
6-
{ 'one': true, 'two': false }
7-
]
84

95
vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
106
'': {
@@ -99,4 +95,9 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
9995
items[0].newObject.should.eql(sampleObjects[1])
10096
}
10197
}
102-
).export(module)
98+
).export(module)
99+
100+
sampleObjects = [
101+
{ 'test': true, 'numeric': 52, 'items': ['one', 'two'] },
102+
{ 'one': true, 'two': false }
103+
]

test/data/storedObject_test.coffee

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ vows = require 'vows'
22
should = require 'should'
33
StoredObject = require '../../data/storedObject'
44

5-
callCount = 0
6-
args = []
7-
8-
getTopic = () ->
9-
topic = new StoredObject()
10-
topic._adapter =
11-
save: (collection, attributes, callback) ->
12-
callCount++;
13-
args.push([collection, attributes, callback])
14-
callback(null, attributes)
15-
return topic
16-
175
vows.describe('Base stored object (data/storedObject)').addBatch(
186
'': {
197
topic: () -> getTopic()
@@ -35,4 +23,16 @@ vows.describe('Base stored object (data/storedObject)').addBatch(
3523
args[0][2].should.equal(@callback)
3624
}
3725
}
38-
).export(module)
26+
).export(module)
27+
28+
callCount = 0
29+
args = []
30+
31+
getTopic = () ->
32+
topic = new StoredObject()
33+
topic._adapter =
34+
save: (collection, attributes, callback) ->
35+
callCount++;
36+
args.push([collection, attributes, callback])
37+
callback(null, attributes)
38+
return topic

test/models/model_test.coffee

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@ should = require 'should'
33
StoredObject = require '../../data/storedObject'
44
Model = require '../../models/model'
55

6-
callCount = 0
7-
args = []
8-
9-
getTopic = () ->
10-
topic = new Model()
11-
topic._adapter =
12-
save: (collection, attributes, callback) ->
13-
callCount++;
14-
args.push([collection, attributes, callback])
15-
callback(null, attributes)
16-
return topic
17-
186
vows.describe('Base model (models/model)').addBatch(
197
'': {
208
topic: () -> getTopic()
@@ -43,18 +31,31 @@ vows.describe('Base model (models/model)').addBatch(
4331
}
4432
instance.save('testCollection', @callback)
4533

46-
'it should call save() on the base stored object': (err, attributes) ->
34+
'it should call save() on the base object': (err, attributes) ->
4735
callCount.should.equal(1)
4836
args.should.have.length(1)
4937

5038
'it should pass model.attributes to the save()': (err, attributes) ->
5139
args[0].should.have.length(3)
5240
args[0][1].should.eql({ 'one': true })
5341

54-
'it should pass collection and callback to base object': (err, attributes) ->
42+
'it should pass collection and callback to base': (err, attributes) ->
5543
args[0].should.have.length(3)
5644
args[0][0].should.equal('testCollection')
5745
args[0][2].should.not.be.null
5846
}
5947
}
6048
).export(module)
49+
50+
callCount = 0
51+
args = []
52+
53+
getTopic = () ->
54+
topic = new Model()
55+
topic._adapter =
56+
save: (collection, attributes, callback) ->
57+
callCount++;
58+
args.push([collection, attributes, callback])
59+
callback(null, attributes)
60+
return topic
61+

test/models/user_test.coffee

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
vows = require 'vows'
22
should = require 'should'
33
User = require '../../models/user'
4-
5-
expectedAttributes =
6-
name: 'Abraham Lincoln'
7-
userSince: new Date()
8-
slugs: ['abe', 'penniesrock']
9-
handles: [{type: 'twitter', handle: 'abelincoln'}]
10-
credentials: [{provider: 'twitter', id: 1234 }]
11-
_id: 1234
124

135
vows.describe('User (models/user)').addBatch(
146
'when creating a user model': {
@@ -44,3 +36,11 @@ vows.describe('User (models/user)').addBatch(
4436
user.attributes._id.should.equal(expectedAttributes._id)
4537
}
4638
).export(module)
39+
40+
expectedAttributes =
41+
name: 'Abraham Lincoln'
42+
userSince: new Date()
43+
slugs: ['abe', 'penniesrock']
44+
handles: [{type: 'twitter', handle: 'abelincoln'}]
45+
credentials: [{provider: 'twitter', id: 1234 }]
46+
_id: 1234

0 commit comments

Comments
 (0)