@@ -84,6 +84,26 @@ describe('mocha-runner/mocha-adapter', () => {
84
84
85
85
afterEach ( ( ) => sandbox . restore ( ) ) ;
86
86
87
+ describe ( 'init' , ( ) => {
88
+ it ( 'should add an empty hermione object to global' , ( ) => {
89
+ MochaAdapter . init ( ) ;
90
+
91
+ assert . deepEqual ( global . hermione , { } ) ;
92
+
93
+ delete global . hermione ;
94
+ } ) ;
95
+ } ) ;
96
+
97
+ describe ( 'clean' , ( ) => {
98
+ it ( 'should delete hermione from global' , ( ) => {
99
+ global . hermione = 'some-global-value' ;
100
+
101
+ MochaAdapter . clean ( ) ;
102
+
103
+ assert . isUndefined ( global . hermione ) ;
104
+ } ) ;
105
+ } ) ;
106
+
87
107
describe ( 'constructor' , ( ) => {
88
108
it ( 'should pass shared opts to mocha instance' , ( ) => {
89
109
mkMochaAdapter_ ( { grep : 'foo' } ) ;
@@ -138,54 +158,27 @@ describe('mocha-runner/mocha-adapter', () => {
138
158
assert . deepEqual ( mocha . files , [ ] ) ;
139
159
} ) ;
140
160
141
- it ( 'should add global "hermione" object on "pre-require" event' , ( ) => {
142
- const mochaAdapter = mkMochaAdapter_ ( ) ;
143
-
144
- mochaAdapter . addFiles ( [ 'path/to/file' ] ) ;
145
- MochaStub . prototype . suite . emit ( 'pre-require' ) ;
146
-
147
- assert . isDefined ( global . hermione ) ;
148
- } ) ;
149
-
150
161
describe ( 'hermione global' , ( ) => {
151
- afterEach ( ( ) => delete global . hermione ) ;
162
+ beforeEach ( ( ) => MochaAdapter . init ( ) ) ;
163
+ afterEach ( ( ) => MochaAdapter . clean ( ) ) ;
152
164
153
165
it ( 'hermione.skip should return SkipBuilder instance' , ( ) => {
154
- const mochaAdapter = mkMochaAdapter_ ( ) ;
155
-
156
- mochaAdapter . addFiles ( [ 'path/to/file' ] ) ;
157
- MochaStub . prototype . suite . emit ( 'pre-require' ) ;
166
+ mkMochaAdapter_ ( ) ;
158
167
159
168
assert . instanceOf ( global . hermione . skip , SkipBuilder ) ;
160
169
} ) ;
161
170
162
171
it ( 'hermione.only should return OnlyBuilder instance' , ( ) => {
163
- const mochaAdapter = mkMochaAdapter_ ( ) ;
164
-
165
- mochaAdapter . addFiles ( [ 'path/to/file' ] ) ;
166
- MochaStub . prototype . suite . emit ( 'pre-require' ) ;
172
+ mkMochaAdapter_ ( ) ;
167
173
168
174
assert . instanceOf ( global . hermione . only , OnlyBuilder ) ;
169
175
} ) ;
170
176
171
177
it ( 'hermione.ctx should return passed ctx' , ( ) => {
172
- const mochaAdapter = mkMochaAdapter_ ( { } , { some : 'ctx' } ) ;
173
-
174
- mochaAdapter . addFiles ( [ 'path/to/file.js' ] ) ;
175
- MochaStub . prototype . suite . emit ( 'pre-require' ) ;
178
+ mkMochaAdapter_ ( { } , { some : 'ctx' } ) ;
176
179
177
180
assert . deepEqual ( global . hermione . ctx , { some : 'ctx' } ) ;
178
181
} ) ;
179
-
180
- it ( 'should remove global "hermione" object on "post-require" event' , ( ) => {
181
- const mochaAdapter = mkMochaAdapter_ ( ) ;
182
-
183
- mochaAdapter . addFiles ( [ 'path/to/file' ] ) ;
184
- MochaStub . prototype . suite . emit ( 'pre-require' ) ;
185
- MochaStub . prototype . suite . emit ( 'post-require' ) ;
186
-
187
- assert . isUndefined ( global . hermione ) ;
188
- } ) ;
189
182
} ) ;
190
183
} ) ;
191
184
0 commit comments