Skip to content

Commit

Permalink
chore: added some sinon assertions (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jp-Rivera authored and kumar303 committed Jul 11, 2017
1 parent d1f9551 commit 3d98456
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
6 changes: 2 additions & 4 deletions tests/unit/test-cmd/test.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ describe('build', () => {
};
return build(params, {packageCreator, createFileFilter}).then(() => {
// ensure sourceDir, artifactsDir, ignoreFiles is used
assert.ok(createFileFilter.called);
assert.deepEqual(createFileFilter.firstCall.args[0], params);
sinon.assert.calledWithMatch(createFileFilter, params);
// ensure packageCreator received correct fileFilter
assert.ok(packageCreator.called);
assert.equal(packageCreator.firstCall.args[0].fileFilter, fileFilter);
sinon.assert.calledWithMatch(packageCreator, {fileFilter});
});
});

Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test-cmd/test.docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ describe('docs', () => {
it('passes the correct url to docs', () => {
const openUrl = sinon.spy((urlToOpen, callback) => callback(null));
return defaultDocsCommand({}, {openUrl}).then(() => {
assert.ok(openUrl.called);
assert.equal(openUrl.firstCall.args[0], url);
sinon.assert.calledWith(openUrl, url);
});
});

Expand Down
13 changes: 6 additions & 7 deletions tests/unit/test-cmd/test.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ describe('run', () => {
const cmd = prepareRun();
const FirefoxDesktopExtensionRunner = sinon.spy(FakeExtensionRunner);
await cmd.run({firefox}, {FirefoxDesktopExtensionRunner});
assert.equal(FirefoxDesktopExtensionRunner.called, true);
assert.equal(FirefoxDesktopExtensionRunner.firstCall.args[0].firefoxBinary,
firefox);
sinon.assert.calledWithMatch(
FirefoxDesktopExtensionRunner, {firefoxBinary: firefox}
);
});

it('passes startUrl parameter to Firefox when specified', async () => {
Expand All @@ -76,10 +76,9 @@ describe('run', () => {

await cmd.run({startUrl: expectedStartUrls},
{FirefoxDesktopExtensionRunner});

assert.ok(FirefoxDesktopExtensionRunner.called);
assert.deepEqual(FirefoxDesktopExtensionRunner.firstCall.args[0].startUrl,
expectedStartUrls);
sinon.assert.calledWithMatch(
FirefoxDesktopExtensionRunner, {startUrl: expectedStartUrls}
);
});

it('passes the expected parameters to the extension runner', async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test-extension-runners/test.firefox-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ describe('util/extension-runners/firefox-desktop', () => {
await runnerInstance.run();

assert.ok(runnerInstance.getName(), 'Firefox Desktop');
assert.ok(remoteFirefox.installTemporaryAddon.calledOnce);
assert.equal(remoteFirefox.installTemporaryAddon.firstCall.args[0],
params.extensions[0].sourceDir);
sinon.assert.calledOnce(remoteFirefox.installTemporaryAddon);
sinon.assert.calledWithMatch(remoteFirefox.installTemporaryAddon,
params.extensions[0].sourceDir);

sinon.assert.calledOnce(params.firefoxApp.createProfile);
sinon.assert.calledWith(params.firefoxApp.createProfile,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test.program.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ describe('program.Program', () => {
shouldExitProgram: true,
})
.then(() => {
assert.equal(fakeProcess.exit.called, true);
assert.equal(fakeProcess.exit.firstCall.args[0], 1);
sinon.assert.calledOnce(fakeProcess.exit);
sinon.assert.calledWith(fakeProcess.exit, 1);
});
});

Expand Down

0 comments on commit 3d98456

Please sign in to comment.