@@ -111,8 +111,8 @@ describe('core', function() {
111
111
112
112
describe ( '#problems' , function ( ) {
113
113
var PROBLEMS = [
114
- { id : 0 , name : 'name0' , slug : 'slug0' , starred : false } ,
115
- { id : 1 , name : 'name1' , slug : 'slug1' , starred : true }
114
+ { id : 0 , name : 'name0' , slug : 'slug0' , starred : false , category : 'algorithms' } ,
115
+ { id : 1 , name : 'name1' , slug : 'slug1' , starred : true , category : 'algorithms' }
116
116
] ;
117
117
var RESULTS = [
118
118
{ name : 'result0' } ,
@@ -121,7 +121,7 @@ describe('core', function() {
121
121
122
122
describe ( '#getProblems' , function ( ) {
123
123
it ( 'should getProblems w/ cache ok' , function ( done ) {
124
- cache . set ( 'all ' , PROBLEMS ) ;
124
+ cache . set ( 'problems ' , PROBLEMS ) ;
125
125
126
126
core . getProblems ( function ( e , problems ) {
127
127
assert . equal ( e , null ) ;
@@ -131,7 +131,7 @@ describe('core', function() {
131
131
} ) ;
132
132
133
133
it ( 'should getProblems w/o cache ok' , function ( done ) {
134
- cache . del ( 'all ' ) ;
134
+ cache . del ( 'problems ' ) ;
135
135
136
136
client . getProblems = function ( category , user , cb ) {
137
137
return cb ( null , PROBLEMS ) ;
@@ -145,7 +145,7 @@ describe('core', function() {
145
145
} ) ;
146
146
147
147
it ( 'should getProblems w/o cache fail if client error' , function ( done ) {
148
- cache . del ( 'all ' ) ;
148
+ cache . del ( 'problems ' ) ;
149
149
150
150
client . getProblems = function ( category , user , cb ) {
151
151
return cb ( 'client getProblems error' ) ;
@@ -160,8 +160,8 @@ describe('core', function() {
160
160
161
161
describe ( '#getProblem' , function ( ) {
162
162
it ( 'should getProblem by id w/ cache ok' , function ( done ) {
163
- cache . set ( 'all ' , PROBLEMS ) ;
164
- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
163
+ cache . set ( 'problems ' , PROBLEMS ) ;
164
+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
165
165
166
166
core . getProblem ( 0 , function ( e , problem ) {
167
167
assert . equal ( e , null ) ;
@@ -171,8 +171,8 @@ describe('core', function() {
171
171
} ) ;
172
172
173
173
it ( 'should getProblem by name w/ cache ok' , function ( done ) {
174
- cache . set ( 'all ' , PROBLEMS ) ;
175
- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
174
+ cache . set ( 'problems ' , PROBLEMS ) ;
175
+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
176
176
177
177
core . getProblem ( 'name0' , function ( e , problem ) {
178
178
assert . equal ( e , null ) ;
@@ -182,8 +182,8 @@ describe('core', function() {
182
182
} ) ;
183
183
184
184
it ( 'should getProblem by key w/ cache ok' , function ( done ) {
185
- cache . set ( 'all ' , PROBLEMS ) ;
186
- cache . set ( 'slug0' , PROBLEMS [ 0 ] ) ;
185
+ cache . set ( 'problems ' , PROBLEMS ) ;
186
+ cache . set ( '0. slug0.algorithms ' , PROBLEMS [ 0 ] ) ;
187
187
188
188
core . getProblem ( 'slug0' , function ( e , problem ) {
189
189
assert . equal ( e , null ) ;
@@ -193,8 +193,8 @@ describe('core', function() {
193
193
} ) ;
194
194
195
195
it ( 'should getProblem by id w/o cache ok' , function ( done ) {
196
- cache . set ( 'all ' , PROBLEMS ) ;
197
- cache . del ( 'slug0' ) ;
196
+ cache . set ( 'problems ' , PROBLEMS ) ;
197
+ cache . del ( '0. slug0.algorithms ' ) ;
198
198
199
199
client . getProblem = function ( user , problem , cb ) {
200
200
return cb ( null , problem ) ;
@@ -208,7 +208,7 @@ describe('core', function() {
208
208
} ) ;
209
209
210
210
it ( 'should getProblem error if not found' , function ( done ) {
211
- cache . set ( 'all ' , PROBLEMS ) ;
211
+ cache . set ( 'problems ' , PROBLEMS ) ;
212
212
213
213
core . getProblem ( 3 , function ( e , problem ) {
214
214
assert . equal ( e , 'Problem not found!' ) ;
@@ -217,8 +217,8 @@ describe('core', function() {
217
217
} ) ;
218
218
219
219
it ( 'should getProblem fail if client error' , function ( done ) {
220
- cache . set ( 'all ' , PROBLEMS ) ;
221
- cache . del ( 'slug0' ) ;
220
+ cache . set ( 'problems ' , PROBLEMS ) ;
221
+ cache . del ( '0. slug0.algorithms ' ) ;
222
222
223
223
client . getProblem = function ( user , problem , cb ) {
224
224
return cb ( 'client getProblem error' ) ;
@@ -231,7 +231,7 @@ describe('core', function() {
231
231
} ) ;
232
232
233
233
it ( 'should getProblem fail if getProblems error' , function ( done ) {
234
- cache . del ( 'all ' ) ;
234
+ cache . del ( 'problems ' ) ;
235
235
client . getProblems = function ( category , user , cb ) {
236
236
return cb ( 'getProblems error' ) ;
237
237
} ;
@@ -245,8 +245,8 @@ describe('core', function() {
245
245
246
246
describe ( '#updateProblem' , function ( ) {
247
247
it ( 'should updateProblem ok' , function ( done ) {
248
- cache . set ( 'all ' , PROBLEMS ) ;
249
- cache . del ( 'slug0' ) ;
248
+ cache . set ( 'problems ' , PROBLEMS ) ;
249
+ cache . del ( '0. slug0.algorithms ' ) ;
250
250
251
251
var kv = { value : 'value00' } ;
252
252
var ret = core . updateProblem ( PROBLEMS [ 0 ] , kv ) ;
@@ -255,19 +255,19 @@ describe('core', function() {
255
255
core . getProblem ( 0 , function ( e , problem ) {
256
256
assert . equal ( e , null ) ;
257
257
assert . deepEqual ( problem ,
258
- { id : 0 , name : 'name0' , slug : 'slug0' , value : 'value00' , starred : false } ) ;
258
+ { id : 0 , name : 'name0' , slug : 'slug0' , value : 'value00' , starred : false , category : 'algorithms' } ) ;
259
259
done ( ) ;
260
260
} ) ;
261
261
} ) ;
262
262
263
263
it ( 'should updateProblem fail if no problems found' , function ( ) {
264
- cache . del ( 'all ' ) ;
264
+ cache . del ( 'problems ' ) ;
265
265
var ret = core . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
266
266
assert . equal ( ret , false ) ;
267
267
} ) ;
268
268
269
269
it ( 'should updateProblem fail if unknown problem' , function ( ) {
270
- cache . set ( 'all ' , [ PROBLEMS [ 1 ] ] ) ;
270
+ cache . set ( 'problems ' , [ PROBLEMS [ 1 ] ] ) ;
271
271
var ret = core . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
272
272
assert . equal ( ret , false ) ;
273
273
} ) ;
0 commit comments