@@ -33,72 +33,84 @@ describe('get-store-path', () => {
33
33
} ) ;
34
34
} ) ;
35
35
36
- describe ( 'platforms' , ( ) => {
37
- describeIfUnix ( 'unix' , ( ) => {
38
- describe ( 'when CONFIG_DIR is present' , ( ) => {
39
- beforeEach ( ( ) => {
40
- process . env . CONFIG_DIR = '/home/config_dir' ;
41
- } ) ;
36
+ describe ( 'storeDir' , ( ) => {
37
+ describeIfUnix ( 'when provided' , ( ) => {
38
+ it ( 'should respect storeDir' , ( ) => {
39
+ const path = getStorePath ( 'pop' , 'dog' , '/my/store/dir' ) ;
42
40
43
- afterEach ( ( ) => {
44
- delete process . env . CONFIG_DIR ;
45
- } ) ;
41
+ expect ( path ) . toEqual ( '/my/store/dir/pop.dog' ) ;
42
+ } ) ;
43
+ } ) ;
46
44
47
- it ( 'should respect CONFIG_DIR' , ( ) => {
48
- const path = getStorePath ( 'pop' ) ;
45
+ describe ( 'when absent' , ( ) => {
46
+ describe ( 'platforms' , ( ) => {
47
+ describeIfUnix ( 'unix' , ( ) => {
48
+ describe ( 'when CONFIG_DIR is present' , ( ) => {
49
+ beforeEach ( ( ) => {
50
+ process . env . CONFIG_DIR = '/home/config_dir' ;
51
+ } ) ;
49
52
50
- expect ( path ) . toEqual ( '/home/config_dir/pop.haf' ) ;
51
- } ) ;
52
- } ) ;
53
+ afterEach ( ( ) => {
54
+ delete process . env . CONFIG_DIR ;
55
+ } ) ;
53
56
54
- describe ( 'when XDG_CONFIG_HOME is present' , ( ) => {
55
- beforeEach ( ( ) => {
56
- process . env . XDG_CONFIG_HOME = '/home/xdg_config_home' ;
57
- } ) ;
57
+ it ( 'should respect CONFIG_DIR' , ( ) => {
58
+ const path = getStorePath ( 'pop' ) ;
58
59
59
- afterEach ( ( ) => {
60
- delete process . env . XDG_CONFIG_HOME ;
61
- } ) ;
60
+ expect ( path ) . toEqual ( '/home/config_dir/pop.haf' ) ;
61
+ } ) ;
62
+ } ) ;
62
63
63
- it ( 'should respect XDG_CONFIG_HOME' , ( ) => {
64
- const path = getStorePath ( 'pop' ) ;
64
+ describe ( 'when XDG_CONFIG_HOME is present' , ( ) => {
65
+ beforeEach ( ( ) => {
66
+ process . env . XDG_CONFIG_HOME = '/home/xdg_config_home' ;
67
+ } ) ;
65
68
66
- expect ( path ) . toEqual ( '/home/xdg_config_home/pop.haf' ) ;
67
- } ) ;
68
- } ) ;
69
+ afterEach ( ( ) => {
70
+ delete process . env . XDG_CONFIG_HOME ;
71
+ } ) ;
69
72
70
- describe ( 'when fallback ', ( ) => {
71
- const spy = jest . spyOn ( os , 'homedir ') ;
73
+ it ( 'should respect XDG_CONFIG_HOME ', ( ) => {
74
+ const path = getStorePath ( 'pop ') ;
72
75
73
- beforeEach ( ( ) => {
74
- spy . mockReturnValue ( '/Users/pop' ) ;
75
- } ) ;
76
+ expect ( path ) . toEqual ( '/home/xdg_config_home/pop.haf' ) ;
77
+ } ) ;
78
+ } ) ;
76
79
77
- afterEach ( ( ) => {
78
- spy . mockRestore ( ) ;
79
- } ) ;
80
+ describe ( 'when fallback' , ( ) => {
81
+ const spy = jest . spyOn ( os , 'homedir' ) ;
82
+
83
+ beforeEach ( ( ) => {
84
+ spy . mockReturnValue ( '/Users/pop' ) ;
85
+ } ) ;
80
86
81
- it ( 'should put under ~/.config' , ( ) => {
82
- const path = getStorePath ( 'pop' ) ;
87
+ afterEach ( ( ) => {
88
+ spy . mockRestore ( ) ;
89
+ } ) ;
83
90
84
- expect ( path ) . toEqual ( '/Users/pop/.config/pop.haf' ) ;
91
+ it ( 'should put under ~/.config' , ( ) => {
92
+ const path = getStorePath ( 'pop' ) ;
93
+
94
+ expect ( path ) . toEqual ( '/Users/pop/.config/pop.haf' ) ;
95
+ } ) ;
96
+ } ) ;
85
97
} ) ;
86
- } ) ;
87
- } ) ;
88
98
89
- describeIfWindows ( 'when windows 😞' , ( ) => {
90
- beforeEach ( ( ) => {
91
- process . env . LOCALAPPDATA = 'C:\\Users\\Pop\\ApplicationData' ;
92
- } ) ;
99
+ describeIfWindows ( 'when windows 😞' , ( ) => {
100
+ beforeEach ( ( ) => {
101
+ process . env . LOCALAPPDATA = 'C:\\Users\\Pop\\ApplicationData' ;
102
+ } ) ;
93
103
94
- afterEach ( ( ) => {
95
- delete process . env . LOCALAPPDATA ;
96
- } ) ;
104
+ afterEach ( ( ) => {
105
+ delete process . env . LOCALAPPDATA ;
106
+ } ) ;
97
107
98
- it ( 'should deal with WINDOWS' , ( ) => {
99
- const path = getStorePath ( 'pop' ) ;
108
+ it ( 'should deal with WINDOWS' , ( ) => {
109
+ const path = getStorePath ( 'pop' ) ;
100
110
101
- expect ( path ) . toEqual ( 'C:\\Users\\Pop\\ApplicationData\\pop.haf' ) ;
111
+ expect ( path ) . toEqual ( 'C:\\Users\\Pop\\ApplicationData\\pop.haf' ) ;
112
+ } ) ;
113
+ } ) ;
102
114
} ) ;
103
115
} ) ;
104
116
} ) ;
0 commit comments