@@ -2,40 +2,109 @@ var path = require('path');
2
2
var settings = require ( '../src/settings.js' ) ;
3
3
4
4
describe ( 'settings' , function ( ) {
5
+ describe ( 'without config but state' , function ( ) {
6
+ before ( function ( ) {
7
+ var fakeApp = path . join ( __dirname , '.' ) ;
8
+ var fakeUserData = path . join ( __dirname , './fake-userdata' ) ;
9
+ settings . load ( fakeApp , fakeUserData ) ;
10
+ } ) ;
5
11
6
- before ( function ( ) {
7
- var fakeHomeDir = path . join ( __dirname , './fake-home-dir' ) ;
8
- settings . load ( fakeHomeDir ) ;
9
- } ) ;
12
+ it ( 'reads command-line args' , function ( ) {
13
+ //this arg is passed into the specs by mocha
14
+ expect ( settings . get ( 'reporter' ) ) . to . eql ( 'spec' ) ;
15
+ } ) ;
10
16
11
- it ( 'reads command-line args' , function ( ) {
12
- //this arg is passed into the specs by mocha
13
- expect ( settings . get ( 'reporter' ) ) . to . eql ( 'spec' ) ;
14
- } ) ;
17
+ it ( 'reads array types' , function ( ) {
18
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 2 ) ;
19
+ } ) ;
15
20
16
- it ( 'reads array types ' , function ( ) {
17
- expect ( settings . get ( 'teams ' ) ) . to . have . length ( 2 ) ;
18
- } ) ;
21
+ it ( 'reads nested objects ' , function ( ) {
22
+ expect ( settings . get ( 'window:width ' ) ) . to . eql ( 800 ) ;
23
+ } ) ;
19
24
20
- it ( 'reads nested objects' , function ( ) {
21
- expect ( settings . get ( 'window:width' ) ) . to . eql ( 800 ) ;
22
- } ) ;
25
+ it ( 'sets config values' , function ( ) {
26
+ settings . set ( 'window:width' , 1920 ) ;
27
+ expect ( settings . get ( 'window:width' ) ) . to . eql ( 1920 ) ;
28
+ } ) ;
23
29
24
- it ( 'sets config values' , function ( ) {
25
- settings . set ( 'window:width' , 1920 ) ;
26
- expect ( settings . get ( 'window:width' ) ) . to . eql ( 1920 ) ;
27
- } ) ;
30
+ it ( 'has default values' , function ( ) {
31
+ expect ( settings . get ( 'window:height' ) ) . to . eql ( 600 ) ;
32
+ } ) ;
28
33
29
- it ( 'has default values' , function ( ) {
30
- expect ( settings . get ( 'window:height' ) ) . to . eql ( 600 ) ;
34
+ it ( 'appends config values' , function ( ) {
35
+ settings . append ( 'teams' , 'http://localhost/team3' ) ;
36
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 3 ) ;
37
+ } ) ;
31
38
} ) ;
32
39
33
- it ( 'appends config values' , function ( ) {
34
- settings . append ( 'teams' , 'http://localhost/team3' ) ;
35
- expect ( settings . get ( 'teams' ) ) . to . have . length ( 3 ) ;
40
+ describe ( 'with config but no state' , function ( ) {
41
+ before ( function ( ) {
42
+ var fakeApp = path . join ( __dirname , './fake-app' ) ;
43
+ var fakeUserData = path . join ( __dirname , './' ) ;
44
+ settings . load ( fakeApp , fakeUserData ) ;
45
+ } ) ;
46
+
47
+ it ( 'reads command-line args' , function ( ) {
48
+ //this arg is passed into the specs by mocha
49
+ expect ( settings . get ( 'reporter' ) ) . to . eql ( 'spec' ) ;
50
+ } ) ;
51
+
52
+ it ( 'reads array types' , function ( ) {
53
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 2 ) ;
54
+ } ) ;
55
+
56
+ it ( 'reads nested objects' , function ( ) {
57
+ expect ( settings . get ( 'window:height' ) ) . to . eql ( 1024 ) ;
58
+ } ) ;
59
+
60
+ it ( 'sets config values' , function ( ) {
61
+ settings . set ( 'window:height' , 1920 ) ;
62
+ expect ( settings . get ( 'window:height' ) ) . to . eql ( 1920 ) ;
63
+ } ) ;
64
+
65
+ it ( 'has default values' , function ( ) {
66
+ expect ( settings . get ( 'window:width' ) ) . to . eql ( 1024 ) ;
67
+ } ) ;
68
+
69
+ it ( 'appends config values' , function ( ) {
70
+ settings . append ( 'teams' , 'http://localhost/team3' ) ;
71
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 3 ) ;
72
+ } ) ;
36
73
} ) ;
37
74
38
- it ( 'reads non-state settings from `config.json`' , function ( ) {
39
- expect ( settings . get ( 'chrome-args' ) ) . to . have . property ( "some-arg-name" , "some-arg-value" ) ;
75
+ describe ( 'with config and state' , function ( ) {
76
+ before ( function ( ) {
77
+ var fakeApp = path . join ( __dirname , './fake-app' ) ;
78
+ var fakeUserData = path . join ( __dirname , './fake-userdata' ) ;
79
+ settings . load ( fakeApp , fakeUserData ) ;
80
+ } ) ;
81
+
82
+ it ( 'reads command-line args' , function ( ) {
83
+ //this arg is passed into the specs by mocha
84
+ expect ( settings . get ( 'reporter' ) ) . to . eql ( 'spec' ) ;
85
+ } ) ;
86
+
87
+ it ( 'reads array types' , function ( ) {
88
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 2 ) ;
89
+ } ) ;
90
+
91
+ it ( 'reads nested objects' , function ( ) {
92
+ expect ( settings . get ( 'window:width' ) ) . to . eql ( 800 ) ;
93
+ expect ( settings . get ( 'window:height' ) ) . to . eql ( 1024 ) ;
94
+ } ) ;
95
+
96
+ it ( 'sets config values' , function ( ) {
97
+ settings . set ( 'window:width' , 1920 ) ;
98
+ expect ( settings . get ( 'window:width' ) ) . to . eql ( 1920 ) ;
99
+ } ) ;
100
+
101
+ it ( 'appends config values' , function ( ) {
102
+ settings . append ( 'teams' , 'http://localhost/team3' ) ;
103
+ expect ( settings . get ( 'teams' ) ) . to . have . length ( 3 ) ;
104
+ } ) ;
105
+
106
+ it ( 'reads non-state settings from `config.json`' , function ( ) {
107
+ expect ( settings . get ( 'chrome-args' ) ) . to . have . property ( "some-arg-name" , "some-arg-value" ) ;
108
+ } ) ;
40
109
} ) ;
41
110
} ) ;
0 commit comments