Skip to content

Commit

Permalink
Add tagTemplate (temporary) to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 10, 2021
1 parent 5333778 commit 7768648
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ConventionalChangelog extends Plugin {
}

getIncrementedVersionCI(options) {
return this.getIncrementedVersion(options)
return this.getIncrementedVersion(options);
}

async bump(version) {
Expand Down
28 changes: 14 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ const infile = 'CHANGES.md';
const git = { tagName: '${version}' };

test('should not throw', async t => {
const options = { [namespace]: { preset }, git };
const options = { [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await assert.doesNotReject(runTasks(plugin));
});

test('should set changelog', async t => {
const options = { [namespace]: { preset }, git };
const options = { [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const { changelog } = plugin.config.getContext();
assert.strictEqual(changelog, 'The changelog');
});

test('should use recommended bump', async t => {
const options = { [namespace]: { preset }, git };
const options = { [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const { version } = plugin.config.getContext();
assert.strictEqual(version, '1.1.0');
});

test('should ignore recommended bump (option)', async t => {
const options = { [namespace]: { preset, ignoreRecommendedBump: true }, git };
const options = { [namespace]: { preset, ignoreRecommendedBump: true }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
const spy = sinon.spy(plugin, 'generateChangelog');
await runTasks(plugin);
Expand All @@ -66,15 +66,15 @@ test('should ignore recommended bump (option)', async t => {
});

test('should ignore recommended bump (prelease)', async t => {
const options = { preRelease: 'alpha', [namespace]: { preset }, git };
const options = { preRelease: 'alpha', [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const { version } = plugin.config.getContext();
assert.strictEqual(version, '1.0.1-alpha.0');
});

test('should ignore recommended bump (prelease continuation)', async t => {
const options = { preRelease: 'alpha', [namespace]: { preset }, git };
const options = { preRelease: 'alpha', [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
const stub = sinon.stub(plugin, 'getLatestVersion').returns('1.0.1-alpha.0');
await runTasks(plugin);
Expand All @@ -84,7 +84,7 @@ test('should ignore recommended bump (prelease continuation)', async t => {
});

test('should ignore recommended bump (next prelease)', async t => {
const options = { preRelease: 'beta', [namespace]: { preset }, git };
const options = { preRelease: 'beta', [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
const stub = sinon.stub(plugin, 'getLatestVersion').returns('1.0.1-alpha.1');
await runTasks(plugin);
Expand All @@ -94,7 +94,7 @@ test('should ignore recommended bump (next prelease)', async t => {
});

test('should use recommended bump (from prelease)', async t => {
const options = { [namespace]: { preset }, git };
const options = { [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
const stub = sinon.stub(plugin, 'getLatestVersion').returns('1.0.1-beta.0');
await runTasks(plugin);
Expand All @@ -104,23 +104,23 @@ test('should use recommended bump (from prelease)', async t => {
});

test('should use provided increment', async t => {
const options = { increment: 'major', [namespace]: { preset }, git };
const options = { increment: 'major', [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const { version } = plugin.config.getContext();
assert.strictEqual(version, '2.0.0');
});

test('should use provided version', async t => {
const options = { increment: '1.2.3', [namespace]: { preset }, git };
const options = { increment: '1.2.3', [namespace]: { preset }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const { version } = plugin.config.getContext();
assert.strictEqual(version, '1.2.3');
});

test(`should write and update infile (${infile})`, async t => {
const options = { [namespace]: { preset, infile }, git };
const options = { [namespace]: { preset, infile }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const changelog = fs.readFileSync(infile);
Expand All @@ -134,20 +134,20 @@ test(`should write and update infile (${infile})`, async t => {
});

test('should reject if conventional bump passes error', async t => {
const options = { [namespace]: { preset: 'what?' }, git };
const options = { [namespace]: { preset: 'what?' }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await assert.rejects(runTasks(plugin), /Something went wrong/);
});

test('should reject if conventional changelog has error', async t => {
const options = { [namespace]: { preset, releaseCount: -1 }, git };
const options = { [namespace]: { preset, releaseCount: -1 }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
await assert.rejects(runTasks(plugin), /Something went wrong/);
});

test('should not write infile in dry run', async t => {
const infile = 'DRYRUN.md';
const options = { 'dry-run': true, [namespace]: { preset, infile }, git };
const options = { 'dry-run': true, [namespace]: { preset, infile }, git, tagTemplate: '${version}' };
const plugin = factory(Plugin, { namespace, options });
const spy = sinon.spy(plugin, 'writeChangelog');
await runTasks(plugin);
Expand Down

0 comments on commit 7768648

Please sign in to comment.