@@ -6,25 +6,24 @@ sampleObjects = [
66 { ' one' : true , ' two' : false }
77]
88
9- describe ' When using a In-memory store (data/adapters/inMemory)' , ->
10-
9+ describe (' In-memory store (data/adapters/inMemory)' , ->
1110 beforeEach ->
1211 @adapter = new InMemoryDataAdapter ()
13-
12+
1413 it ' should require no constructor arguments' , ->
1514 should .exist (@adapter )
16-
15+
1716 it ' should be empty when nothing has been added' , ->
1817 @adapter .items .should .eql ({})
1918
20- describe ' when saving a new item' , ->
21-
19+ describe (' when saving a new item' , ->
2220 beforeEach (done ) ->
23- @adapter .save ' testObjects' , sampleObjects[0 ], (e , a ) =>
21+ @adapter .save ( ' testObjects' , sampleObjects[0 ], (e , a ) =>
2422 @attributes = a
2523 @err = e
2624 done ()
27-
25+ )
26+
2827 it ' should pass back the original attributes' , ->
2928 should .not .exist (@err )
3029 @attributes .test .should .be .true
@@ -33,79 +32,88 @@ describe 'When using a In-memory store (data/adapters/inMemory)', ->
3332
3433 it ' should not simply use the same object in memory' , ->
3534 # standard equal compares memory addresses
36- @attributes .should .not .equal (sampleObjects[0 ])
35+ @attributes .should .not .equal (sampleObjects[0 ])
3736
3837 it ' should add an _id attribute' , ->
3938 @attributes .should .have .property (' _id' )
40- @attributes ._id .should .equal (0 )
41-
42- describe ' when updating an existing item' , ->
43-
44- beforeEach (done ) ->
45- @adapter .save ' testObjects' , {
46- ' _id' : 0
47- ' newObject' : sampleObjects[1 ]
48- }, (e , a ) =>
49- @err = e
50- @attributes = a
51- done ()
52-
53- it ' should pass back the new attributes' , ->
54- should .not .exist (@err )
55- should .exist (@attributes )
56- @attributes ._id .should .equal (0 )
57- @attributes .newObject .should .eql (sampleObjects[1 ])
58-
59- describe ' When finding an object by real id' , ->
60-
61- beforeEach (done ) ->
62- @adapter .find ' testObjects' , {' _id' : 0 }, (e , i ) =>
63- @err = e
64- @foundItems = i
65- done ()
39+ @attributes ._id .should .equal (0 )
40+ )
6641
67- it ' should return the object stored' , ->
68- should .not .exist (@err )
69- should .exist (@foundItems )
70- @foundItems .should .have .length (1 )
71- @foundItems [0 ]._id .should .equal (0 )
42+ describe (' when updating an existing item' , ->
43+ beforeEach (done ) ->
44+ attributes = { ' _id' : 0 , ' newObject' : sampleObjects[1 ] }
45+ @adapter .save (' testObjects' , attributes, (e , a ) =>
46+ @err = e
47+ @attributes = a
48+ done ()
49+ )
7250
73- describe ' when finding an object by a fake id' , ->
74-
75- beforeEach (done ) ->
76- @adapter .find ' testObjects' , {' _id' : 1 }, (e , i ) =>
51+ it ' should pass back the new attributes' , ->
52+ should .not .exist (@err )
53+ should .exist (@attributes )
54+ @attributes ._id .should .equal (0 )
55+ @attributes .newObject .should .eql (sampleObjects[1 ])
56+ )
57+
58+ describe (' When finding an object by real id' , ->
59+ beforeEach (done ) ->
60+ @adapter .save (' testObjects' , sampleObjects[0 ], (e , a ) =>
61+ @adapter .find (' testObjects' , {' _id' : 0 }, (e , i ) =>
7762 @err = e
7863 @foundItems = i
7964 done ()
65+ )
66+ )
67+
68+ it ' should return the object stored' , ->
69+ should .not .exist (@err )
70+ should .exist (@foundItems )
71+ @foundItems .should .have .length (1 )
72+ @foundItems [0 ]._id .should .equal (0 )
73+ )
8074
81- it ' should not return any items' , ->
82- should .not .exist (@err )
83- should .exist (@foundItems )
84- @foundItems .should .have .length (0 )
75+ describe (' when finding an object by a fake id' , ->
76+ beforeEach (done ) ->
77+ @adapter .find (' testObjects' , {' _id' : 1 }, (e , i ) =>
78+ @err = e
79+ @foundItems = i
80+ done ()
81+ )
8582
86- describe ' when finding an object in a non-existent collection' , ->
87-
88- beforeEach (done ) ->
89- @adapter .find ' notestObjects' , {' _id' : 0 }, (e , i ) =>
90- @err = e
91- @foundItems = i
92- done ()
83+ it ' should not return any items' , ->
84+ should .not .exist (@err )
85+ should .exist (@foundItems )
86+ @foundItems .should .have .length (0 )
87+ )
9388
94- it ' should not return any items' , ->
95- should .not .exist (@err )
96- should .exist (@foundItems )
97- @foundItems .should .have .length (0 )
89+ describe (' when finding an object in a non-existent collection' , ->
90+ beforeEach (done ) ->
91+ @adapter .find (' notestObjects' , {' _id' : 0 }, (e , i ) =>
92+ @err = e
93+ @foundItems = i
94+ done ()
95+ )
96+
97+ it ' should not return any items' , ->
98+ should .not .exist (@err )
99+ should .exist (@foundItems )
100+ @foundItems .should .have .length (0 )
101+ )
98102
99- describe ' when searching with no parameters' , ->
100-
101- beforeEach ( done ) ->
102- @adapter .find ' testObjects' , {}, (e , i ) =>
103+ describe ( ' when searching with no parameters' , ->
104+ beforeEach ( done ) ->
105+ @adapter . save ( ' testObjects ' , sampleObjects[ 0 ], ( e , a ) =>
106+ @adapter .find ( ' testObjects' , {}, (e , i ) =>
103107 @err = e
104108 @foundItems = i
105- done ()
106-
107- it ' should return all items in the collection' , ->
108- should .not .exist (@err )
109- should .exist (@foundItems )
110- @foundItems .should .have .length (1 )
111- @foundItems [0 ]._id .should .equal (0 )
109+ done ()
110+ )
111+ )
112+
113+ it ' should return all items in the collection' , ->
114+ should .not .exist (@err )
115+ should .exist (@foundItems )
116+ @foundItems .should .have .length (1 )
117+ @foundItems [0 ]._id .should .equal (0 )
118+ )
119+ )
0 commit comments