@@ -4,6 +4,7 @@ const assert = require('uvu/assert')
4
4
const plugin = require ( '../../main/js' )
5
5
const realNpmPlugin = require ( '@semantic-release/npm' )
6
6
7
+
7
8
test ( 'prepare, publish, addChannel are re-exported as is' , ( ) => {
8
9
assert . is ( realNpmPlugin . addChannel , plugin . addChannel )
9
10
assert . is ( realNpmPlugin . publish , plugin . publish )
@@ -12,24 +13,36 @@ test('prepare, publish, addChannel are re-exported as is', () => {
12
13
13
14
test ( 'verifyConditions passes args down to `semrel/npm`' , async ( ) => {
14
15
const mock = sinon . mock ( realNpmPlugin )
15
- mock . expects ( 'verifyConditions' ) . once ( ) . withArgs ( 'test' ) . returns ( Promise . resolve ( ) )
16
+ const context = { options : { } }
17
+ mock . expects ( 'verifyConditions' ) . once ( ) . withArgs ( 'test' , context ) . returns ( Promise . resolve ( ) )
18
+
19
+ await plugin . verifyConditions ( 'test' , context )
20
+
21
+ mock . verify ( )
22
+ plugin . verifyConditions . _reset ( )
23
+ } )
24
+
25
+ test ( 'verifyConditions replaces context paths `' , async ( ) => {
26
+ const mock = sinon . mock ( realNpmPlugin )
27
+ const context = { options : { publish : { path : '@semrel-extra/npm' } } }
28
+ const _context = { options : { publish : { path : '@semantic-release/npm' } } }
29
+ mock . expects ( 'verifyConditions' ) . once ( ) . withArgs ( 'test' , _context ) . returns ( Promise . resolve ( ) )
16
30
17
- await plugin . verifyConditions ( 'test' )
31
+ await plugin . verifyConditions ( 'test' , context )
18
32
19
33
mock . verify ( )
20
- mock . restore ( )
21
34
plugin . verifyConditions . _reset ( )
22
35
} )
23
36
24
37
test ( 'prevents multiple `verifyConditions` invocations' , async ( ) => {
25
38
const mock = sinon . mock ( realNpmPlugin )
26
- mock . expects ( 'verifyConditions' ) . once ( ) . withArgs ( 'test' ) . returns ( Promise . resolve ( ) )
39
+ const context = { options : { publish : { } } }
40
+ mock . expects ( 'verifyConditions' ) . once ( ) . withArgs ( 'test' , context ) . returns ( Promise . resolve ( ) )
27
41
28
- await plugin . verifyConditions ( 'test' )
29
- await plugin . verifyConditions ( 'test' )
42
+ await plugin . verifyConditions ( 'test' , context )
43
+ await plugin . verifyConditions ( 'test' , context )
30
44
31
45
mock . verify ( )
32
- mock . restore ( )
33
46
plugin . verifyConditions . _reset ( )
34
47
} )
35
48
0 commit comments