11'use strict' ;
2- var execSync = require ( 'child_process' ) . execSync ;
3- var fs = require ( 'fs' ) ;
2+ const execSync = require ( 'child_process' ) . execSync ;
3+ const fs = require ( 'fs' ) ;
44
5- var _ = require ( 'underscore' ) ;
6- var assert = require ( 'chai' ) . assert ;
7- var rewire = require ( 'rewire' ) ;
5+ const _ = require ( 'underscore' ) ;
6+ const assert = require ( 'chai' ) . assert ;
7+ const rewire = require ( 'rewire' ) ;
88
9- var log = require ( '../../lib/log' ) ;
10- var config = require ( '../../lib/config' ) ;
9+ const log = require ( '../../lib/log' ) ;
10+ const config = require ( '../../lib/config' ) ;
1111
12- var cache = rewire ( '../../lib/cache' ) ;
13- var h = rewire ( '../../lib/helper' ) ;
14- var session = rewire ( '../../lib/session' ) ;
15- var plugin = rewire ( '../../lib/plugins/cache' ) ;
12+ const cache = rewire ( '../../lib/cache' ) ;
13+ const h = rewire ( '../../lib/helper' ) ;
14+ const session = rewire ( '../../lib/session' ) ;
15+ const plugin = rewire ( '../../lib/plugins/cache' ) ;
1616
17- var HOME = './tmp' ;
17+ const HOME = './tmp' ;
1818
1919describe ( 'plugin:cache' , function ( ) {
20- var PROBLEMS = [
20+ const PROBLEMS = [
2121 { id : 0 , name : 'name0' , slug : 'slug0' , starred : false , category : 'algorithms' } ,
2222 { id : 1 , name : 'name1' , slug : 'slug1' , starred : true , category : 'algorithms' }
2323 ] ;
24- var PROBLEM = { id : 0 , slug : 'slug0' , category : 'algorithms' } ;
24+ const PROBLEM = { id : 0 , slug : 'slug0' , category : 'algorithms' } ;
2525
26- var NEXT = { } ;
26+ const NEXT = { } ;
2727
2828 before ( function ( ) {
2929 log . init ( ) ;
@@ -132,11 +132,11 @@ describe('plugin:cache', function() {
132132 it ( 'should ok' , function ( ) {
133133 cache . del ( '0.slug0.algorithms' ) ;
134134
135- var problem = _ . clone ( PROBLEMS [ 0 ] ) ;
135+ const problem = _ . clone ( PROBLEMS [ 0 ] ) ;
136136 problem . locked = true ;
137137 problem . state = 'ac' ;
138138
139- var ret = plugin . saveProblem ( problem ) ;
139+ const ret = plugin . saveProblem ( problem ) ;
140140 assert . equal ( ret , true ) ;
141141 assert . deepEqual ( cache . get ( '0.slug0.algorithms' ) ,
142142 { id : 0 , slug : 'slug0' , name : 'name0' , category : 'algorithms' } ) ;
@@ -147,8 +147,8 @@ describe('plugin:cache', function() {
147147 it ( 'should updateProblem ok' , function ( done ) {
148148 cache . set ( 'problems' , PROBLEMS ) ;
149149
150- var kv = { value : 'value00' } ;
151- var ret = plugin . updateProblem ( PROBLEMS [ 0 ] , kv ) ;
150+ const kv = { value : 'value00' } ;
151+ const ret = plugin . updateProblem ( PROBLEMS [ 0 ] , kv ) ;
152152 assert . equal ( ret , true ) ;
153153
154154 plugin . getProblems ( function ( e , problems ) {
@@ -163,20 +163,20 @@ describe('plugin:cache', function() {
163163
164164 it ( 'should updateProblem fail if no problems found' , function ( ) {
165165 cache . del ( 'problems' ) ;
166- var ret = plugin . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
166+ const ret = plugin . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
167167 assert . equal ( ret , false ) ;
168168 } ) ;
169169
170170 it ( 'should updateProblem fail if unknown problem' , function ( ) {
171171 cache . set ( 'problems' , [ PROBLEMS [ 1 ] ] ) ;
172- var ret = plugin . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
172+ const ret = plugin . updateProblem ( PROBLEMS [ 0 ] , { } ) ;
173173 assert . equal ( ret , false ) ;
174174 } ) ;
175175 } ) ; // #updateProblem
176176
177177 describe ( '#user' , function ( ) {
178- var USER = { name : 'test-user' , pass : 'password' } ;
179- var USER_SAFE = { name : 'test-user' } ;
178+ const USER = { name : 'test-user' , pass : 'password' } ;
179+ const USER_SAFE = { name : 'test-user' } ;
180180
181181 it ( 'should login ok' , function ( done ) {
182182 config . autologin . enable = true ;
0 commit comments