Skip to content

Commit

Permalink
Replace ava with bron
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jun 6, 2019
1 parent 635b72f commit a6a2ef5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Conventional changelog plugin for release-it",
"main": "index.js",
"scripts": {
"test": "ava test.js --verbose",
"test": "bron test.js",
"release": "release-it"
},
"keywords": [
Expand Down Expand Up @@ -37,7 +37,7 @@
"release-it": "^12.2.1"
},
"devDependencies": {
"ava": "^1.4.1",
"bron": "0.0.1",
"proxyquire": "^2.1.0",
"sinon": "^7.3.1"
},
Expand Down
32 changes: 14 additions & 18 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const test = require('ava');
const test = require('bron');
const assert = require('assert');
const { EOL } = require('os');
const sinon = require('sinon');
const proxyquire = require('proxyquire');
Expand Down Expand Up @@ -31,73 +32,68 @@ const namespace = 'conventional-changelog';
const preset = 'angular';
const infile = 'CHANGES.md';

test.after.always(() => {
try {
fs.unlinkSync(infile);
} catch (err) {}
});

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

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

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

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

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

test(`should write and update infile (${infile})`, async t => {
const options = { [namespace]: { preset, infile } };
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const changelog = fs.readFileSync(infile);
t.is(changelog.toString().trim(), 'The changelog');
assert.strictEqual(changelog.toString().trim(), 'The changelog');
{
await runTasks(plugin);
const changelog = fs.readFileSync(infile);
t.is(changelog.toString().trim(), `The changelog${EOL}${EOL}The changelog`);
assert.strictEqual(changelog.toString().trim(), `The changelog${EOL}${EOL}The changelog`);
}
fs.unlinkSync(infile);
});

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

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

test('should not write infile in dry run', async t => {
Expand All @@ -106,6 +102,6 @@ test('should not write infile in dry run', async t => {
const plugin = factory(Plugin, { namespace, options, global: { isDryRun: true } });
const spy = sinon.spy(plugin, 'writeChangelog');
await runTasks(plugin);
t.is(spy.callCount, 0);
t.throws(() => fs.readFileSync(infile), /no such file/);
assert.strictEqual(spy.callCount, 0);
assert.throws(() => fs.readFileSync(infile), /no such file/);
});

0 comments on commit a6a2ef5

Please sign in to comment.