File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -277,4 +277,12 @@ describe('helper', function() {
277277 } ) ;
278278 } ) ;
279279 } ) ; // #readStdin
280+
281+ describe ( '#badge' , function ( ) {
282+ it ( 'should ok' , function ( ) {
283+ chalk . enabled = true ;
284+ assert . equal ( h . badge ( 'x' ) , chalk . white . bgBlue ( ' x ' ) ) ;
285+ assert . equal ( h . badge ( 'x' , 'green' ) , chalk . black . bgGreen ( ' x ' ) ) ;
286+ } ) ;
287+ } ) ; // #badge
280288} ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const assert = require ( 'chai' ) . assert ;
3+ const rewire = require ( 'rewire' ) ;
4+
5+ const session = rewire ( '../lib/session' ) ;
6+
7+ describe ( 'session' , function ( ) {
8+ let stats = null ;
9+ let now = '' ;
10+
11+ before ( function ( ) {
12+ const cache = {
13+ get : ( k ) => stats ,
14+ set : ( k , v ) => stats = v
15+ } ;
16+ session . __set__ ( 'cache' , cache ) ;
17+
18+ const moment = ( ) => {
19+ return {
20+ format : ( ) => now
21+ }
22+ } ;
23+ session . __set__ ( 'moment' , moment ) ;
24+ } ) ;
25+
26+ describe ( '#updateStat' , function ( ) {
27+ it ( 'should ok' , function ( ) {
28+ now = '2017.12.13' ;
29+ session . updateStat ( 'ac' , 10 ) ;
30+ assert . deepEqual ( stats , {
31+ '2017.12.13' : { ac : 10 }
32+ } ) ;
33+
34+ session . updateStat ( 'ac' , 20 ) ;
35+ assert . deepEqual ( stats , {
36+ '2017.12.13' : { ac : 30 }
37+ } ) ;
38+
39+ now = '2017.12.14' ;
40+ session . updateStat ( 'ac' , 40 ) ;
41+ assert . deepEqual ( stats , {
42+ '2017.12.13' : { ac : 30 } ,
43+ '2017.12.14' : { ac : 40 }
44+ } ) ;
45+ } ) ;
46+ } ) ;
47+ } ) ;
You can’t perform that action at this time.
0 commit comments