-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab46b05
commit 29599f1
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const plugin = require('@semantic-release/npm') | ||
|
||
let verified | ||
let result | ||
|
||
async function verifyConditionsHooked(...args) { | ||
if (verified) { | ||
return result | ||
} | ||
|
||
return plugin.verifyConditions(...args).then(r => { | ||
result = r | ||
verified = true | ||
}) | ||
} | ||
|
||
verifyConditionsHooked._reset = () => { | ||
result = undefined | ||
verified = undefined | ||
} | ||
|
||
module.exports = { ...plugin, verifyConditions: verifyConditionsHooked } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const sinon = require('sinon') | ||
const { test } = require('uvu') | ||
const assert = require('uvu/assert') | ||
const plugin = require('../../main/js') | ||
const realNpmPlugin = require('@semantic-release/npm') | ||
|
||
test('prepare, publish, addChannel are re-exported as is', () => { | ||
assert.is(realNpmPlugin.addChannel, plugin.addChannel) | ||
assert.is(realNpmPlugin.publish, plugin.publish) | ||
assert.is(realNpmPlugin.prepare, plugin.prepare) | ||
}) | ||
|
||
test('verifyConditions passes args down to `semrel/npm`', async () => { | ||
const mock = sinon.mock(realNpmPlugin) | ||
mock.expects('verifyConditions').once().withArgs('test').returns(Promise.resolve()) | ||
|
||
await plugin.verifyConditions('test') | ||
|
||
mock.verify() | ||
mock.restore() | ||
plugin.verifyConditions._reset() | ||
}) | ||
|
||
test('prevents multiple `verifyConditions` invocations', async () => { | ||
const mock = sinon.mock(realNpmPlugin) | ||
mock.expects('verifyConditions').once().withArgs('test').returns(Promise.resolve()) | ||
|
||
await plugin.verifyConditions('test') | ||
await plugin.verifyConditions('test') | ||
|
||
mock.verify() | ||
mock.restore() | ||
plugin.verifyConditions._reset() | ||
}) | ||
|
||
test.run() |