Skip to content

Commit

Permalink
chore: add tests for release specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 25, 2022
1 parent 9bdad61 commit ebed330
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions test/apply/release-config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
const t = require('tap')
const { existsSync } = require('fs')
const setup = require('../setup.js')

t.test('no plugin for root only', async (t) => {
const s = await setup(t)
await s.apply()
t.test('root only', async (t) => {
const prvt = { private: true }
const cases = [
[{}, { plugins: false, pr: true }],
[{ workspaces: { a: 'a' } }, { plugins: true, pr: true }],
[{ workspaces: { a: prvt } }, { plugins: false, pr: true }],
[{ package: prvt }, { plugins: false, pr: false }],
[{ package: prvt, workspaces: { a: 'a' } }, { plugins: true, pr: true }],
[{ package: prvt, workspaces: { a: prvt } }, { plugins: false, pr: false }],
]

const releaseConfig = await s.readJson('release-please-config.json')
t.equal(releaseConfig.plugins, undefined)
})

t.test('has plugin for workspace', async (t) => {
const s = await setup(t, {
workspaces: {
a: 'a',
},
})
await s.apply()

const releaseConfig = await s.readJson('release-please-config.json')
t.strictSame(releaseConfig.plugins, ['node-workspace'])
})
for (const [config, expected] of cases) {
await t.test(JSON.stringify(config), async t => {
const s = await setup(t, config)
await s.apply()

t.test('no plugin for private workspace', async (t) => {
const s = await setup(t, {
workspaces: {
a: {
private: true,
},
},
})
await s.apply()
const releaseConfig = await s.readJson('release-please-config.json').catch(() => ({}))
const pr = existsSync(s.join('.github', 'workflows', 'pull-request.yml'))

const releaseConfig = await s.readJson('release-please-config.json')
t.equal(releaseConfig.plugins, undefined)
t.strictSame(releaseConfig.plugins, expected.plugins ? ['node-workspace'] : undefined)
t.equal(pr, expected.pr)
})
}
})

0 comments on commit ebed330

Please sign in to comment.