1
1
'use strict' ;
2
2
3
3
const { validateLegacyPlugin, list} = require ( '../../../lib/cli/run-helpers' ) ;
4
+ const Mocha = require ( '../../../lib/mocha' ) ;
4
5
5
6
describe ( 'helpers' , function ( ) {
6
7
describe ( 'validateLegacyPlugin()' , function ( ) {
@@ -25,24 +26,19 @@ describe('helpers', function() {
25
26
} ) ;
26
27
} ) ;
27
28
28
- describe ( 'when used with an "interfaces " key' , function ( ) {
29
+ describe ( 'when used with an "ui " key' , function ( ) {
29
30
it ( 'should disallow an array of names' , function ( ) {
30
- expect (
31
- ( ) => validateLegacyPlugin ( { interface : [ 'bar' ] } , 'interface' ) ,
32
- 'to throw' ,
33
- {
34
- code : 'ERR_MOCHA_INVALID_INTERFACE' ,
35
- message : / c a n o n l y b e s p e c i f i e d o n c e / i
36
- }
37
- ) ;
31
+ expect ( ( ) => validateLegacyPlugin ( { ui : [ 'bar' ] } , 'ui' ) , 'to throw' , {
32
+ code : 'ERR_MOCHA_INVALID_INTERFACE' ,
33
+ message : / c a n o n l y b e s p e c i f i e d o n c e / i
34
+ } ) ;
38
35
} ) ;
39
36
40
37
it ( 'should fail to recognize an unknown interface' , function ( ) {
41
- expect (
42
- ( ) => validateLegacyPlugin ( { interface : 'bar' } , 'interface' ) ,
43
- 'to throw' ,
44
- { code : 'ERR_MOCHA_INVALID_INTERFACE' , message : / c a n n o t f i n d m o d u l e / i}
45
- ) ;
38
+ expect ( ( ) => validateLegacyPlugin ( { ui : 'bar' } , 'ui' ) , 'to throw' , {
39
+ code : 'ERR_MOCHA_INVALID_INTERFACE' ,
40
+ message : / c a n n o t f i n d m o d u l e / i
41
+ } ) ;
46
42
} ) ;
47
43
} ) ;
48
44
@@ -56,6 +52,17 @@ describe('helpers', function() {
56
52
} ) ;
57
53
} ) ;
58
54
55
+ describe ( 'when used with a third-party interface' , function ( ) {
56
+ it ( 'should add the interface to "Mocha.interfaces"' , function ( ) {
57
+ // let's suppose that `glob` is an interface
58
+ const opts = { ui : 'glob' } ;
59
+ validateLegacyPlugin ( opts , 'ui' , Mocha . interfaces ) ;
60
+ expect ( opts . ui , 'to equal' , 'glob' ) ;
61
+ expect ( Mocha . interfaces , 'to satisfy' , { glob : require ( 'glob' ) } ) ;
62
+ delete Mocha . interfaces . glob ;
63
+ } ) ;
64
+ } ) ;
65
+
59
66
describe ( 'when a plugin throws an exception upon load' , function ( ) {
60
67
it ( 'should fail and report the original error' , function ( ) {
61
68
expect (
0 commit comments