@@ -7,10 +7,56 @@ describe('settings', function() {
77
88 it ( 'language setting should be set' , function ( ) {
99 const expect = { lang : 'en' } ;
10- var s = new Settings ( ) ;
11- s . setLanguage ( 'en' ) ;
12- assert . equal ( s . getSettings ( ) . lang , expect . lang ) ;
10+ var set = new Settings ( ) ;
11+ set . setLanguage ( 'en' ) ;
12+ assert . equal ( set . getSettings ( ) . lang , expect . lang ) ;
1313 } ) ;
1414
15+
16+
17+ var s = new Settings ( ) ;
18+ it ( 'city london should be added to custom field filters' , function ( ) {
19+ s . addCustomFieldFilter ( 'city' , 'london' ) ;
20+ var expect = '["city%3Dlondon"]' ;
21+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
22+ } ) ;
23+
24+ it ( 'city berlin and color red should be added to custom field filters' , function ( ) {
25+ s . addCustomFieldFilter ( 'city' , 'berlin' ) ;
26+ var expect = '["city%3Dlondon","city%3Dberlin"]' ;
27+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
28+
29+ s . addCustomFieldFilter ( 'color' , 'red' ) ;
30+ expect = '["city%3Dlondon","city%3Dberlin","color%3Dred"]' ;
31+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
32+ } ) ;
33+
34+ it ( 'color blue should be added and red removed from custom field filters' , function ( ) {
35+ s . addCustomFieldFilter ( 'color' , 'blue' ) ;
36+ var expect = '["city%3Dlondon","city%3Dberlin","color%3Dred","color%3Dblue"]' ;
37+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
38+
39+ s . removeCustomFieldFilter ( 'color' , 'red' ) ;
40+ expect = '["city%3Dlondon","city%3Dberlin","color%3Dblue"]' ;
41+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
42+ } ) ;
43+
44+ it ( 'all cities should be removed from custom field filters' , function ( ) {
45+ s . removeCustomFieldFilter ( 'city' ) ;
46+ var expect = '["color%3Dblue"]' ;
47+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
48+ } ) ;
49+
50+ it ( 'all colors should be removed from custom field filters' , function ( ) {
51+ s . removeCustomFieldFilter ( 'foo' ) ;
52+ var expect = '["color%3Dblue"]' ;
53+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
54+
55+ s . removeCustomFieldFilter ( 'color' ) ;
56+ expect = '[]' ;
57+ assert . equal ( JSON . stringify ( s . getSettings ( ) . customFieldFilters ) , expect ) ;
58+ } ) ;
59+
60+
1561 } ) ;
1662} ) ;
0 commit comments