From 9dcefc0beefc99ce8e800d827bd3f8e045a68d77 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 14 Feb 2018 09:19:59 +0100 Subject: [PATCH 1/6] :new: Change testing suite to follow standards --- package.json | 7 +++-- test/setup.js | 48 ++++++++++++++++++++--------- test/steps/api/3_then.js | 8 ++--- test/steps/childProcesses/3_then.js | 2 +- test/steps/config/3_then.js | 2 +- test/steps/crypto/3_then.js | 26 ++++++++-------- test/steps/files/3_then.js | 4 +-- test/steps/general/3_then.js | 22 ++++++------- test/steps/inputs/3_then.js | 44 +++++++++++++------------- test/steps/printing/3_then.js | 2 +- test/steps/queries/3_then.js | 8 ++--- test/steps/transactions/3_then.js | 2 +- test/steps/vorpal/3_then.js | 2 +- 13 files changed, 99 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index 0cd5a2ff..f50f8539 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,8 @@ "babel-plugin-istanbul": "=4.1.5", "babel-preset-env": "=1.6.1", "babel-register": "=6.26.0", + "chai": "=4.1.2", + "chai-as-promised": "=7.1.1", "coveralls": "=3.0.0", "eslint": "=4.11.0", "eslint-config-airbnb-base": "=12.1.0", @@ -78,8 +80,7 @@ "mocha-bdd": "=0.1.2", "nyc": "=11.3.0", "prettier": "=1.9.2", - "should": "=13.1.3", - "should-sinon": "=0.0.6", - "sinon": "=4.1.2" + "sinon": "=4.1.2", + "sinon-chai": "=2.14.0" } } diff --git a/test/setup.js b/test/setup.js index 29422c9a..e112c823 100644 --- a/test/setup.js +++ b/test/setup.js @@ -15,29 +15,49 @@ */ import os from 'os'; import 'babel-polyfill'; -import should from 'should'; +import chai, { Assertion } from 'chai'; +import 'chai/register-should'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import sinon from 'sinon'; -import 'should-sinon'; import mochaBDD from 'mocha-bdd'; process.env.NODE_ENV = 'test'; process.env.LISKY_CONFIG_DIR = process.env.LISKY_CONFIG_DIR || `${os.homedir()}/.lisky`; -should.use((_, Assertion) => { - // istanbul ignore next - Assertion.add('hexString', function hexString() { - this.params = { - operator: 'to be hex string', - }; - Buffer.from(this.obj, 'hex') - .toString('hex') - .should.equal(this.obj); - }); +/* eslint-disable no-underscore-dangle */ +Assertion.addProperty('hexString', function handleAssert() { + const actual = this._obj; + + new Assertion(actual).to.be.a('string'); + + const expected = Buffer.from(actual, 'hex').toString('hex'); + this.assert( + expected === actual, + 'expected #{this} to be a hexString', + 'expected #{this} not to be a hexString', + ); +}); + +Assertion.addProperty('integer', function handleAssert() { + const actual = this._obj; + + new Assertion(actual).to.be.a('number'); + + const expected = parseInt(actual, 10); + this.assert( + actual === expected, + 'expected #{this} to be an integer', + 'expected #{this} not to be an integer', + ); }); +/* eslint-enable no-underscore-dangle */ mochaBDD(); -// See https://github.com/shouldjs/should.js/issues/41 -Object.defineProperty(global, 'should', { value: should }); + +[sinonChai, chaiAsPromised].forEach(plugin => chai.use(plugin)); + +global.should = chai.should(); global.sinon = sinon; global.sandbox = sinon.sandbox.create(); diff --git a/test/steps/api/3_then.js b/test/steps/api/3_then.js index 07900bd4..dc604d54 100644 --- a/test/steps/api/3_then.js +++ b/test/steps/api/3_then.js @@ -18,7 +18,7 @@ import { getFirstBoolean } from '../utils'; export function itShouldNotSetTheLiskAPIInstanceTestnetSetting() { const { liskAPIInstance } = this.test.ctx; - return liskAPIInstance.setTestnet.should.not.be.called(); + return liskAPIInstance.setTestnet.should.not.be.called; } export function itShouldSetTheLiskAPIInstanceTestnetSettingTo() { @@ -42,7 +42,7 @@ export function itShouldUseTheLiskAPIInstanceToSendARequestToTheEndpointUsingThe export function itShouldNotBroadcastTheSignature() { const { liskAPIInstance } = this.test.ctx; - return liskAPIInstance.broadcastSignatures.should.not.be.called(); + return liskAPIInstance.broadcastSignatures.should.not.be.called; } export function itShouldBroadcastTheSignature() { @@ -54,7 +54,7 @@ export function itShouldBroadcastTheSignature() { export function itShouldNotBroadcastTheTransaction() { const { liskAPIInstance } = this.test.ctx; - return liskAPIInstance.broadcastTransaction.should.not.be.called(); + return liskAPIInstance.broadcastTransaction.should.not.be.called; } export function itShouldBroadcastTheTransaction() { @@ -66,7 +66,7 @@ export function itShouldBroadcastTheTransaction() { export function itShouldResolveToTheAPIResponse() { const { returnValue, apiResponse } = this.test.ctx; - return returnValue.should.be.fulfilledWith(apiResponse); + return returnValue.should.be.eventually.eql(apiResponse); } export function theLiskAPIInstanceShouldBeALiskJSAPIInstance() { diff --git a/test/steps/childProcesses/3_then.js b/test/steps/childProcesses/3_then.js index 036f2f4c..942ec067 100644 --- a/test/steps/childProcesses/3_then.js +++ b/test/steps/childProcesses/3_then.js @@ -32,7 +32,7 @@ export function itShouldExecuteAScriptExecutingThirdInASeparateChildProcess() { } export function itShouldNotExecuteAThirdScriptInASeparateChildProcess() { - return childProcess.exec.should.not.be.calledThrice(); + return childProcess.exec.should.not.be.calledThrice; } export function theLiskyInstanceShouldLogTheFirstChildProcessOutputFirst() { diff --git a/test/steps/config/3_then.js b/test/steps/config/3_then.js index 1dcdd10d..ce46a5b7 100644 --- a/test/steps/config/3_then.js +++ b/test/steps/config/3_then.js @@ -42,7 +42,7 @@ export function itShouldUpdateTheConfigVariableToBoolean() { export function itShouldResolveToTheConfig() { const { returnValue, config } = this.test.ctx; - return returnValue.should.be.fulfilledWith(config); + return returnValue.should.be.eventually.eql(config); } export function theDefaultConfigShouldBeExported() { diff --git a/test/steps/crypto/3_then.js b/test/steps/crypto/3_then.js index 7ac1c4d7..8d3bf2d8 100644 --- a/test/steps/crypto/3_then.js +++ b/test/steps/crypto/3_then.js @@ -27,12 +27,12 @@ export function itShouldSignTheMessageWithThePassphrase() { export function itShouldResolveToTheResultOfSigningTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(cryptoResult); + return returnValue.should.be.eventually.eql(cryptoResult); } export function itShouldResolveToTheResultOfDecryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(cryptoResult); + return returnValue.should.be.eventually.eql(cryptoResult); } export function itShouldDecryptThePassphraseUsingTheIVAndThePassword() { @@ -46,7 +46,7 @@ export function itShouldDecryptThePassphraseUsingTheIVAndThePassword() { export function itShouldResolveToTheResultOfEncryptingThePassphraseCombinedWithThePublicKey() { const { returnValue, cryptoResult, publicKey } = this.test.ctx; - return returnValue.should.be.fulfilledWith( + return returnValue.should.be.eventually.eql( Object.assign({}, cryptoResult, { publicKey }), ); } @@ -61,7 +61,7 @@ export function itShouldEncryptThePassphraseUsingThePassword() { export function itShouldResolveToTheResultOfEncryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(cryptoResult); + return returnValue.should.be.eventually.eql(cryptoResult); } export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderPublicKey() { @@ -76,7 +76,7 @@ export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderP export function itShouldResolveToTheResultOfDecryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(cryptoResult); + return returnValue.should.be.eventually.eql(cryptoResult); } export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { @@ -90,7 +90,7 @@ export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { export function itShouldResolveToTheResultOfEncryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(cryptoResult); + return returnValue.should.be.eventually.eql(cryptoResult); } export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheAddress() { @@ -105,7 +105,7 @@ export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheA publicKey, address, }; - return returnValue.should.be.fulfilledWith(expectedObject); + return returnValue.should.be.eventually.eql(expectedObject); } export function theSignatureShouldBeReturned() { @@ -215,12 +215,12 @@ export function theDecryptedMessageShouldBeReturned() { export function itShouldResolveToThePassphrase() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.fulfilledWith(passphrase); + return returnValue.should.be.eventually.eql(passphrase); } export function itShouldReturnAnObjectWithThePassphrase() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ + return returnValue.should.be.eventually.eql({ passphrase, secondPassphrase: null, password: null, @@ -230,7 +230,7 @@ export function itShouldReturnAnObjectWithThePassphrase() { export function itShouldReturnAnObjectWithTheSecondPassphrase() { const { returnValue, secondPassphrase } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ + return returnValue.should.be.eventually.eql({ passphrase: null, secondPassphrase, password: null, @@ -240,7 +240,7 @@ export function itShouldReturnAnObjectWithTheSecondPassphrase() { export function itShouldReturnAnObjectWithThePassword() { const { returnValue, password } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ + return returnValue.should.be.eventually.eql({ passphrase: null, secondPassphrase: null, password, @@ -250,7 +250,7 @@ export function itShouldReturnAnObjectWithThePassword() { export function itShouldReturnAnObjectWithTheData() { const { returnValue, data } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ + return returnValue.should.be.eventually.eql({ passphrase: null, secondPassphrase: null, password: null, @@ -266,7 +266,7 @@ export function itShouldReturnAnObjectWithThePassphraseTheSecondPassphraseThePas password, data, } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ + return returnValue.should.be.eventually.eql({ passphrase, secondPassphrase, password, diff --git a/test/steps/files/3_then.js b/test/steps/files/3_then.js index 26d4ed72..6fea5b94 100644 --- a/test/steps/files/3_then.js +++ b/test/steps/files/3_then.js @@ -64,10 +64,10 @@ export function theDefaultConfigShouldBeWrittenToTheConfigFile() { } export function theConfigFileShouldNotBeWritten() { - return fsUtils.writeJSONSync.should.not.be.called(); + return fsUtils.writeJSONSync.should.not.be.called; } export function itShouldResolveToTheFirstLineOfTheFile() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.fulfilledWith(passphrase); + return returnValue.should.be.eventually.eql(passphrase); } diff --git a/test/steps/general/3_then.js b/test/steps/general/3_then.js index a9b84679..b84d621c 100644 --- a/test/steps/general/3_then.js +++ b/test/steps/general/3_then.js @@ -35,13 +35,13 @@ export function itShouldReturnTheResult() { export function itShouldThrowValidationError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return testFunction.should.throw(new ValidationError(message)); + return testFunction.should.throw(ValidationError, message); } export function itShouldThrowFileSystemError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return testFunction.should.throw(new FileSystemError(message)); + return testFunction.should.throw(FileSystemError, message); } export function itShouldExitWithCode() { @@ -52,7 +52,7 @@ export function itShouldExitWithCode() { export function itShouldResolveToTheErrorObject() { const { returnValue, errorObject } = this.test.ctx; - return returnValue.should.be.fulfilledWith(errorObject); + return returnValue.should.be.eventually.eql(errorObject); } export async function itShouldResolveToAnObjectWithMessage() { @@ -104,22 +104,22 @@ export function itShouldRejectWithTheOriginalRejection() { export function itShouldReturnAnEmptyObject() { const { returnValue } = this.test.ctx; - return returnValue.should.be.fulfilledWith({}); + return returnValue.should.be.eventually.eql({}); } export function itShouldReturnTrue() { const { returnValue } = this.test.ctx; - return returnValue.should.be.true(); + return returnValue.should.be.true; } export function itShouldReturnFalse() { const { returnValue } = this.test.ctx; - return returnValue.should.be.false(); + return returnValue.should.be.false; } export function itShouldReturnNull() { const { returnValue } = this.test.ctx; - return should(returnValue).be.null(); + return should(returnValue).be.null; } export function itShouldReturnString() { @@ -131,12 +131,12 @@ export function itShouldReturnString() { export function itShouldResolveToTheOptions() { const { options, returnValue } = this.test.ctx; - return returnValue.should.be.fulfilledWith(options); + return returnValue.should.be.eventually.eql(options); } export function itShouldResolveToTheDataAsAString() { const { returnValue, data } = this.test.ctx; - return returnValue.should.be.fulfilledWith(data); + return returnValue.should.be.eventually.eql(data); } export function itShouldReturnAnObjectWithError() { @@ -149,10 +149,10 @@ export function itShouldReturnAnObjectWithError() { export function itShouldResolveToTheWarrantyInformation() { const { returnValue, warranty } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ warranty }); + return returnValue.should.be.eventually.eql({ warranty }); } export function itShouldResolveToTheCopyrightInformation() { const { returnValue, copyright } = this.test.ctx; - return returnValue.should.be.fulfilledWith({ copyright }); + return returnValue.should.be.eventually.eql({ copyright }); } diff --git a/test/steps/inputs/3_then.js b/test/steps/inputs/3_then.js index 8d325098..fcaa6505 100644 --- a/test/steps/inputs/3_then.js +++ b/test/steps/inputs/3_then.js @@ -28,11 +28,11 @@ export async function itShouldGetTheDataUsingTheVotesSource() { } export async function itShouldNotGetTheDataUsingTheUnvotesSource() { - return inputUtils.getData.should.not.be.called(); + return inputUtils.getData.should.not.be.called; } export async function itShouldNotGetTheDataUsingTheVotesSource() { - return inputUtils.getData.should.not.be.called(); + return inputUtils.getData.should.not.be.called; } export async function itShouldResolveWithThePassphrase() { @@ -44,7 +44,7 @@ export async function itShouldResolveWithThePassphrase() { export async function itShouldResolveWithoutThePassphrase() { const { returnValue } = this.test.ctx; const result = await returnValue; - return result.should.have.property('passphrase').be.null(); + return result.should.have.property('passphrase').be.null; } export async function itShouldResolveWithTheSecondPassphrase() { @@ -58,7 +58,7 @@ export async function itShouldResolveWithTheSecondPassphrase() { export async function itShouldResolveWithoutTheSecondPassphrase() { const { returnValue } = this.test.ctx; const result = await returnValue; - return result.should.have.property('secondPassphrase').be.null(); + return result.should.have.property('secondPassphrase').be.null; } export async function itShouldResolveWithThePassword() { @@ -70,7 +70,7 @@ export async function itShouldResolveWithThePassword() { export async function itShouldResolveWithoutThePassword() { const { returnValue } = this.test.ctx; const result = await returnValue; - return result.should.have.property('password').be.null(); + return result.should.have.property('password').be.null; } export async function itShouldResolveWithTheData() { @@ -82,7 +82,7 @@ export async function itShouldResolveWithTheData() { export async function itShouldResolveWithoutTheData() { const { returnValue } = this.test.ctx; const result = await returnValue; - return result.should.have.property('data').be.null(); + return result.should.have.property('data').be.null; } export function itShouldGetTheInputsFromSourcesUsingTheVorpalInstance() { @@ -93,7 +93,7 @@ export function itShouldGetTheInputsFromSourcesUsingTheVorpalInstance() { export function itShouldNotGetTheInputsFromSourcesUsingTheSecondPassphraseSource() { const firstCallArgs = getInputsFromSources.firstCall.args; - return firstCallArgs[1].should.have.property('secondPassphrase').be.null(); + return firstCallArgs[1].should.have.property('secondPassphrase').be.null; } export function itShouldGetTheInputsFromSourcesUsingTheSecondPassphraseSourceWithARepeatingPrompt() { @@ -115,7 +115,7 @@ export function itShouldGetTheInputsFromSourcesUsingTheEncryptedPassphraseSource export function itShouldNotGetTheInputsFromSourcesUsingTheEncryptedPassphraseSource() { const firstCallArgs = getInputsFromSources.firstCall.args; - return firstCallArgs[1].should.have.property('data').be.null(); + return firstCallArgs[1].should.have.property('data').be.null; } export function itShouldGetTheInputsFromSourcesUsingTheMessageSource() { @@ -128,7 +128,7 @@ export function itShouldGetTheInputsFromSourcesUsingTheMessageSource() { export function itShouldNotGetTheInputsFromSourcesUsingTheMessageSource() { const firstCallArgs = getInputsFromSources.firstCall.args; - return firstCallArgs[1].should.have.property('data').be.null(); + return firstCallArgs[1].should.have.property('data').be.null; } export function itShouldGetTheInputsFromSourcesUsingThePassphraseSourceWithARepeatingPrompt() { @@ -169,7 +169,7 @@ export function itShouldGetTheInputsFromSourcesWithoutARepeatingPassphrasePrompt const repeatPromptArg = getInputsFromSources.firstCall.args[1]; // istanbul ignore next return repeatPromptArg.repeatPrompt && repeatPromptArg.repeatPrompt.passphrase - ? repeatPromptArg.repeatPrompt.passphrase.should.not.be.true() + ? repeatPromptArg.repeatPrompt.passphrase.should.not.be.true : true; } @@ -184,7 +184,7 @@ export function itShouldNotGetThePassphrase() { const passphraseArgs = inputUtils.getPassphrase.args.filter( args => !args[2].displayName, ); - return passphraseArgs.should.be.empty(); + return passphraseArgs.should.be.empty; } export function itShouldGetTheSecondPassphrase() { @@ -198,7 +198,7 @@ export function itShouldNotGetTheSecondPassphrase() { const passphraseArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your second secret passphrase', ); - return passphraseArgs.should.be.empty(); + return passphraseArgs.should.be.empty; } export function itShouldGetThePassword() { @@ -212,7 +212,7 @@ export function itShouldNotGetThePassword() { const passphraseArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your password', ); - return passphraseArgs.should.be.empty(); + return passphraseArgs.should.be.empty; } export function itShouldGetTheData() { @@ -221,7 +221,7 @@ export function itShouldGetTheData() { } export function itShouldNotGetTheData() { - return inputUtils.getData.should.not.be.called(); + return inputUtils.getData.should.not.be.called; } export function itShouldAskForTheSecondPassphraseFromStdIn() { @@ -244,14 +244,14 @@ export function itShouldGetTheSecondPassphraseWithASinglePrompt() { )[0]; return secondPassphraseArgs[2].should.have .property('shouldRepeat') - .not.be.ok(); + .not.be.ok; } export function itShouldGetTheSecondPassphraseWithARepeatedPrompt() { const secondPassphraseArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your second secret passphrase', )[0]; - return secondPassphraseArgs[2].should.have.property('shouldRepeat').be.true(); + return secondPassphraseArgs[2].should.have.property('shouldRepeat').be.true; } export function itShouldGetThePassphraseWithASinglePrompt() { @@ -260,28 +260,28 @@ export function itShouldGetThePassphraseWithASinglePrompt() { )[0]; return firstPassphraseArgs[2].should.have .property('shouldRepeat') - .not.be.ok(); + .not.be.ok; } export function itShouldGetThePassphraseWithARepeatedPrompt() { const firstPassphraseArgs = inputUtils.getPassphrase.args.filter( args => !args[2] || !args[2].displayName, )[0]; - return firstPassphraseArgs[2].should.have.property('shouldRepeat').be.true(); + return firstPassphraseArgs[2].should.have.property('shouldRepeat').be.true; } export function itShouldGetThePasswordWithARepeatedPrompt() { const passwordArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your password', )[0]; - return passwordArgs[2].should.have.property('shouldRepeat').be.true(); + return passwordArgs[2].should.have.property('shouldRepeat').be.true; } export function itShouldGetThePasswordWithASinglePrompt() { const passwordArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your password', )[0]; - return passwordArgs[2].should.have.property('shouldRepeat').not.be.ok(); + return passwordArgs[2].should.have.property('shouldRepeat').not.be.ok; } export function itShouldNotAskForThePassphraseFromStdIn() { @@ -352,12 +352,12 @@ export function anOptionsObjectWithTheMessageShouldBeReturned() { export function itShouldPromptForThePassphraseOnce() { const { vorpal } = this.test.ctx; - return vorpal.activeCommand.prompt.should.be.calledOnce(); + return vorpal.activeCommand.prompt.should.be.calledOnce; } export function itShouldPromptForThePassphraseTwice() { const { vorpal } = this.test.ctx; - return vorpal.activeCommand.prompt.should.be.calledTwice(); + return vorpal.activeCommand.prompt.should.be.calledTwice; } export function itShouldUseOptionsWithTheMessage() { diff --git a/test/steps/printing/3_then.js b/test/steps/printing/3_then.js index 16afce1e..bcf56d28 100644 --- a/test/steps/printing/3_then.js +++ b/test/steps/printing/3_then.js @@ -64,7 +64,7 @@ export function theErrorShouldBePrintedWithThePrefix() { export function theActiveCommandShouldBeUsedToLog() { const { activeCommand } = this.test.ctx; - return activeCommand.log.should.be.calledOnce(); + return activeCommand.log.should.be.calledOnce; } export function theObjectShouldBePrinted() { diff --git a/test/steps/queries/3_then.js b/test/steps/queries/3_then.js index 97d9ec19..88c436e2 100644 --- a/test/steps/queries/3_then.js +++ b/test/steps/queries/3_then.js @@ -17,7 +17,7 @@ import { getFirstQuotedString } from '../utils'; export function itShouldResolveToTheResultOfSendingTheRequest() { const { returnValue, sendRequestResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(sendRequestResult); + return returnValue.should.be.eventually.eql(sendRequestResult); } export function theQueryInstanceShouldHaveTheLiskAPIInstanceAsAClient() { @@ -28,16 +28,16 @@ export function theQueryInstanceShouldHaveTheLiskAPIInstanceAsAClient() { export function theQueryInstanceShouldHaveAHandlerFor() { const { queryInstance } = this.test.ctx; const item = getFirstQuotedString(this.test.title); - return queryInstance.handlers.should.have.property(item).be.Function(); + return queryInstance.handlers.should.have.property(item).be.a('function'); } export function itShouldResolveToTheResultOfTheQuery() { const { returnValue, queryResult } = this.test.ctx; - return returnValue.should.be.fulfilledWith(queryResult); + return returnValue.should.be.eventually.eql(queryResult); } export function itShouldResolveToAnArrayOfQueryResults() { const { returnValue, inputs, queryResult } = this.test.ctx; const arrayOfQueryResults = inputs.map(() => queryResult); - return returnValue.should.be.fulfilledWith(arrayOfQueryResults); + return returnValue.should.be.eventually.eql(arrayOfQueryResults); } diff --git a/test/steps/transactions/3_then.js b/test/steps/transactions/3_then.js index d2f981c4..b91ffbc3 100644 --- a/test/steps/transactions/3_then.js +++ b/test/steps/transactions/3_then.js @@ -113,7 +113,7 @@ export function itShouldCreateARegisterSecondPassphraseTransactionUsingThePassph export function itShouldResolveToTheCreatedTransaction() { const { returnValue, createdTransaction } = this.test.ctx; - return returnValue.should.be.fulfilledWith(createdTransaction); + return returnValue.should.be.eventually.eql(createdTransaction); } export function itShouldCreateARegisterDelegateTransactionUsingThePassphraseAndTheDelegateUsername() { diff --git a/test/steps/vorpal/3_then.js b/test/steps/vorpal/3_then.js index 25e616db..823ee2b5 100644 --- a/test/steps/vorpal/3_then.js +++ b/test/steps/vorpal/3_then.js @@ -69,7 +69,7 @@ export function theVorpalCommandInstanceShouldHaveThePrettyOption() { export function theVorpalInstanceShouldHaveTheCommand() { const { vorpal, command } = this.test.ctx; const commandInstance = getCommandInstance(vorpal, command); - return commandInstance.should.be.ok(); + return commandInstance.should.be.ok; } export function aUIParentShouldBeSet() { From 7e26b8db6b80f4c822d211707ad878091a9003ee Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 14 Feb 2018 10:38:45 +0100 Subject: [PATCH 2/6] :recycle: Solve matchAny by creating function --- test/setup.js | 17 +++++++++++++++++ test/steps/printing/3_then.js | 4 ++-- test/steps/transactions/3_then.js | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/test/setup.js b/test/setup.js index e112c823..d7136131 100644 --- a/test/setup.js +++ b/test/setup.js @@ -52,6 +52,23 @@ Assertion.addProperty('integer', function handleAssert() { 'expected #{this} not to be an integer', ); }); + +Assertion.addMethod('matchAny', function handleAssert(matcher) { + const obj = this._obj; + + new Assertion(obj).to.be.an('array'); + let result = false; + obj.forEach(val => { + if (matcher(val)) { + result = true; + } + }); + this.assert( + result, + 'expected #{this} to match at least once', + 'expected #{this} to not to match', + ); +}); /* eslint-enable no-underscore-dangle */ mochaBDD(); diff --git a/test/steps/printing/3_then.js b/test/steps/printing/3_then.js index bcf56d28..bb30fd26 100644 --- a/test/steps/printing/3_then.js +++ b/test/steps/printing/3_then.js @@ -199,9 +199,9 @@ export function theReturnedTableShouldHaveARowForEachObjectWithTheObjectsValues( const row = returnValue[i]; const values = Object.values(testObject); - values.forEach(value => row.should.containEql(value)); + values.forEach(value => row.should.include(value)); return row .filter(value => !values.includes(value)) - .forEach(value => should(value).be.undefined()); + .forEach(value => should(value).be.undefined); }); } diff --git a/test/steps/transactions/3_then.js b/test/steps/transactions/3_then.js index b91ffbc3..b309ee87 100644 --- a/test/steps/transactions/3_then.js +++ b/test/steps/transactions/3_then.js @@ -99,8 +99,8 @@ export function itShouldHaveAFunctionForCreatingATypeTransaction() { transactionType, ); return transactionsObject.should.have - .key(transactionFunctionName) - .and.be.type('function'); + .property(transactionFunctionName) + .and.be.a('function'); } export function itShouldCreateARegisterSecondPassphraseTransactionUsingThePassphraseAndTheSecondPassphrase() { From cba00b3d310e2a14100a76f60c5d02f4585b64bf Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 14 Feb 2018 18:27:16 +0100 Subject: [PATCH 3/6] :recycle: Add work around for cutom error check --- test/setup.js | 1 - test/steps/general/3_then.js | 35 +++++++++++++++++++++++++++++------ test/steps/printing/3_then.js | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/test/setup.js b/test/setup.js index d7136131..38742d50 100644 --- a/test/setup.js +++ b/test/setup.js @@ -75,6 +75,5 @@ mochaBDD(); [sinonChai, chaiAsPromised].forEach(plugin => chai.use(plugin)); -global.should = chai.should(); global.sinon = sinon; global.sandbox = sinon.sandbox.create(); diff --git a/test/steps/general/3_then.js b/test/steps/general/3_then.js index b84d621c..40c3ab13 100644 --- a/test/steps/general/3_then.js +++ b/test/steps/general/3_then.js @@ -14,7 +14,6 @@ * */ import { getFirstQuotedString, getFirstNumber } from '../utils'; -import { FileSystemError, ValidationError } from '../../../src/utils/error'; export function theErrorShouldBeInstanceOfNodesBuiltInError() { const { testError } = this.test.ctx; @@ -35,13 +34,29 @@ export function itShouldReturnTheResult() { export function itShouldThrowValidationError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return testFunction.should.throw(ValidationError, message); + testFunction.should.throw().and.is.instanceOf(Error); + testFunction.should + .throw() + .and.has.property('name') + .which.equal('ValidationError'); + return testFunction.should + .throw() + .and.has.property('message') + .which.include(message); } export function itShouldThrowFileSystemError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return testFunction.should.throw(FileSystemError, message); + testFunction.should.throw().and.is.instanceOf(Error); + testFunction.should + .throw() + .and.has.property('name') + .which.equal('FileSystemError'); + return testFunction.should + .throw() + .and.has.property('message') + .which.include(message); } export function itShouldExitWithCode() { @@ -82,13 +97,21 @@ export function itShouldRejectWithTheErrorMessage() { export function itShouldRejectWithFileSystemErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return returnValue.should.be.rejectedWith(new FileSystemError(message)); + return returnValue.should.be.rejected.then(err => { + err.should.be.instanceOf(Error); + err.should.have.property('name').which.equal('FileSystemError'); + return err.should.have.property('message').which.include(message); + }); } export function itShouldRejectWithValidationErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return returnValue.should.be.rejectedWith(new ValidationError(message)); + return returnValue.should.be.rejected.then(err => { + err.should.be.instanceOf(Error); + err.should.have.property('name').which.equal('ValidationError'); + return err.should.have.property('message').which.include(message); + }); } export function itShouldRejectWithMessage() { @@ -119,7 +142,7 @@ export function itShouldReturnFalse() { export function itShouldReturnNull() { const { returnValue } = this.test.ctx; - return should(returnValue).be.null; + return should.equal(returnValue, null); } export function itShouldReturnString() { diff --git a/test/steps/printing/3_then.js b/test/steps/printing/3_then.js index bb30fd26..fdfcbf4e 100644 --- a/test/steps/printing/3_then.js +++ b/test/steps/printing/3_then.js @@ -202,6 +202,6 @@ export function theReturnedTableShouldHaveARowForEachObjectWithTheObjectsValues( values.forEach(value => row.should.include(value)); return row .filter(value => !values.includes(value)) - .forEach(value => should(value).be.undefined); + .forEach(value => should.equal(value, undefined)); }); } From ba60a0bbeb9dc3c2b180484379bd0db3ce0d98fa Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Thu, 15 Feb 2018 16:42:58 +0100 Subject: [PATCH 4/6] :recycle: change custom error handling to custom function --- test/setup.js | 22 ++++++++++++---------- test/steps/general/3_then.js | 25 +++++-------------------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/test/setup.js b/test/setup.js index 38742d50..ca471ad9 100644 --- a/test/setup.js +++ b/test/setup.js @@ -35,8 +35,8 @@ Assertion.addProperty('hexString', function handleAssert() { const expected = Buffer.from(actual, 'hex').toString('hex'); this.assert( expected === actual, - 'expected #{this} to be a hexString', - 'expected #{this} not to be a hexString', + 'expected #{this} to be a hex string', + 'expected #{this} not to be a hex string', ); }); @@ -57,23 +57,25 @@ Assertion.addMethod('matchAny', function handleAssert(matcher) { const obj = this._obj; new Assertion(obj).to.be.an('array'); - let result = false; - obj.forEach(val => { - if (matcher(val)) { - result = true; - } - }); + const result = obj.some(val => matcher(val)); this.assert( result, 'expected #{this} to match at least once', - 'expected #{this} to not to match', + 'expected #{this} not to match', ); }); + +Assertion.addMethod('customError', function handleAssert(error) { + const obj = this._obj; + new Assertion(obj).to.be.instanceOf(Error); + new Assertion(obj.name).to.equal(error.name); + new Assertion(obj.message).to.equal(error.message); +}); /* eslint-enable no-underscore-dangle */ mochaBDD(); -[sinonChai, chaiAsPromised].forEach(plugin => chai.use(plugin)); +[sinonChai, chaiAsPromised].forEach(chai.use); global.sinon = sinon; global.sandbox = sinon.sandbox.create(); diff --git a/test/steps/general/3_then.js b/test/steps/general/3_then.js index 40c3ab13..cb69d442 100644 --- a/test/steps/general/3_then.js +++ b/test/steps/general/3_then.js @@ -14,6 +14,7 @@ * */ import { getFirstQuotedString, getFirstNumber } from '../utils'; +import { ValidationError, FileSystemError } from '../../../src/utils/error'; export function theErrorShouldBeInstanceOfNodesBuiltInError() { const { testError } = this.test.ctx; @@ -34,29 +35,17 @@ export function itShouldReturnTheResult() { export function itShouldThrowValidationError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - testFunction.should.throw().and.is.instanceOf(Error); - testFunction.should - .throw() - .and.has.property('name') - .which.equal('ValidationError'); return testFunction.should .throw() - .and.has.property('message') - .which.include(message); + .and.be.customError(new ValidationError(message)); } export function itShouldThrowFileSystemError() { const { testFunction } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - testFunction.should.throw().and.is.instanceOf(Error); - testFunction.should - .throw() - .and.has.property('name') - .which.equal('FileSystemError'); return testFunction.should .throw() - .and.has.property('message') - .which.include(message); + .and.be.customError(new FileSystemError(message)); } export function itShouldExitWithCode() { @@ -98,9 +87,7 @@ export function itShouldRejectWithFileSystemErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); return returnValue.should.be.rejected.then(err => { - err.should.be.instanceOf(Error); - err.should.have.property('name').which.equal('FileSystemError'); - return err.should.have.property('message').which.include(message); + return err.should.be.customError(new FileSystemError(message)); }); } @@ -108,9 +95,7 @@ export function itShouldRejectWithValidationErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); return returnValue.should.be.rejected.then(err => { - err.should.be.instanceOf(Error); - err.should.have.property('name').which.equal('ValidationError'); - return err.should.have.property('message').which.include(message); + return err.should.be.customError(new ValidationError(message)); }); } From 5182fed9ff3dcb228e0e8c2f5179af19ffdd6a09 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Thu, 15 Feb 2018 18:30:07 +0100 Subject: [PATCH 5/6] :recycle: Deleted non used code and fix test language --- test/setup.js | 26 -------------------------- test/steps/api/3_then.js | 2 +- test/steps/config/3_then.js | 2 +- test/steps/crypto/3_then.js | 26 +++++++++++++------------- test/steps/files/3_then.js | 2 +- test/steps/general/3_then.js | 12 ++++++------ test/steps/queries/3_then.js | 6 +++--- test/steps/transactions/3_then.js | 2 +- 8 files changed, 26 insertions(+), 52 deletions(-) diff --git a/test/setup.js b/test/setup.js index ca471ad9..cb296c5e 100644 --- a/test/setup.js +++ b/test/setup.js @@ -27,32 +27,6 @@ process.env.LISKY_CONFIG_DIR = process.env.LISKY_CONFIG_DIR || `${os.homedir()}/.lisky`; /* eslint-disable no-underscore-dangle */ -Assertion.addProperty('hexString', function handleAssert() { - const actual = this._obj; - - new Assertion(actual).to.be.a('string'); - - const expected = Buffer.from(actual, 'hex').toString('hex'); - this.assert( - expected === actual, - 'expected #{this} to be a hex string', - 'expected #{this} not to be a hex string', - ); -}); - -Assertion.addProperty('integer', function handleAssert() { - const actual = this._obj; - - new Assertion(actual).to.be.a('number'); - - const expected = parseInt(actual, 10); - this.assert( - actual === expected, - 'expected #{this} to be an integer', - 'expected #{this} not to be an integer', - ); -}); - Assertion.addMethod('matchAny', function handleAssert(matcher) { const obj = this._obj; diff --git a/test/steps/api/3_then.js b/test/steps/api/3_then.js index dc604d54..5d24cdb8 100644 --- a/test/steps/api/3_then.js +++ b/test/steps/api/3_then.js @@ -66,7 +66,7 @@ export function itShouldBroadcastTheTransaction() { export function itShouldResolveToTheAPIResponse() { const { returnValue, apiResponse } = this.test.ctx; - return returnValue.should.be.eventually.eql(apiResponse); + return returnValue.should.eventually.eql(apiResponse); } export function theLiskAPIInstanceShouldBeALiskJSAPIInstance() { diff --git a/test/steps/config/3_then.js b/test/steps/config/3_then.js index ce46a5b7..5fdf86e8 100644 --- a/test/steps/config/3_then.js +++ b/test/steps/config/3_then.js @@ -42,7 +42,7 @@ export function itShouldUpdateTheConfigVariableToBoolean() { export function itShouldResolveToTheConfig() { const { returnValue, config } = this.test.ctx; - return returnValue.should.be.eventually.eql(config); + return returnValue.should.eventually.eql(config); } export function theDefaultConfigShouldBeExported() { diff --git a/test/steps/crypto/3_then.js b/test/steps/crypto/3_then.js index 8d3bf2d8..dc53f6af 100644 --- a/test/steps/crypto/3_then.js +++ b/test/steps/crypto/3_then.js @@ -27,12 +27,12 @@ export function itShouldSignTheMessageWithThePassphrase() { export function itShouldResolveToTheResultOfSigningTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(cryptoResult); + return returnValue.should.eventually.eql(cryptoResult); } export function itShouldResolveToTheResultOfDecryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(cryptoResult); + return returnValue.should.eventually.eql(cryptoResult); } export function itShouldDecryptThePassphraseUsingTheIVAndThePassword() { @@ -46,7 +46,7 @@ export function itShouldDecryptThePassphraseUsingTheIVAndThePassword() { export function itShouldResolveToTheResultOfEncryptingThePassphraseCombinedWithThePublicKey() { const { returnValue, cryptoResult, publicKey } = this.test.ctx; - return returnValue.should.be.eventually.eql( + return returnValue.should.eventually.eql( Object.assign({}, cryptoResult, { publicKey }), ); } @@ -61,7 +61,7 @@ export function itShouldEncryptThePassphraseUsingThePassword() { export function itShouldResolveToTheResultOfEncryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(cryptoResult); + return returnValue.should.eventually.eql(cryptoResult); } export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderPublicKey() { @@ -76,7 +76,7 @@ export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderP export function itShouldResolveToTheResultOfDecryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(cryptoResult); + return returnValue.should.eventually.eql(cryptoResult); } export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { @@ -90,7 +90,7 @@ export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { export function itShouldResolveToTheResultOfEncryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(cryptoResult); + return returnValue.should.eventually.eql(cryptoResult); } export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheAddress() { @@ -105,7 +105,7 @@ export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheA publicKey, address, }; - return returnValue.should.be.eventually.eql(expectedObject); + return returnValue.should.eventually.eql(expectedObject); } export function theSignatureShouldBeReturned() { @@ -215,12 +215,12 @@ export function theDecryptedMessageShouldBeReturned() { export function itShouldResolveToThePassphrase() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.eventually.eql(passphrase); + return returnValue.should.eventually.eql(passphrase); } export function itShouldReturnAnObjectWithThePassphrase() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.eventually.eql({ + return returnValue.should.eventually.eql({ passphrase, secondPassphrase: null, password: null, @@ -230,7 +230,7 @@ export function itShouldReturnAnObjectWithThePassphrase() { export function itShouldReturnAnObjectWithTheSecondPassphrase() { const { returnValue, secondPassphrase } = this.test.ctx; - return returnValue.should.be.eventually.eql({ + return returnValue.should.eventually.eql({ passphrase: null, secondPassphrase, password: null, @@ -240,7 +240,7 @@ export function itShouldReturnAnObjectWithTheSecondPassphrase() { export function itShouldReturnAnObjectWithThePassword() { const { returnValue, password } = this.test.ctx; - return returnValue.should.be.eventually.eql({ + return returnValue.should.eventually.eql({ passphrase: null, secondPassphrase: null, password, @@ -250,7 +250,7 @@ export function itShouldReturnAnObjectWithThePassword() { export function itShouldReturnAnObjectWithTheData() { const { returnValue, data } = this.test.ctx; - return returnValue.should.be.eventually.eql({ + return returnValue.should.eventually.eql({ passphrase: null, secondPassphrase: null, password: null, @@ -266,7 +266,7 @@ export function itShouldReturnAnObjectWithThePassphraseTheSecondPassphraseThePas password, data, } = this.test.ctx; - return returnValue.should.be.eventually.eql({ + return returnValue.should.eventually.eql({ passphrase, secondPassphrase, password, diff --git a/test/steps/files/3_then.js b/test/steps/files/3_then.js index 6fea5b94..02fd3fa3 100644 --- a/test/steps/files/3_then.js +++ b/test/steps/files/3_then.js @@ -69,5 +69,5 @@ export function theConfigFileShouldNotBeWritten() { export function itShouldResolveToTheFirstLineOfTheFile() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.be.eventually.eql(passphrase); + return returnValue.should.eventually.eql(passphrase); } diff --git a/test/steps/general/3_then.js b/test/steps/general/3_then.js index cb69d442..43facf76 100644 --- a/test/steps/general/3_then.js +++ b/test/steps/general/3_then.js @@ -56,7 +56,7 @@ export function itShouldExitWithCode() { export function itShouldResolveToTheErrorObject() { const { returnValue, errorObject } = this.test.ctx; - return returnValue.should.be.eventually.eql(errorObject); + return returnValue.should.eventually.eql(errorObject); } export async function itShouldResolveToAnObjectWithMessage() { @@ -112,7 +112,7 @@ export function itShouldRejectWithTheOriginalRejection() { export function itShouldReturnAnEmptyObject() { const { returnValue } = this.test.ctx; - return returnValue.should.be.eventually.eql({}); + return returnValue.should.eventually.eql({}); } export function itShouldReturnTrue() { @@ -139,12 +139,12 @@ export function itShouldReturnString() { export function itShouldResolveToTheOptions() { const { options, returnValue } = this.test.ctx; - return returnValue.should.be.eventually.eql(options); + return returnValue.should.eventually.eql(options); } export function itShouldResolveToTheDataAsAString() { const { returnValue, data } = this.test.ctx; - return returnValue.should.be.eventually.eql(data); + return returnValue.should.eventually.eql(data); } export function itShouldReturnAnObjectWithError() { @@ -157,10 +157,10 @@ export function itShouldReturnAnObjectWithError() { export function itShouldResolveToTheWarrantyInformation() { const { returnValue, warranty } = this.test.ctx; - return returnValue.should.be.eventually.eql({ warranty }); + return returnValue.should.eventually.eql({ warranty }); } export function itShouldResolveToTheCopyrightInformation() { const { returnValue, copyright } = this.test.ctx; - return returnValue.should.be.eventually.eql({ copyright }); + return returnValue.should.eventually.eql({ copyright }); } diff --git a/test/steps/queries/3_then.js b/test/steps/queries/3_then.js index 88c436e2..f857c090 100644 --- a/test/steps/queries/3_then.js +++ b/test/steps/queries/3_then.js @@ -17,7 +17,7 @@ import { getFirstQuotedString } from '../utils'; export function itShouldResolveToTheResultOfSendingTheRequest() { const { returnValue, sendRequestResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(sendRequestResult); + return returnValue.should.eventually.eql(sendRequestResult); } export function theQueryInstanceShouldHaveTheLiskAPIInstanceAsAClient() { @@ -33,11 +33,11 @@ export function theQueryInstanceShouldHaveAHandlerFor() { export function itShouldResolveToTheResultOfTheQuery() { const { returnValue, queryResult } = this.test.ctx; - return returnValue.should.be.eventually.eql(queryResult); + return returnValue.should.eventually.eql(queryResult); } export function itShouldResolveToAnArrayOfQueryResults() { const { returnValue, inputs, queryResult } = this.test.ctx; const arrayOfQueryResults = inputs.map(() => queryResult); - return returnValue.should.be.eventually.eql(arrayOfQueryResults); + return returnValue.should.eventually.eql(arrayOfQueryResults); } diff --git a/test/steps/transactions/3_then.js b/test/steps/transactions/3_then.js index b309ee87..0caeb766 100644 --- a/test/steps/transactions/3_then.js +++ b/test/steps/transactions/3_then.js @@ -113,7 +113,7 @@ export function itShouldCreateARegisterSecondPassphraseTransactionUsingThePassph export function itShouldResolveToTheCreatedTransaction() { const { returnValue, createdTransaction } = this.test.ctx; - return returnValue.should.be.eventually.eql(createdTransaction); + return returnValue.should.eventually.eql(createdTransaction); } export function itShouldCreateARegisterDelegateTransactionUsingThePassphraseAndTheDelegateUsername() { From 3c8a68f1c3780e540e8b6a3fabb1a9b6e5090d65 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Mon, 26 Feb 2018 17:21:18 +0100 Subject: [PATCH 6/6] :recycle: Fix syntaxing and change eql to equal where it can --- test/README.md | 2 +- test/steps/crypto/3_then.js | 20 ++++++++++---------- test/steps/files/3_then.js | 2 +- test/steps/general/3_then.js | 16 ++++++++-------- test/steps/inputs/3_then.js | 8 ++------ test/steps/queries/3_then.js | 4 ++-- test/steps/transactions/3_then.js | 2 +- 7 files changed, 25 insertions(+), 29 deletions(-) diff --git a/test/README.md b/test/README.md index d1e78c0e..ddc1fc3f 100644 --- a/test/README.md +++ b/test/README.md @@ -131,7 +131,7 @@ export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheA publicKey, address, }; - return returnValue.should.be.fulfilledWith(expectedObject); + return returnValue.should.eventually.eql(expectedObject); } ``` diff --git a/test/steps/crypto/3_then.js b/test/steps/crypto/3_then.js index dc53f6af..4ddf9867 100644 --- a/test/steps/crypto/3_then.js +++ b/test/steps/crypto/3_then.js @@ -27,12 +27,12 @@ export function itShouldSignTheMessageWithThePassphrase() { export function itShouldResolveToTheResultOfSigningTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.eventually.eql(cryptoResult); + return returnValue.should.eventually.equal(cryptoResult); } export function itShouldResolveToTheResultOfDecryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.eventually.eql(cryptoResult); + return returnValue.should.eventually.equal(cryptoResult); } export function itShouldDecryptThePassphraseUsingTheIVAndThePassword() { @@ -61,7 +61,7 @@ export function itShouldEncryptThePassphraseUsingThePassword() { export function itShouldResolveToTheResultOfEncryptingThePassphrase() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.eventually.eql(cryptoResult); + return returnValue.should.eventually.equal(cryptoResult); } export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderPublicKey() { @@ -76,7 +76,7 @@ export function itShouldDecryptTheMessageUsingTheNonceThePassphraseAndTheSenderP export function itShouldResolveToTheResultOfDecryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.eventually.eql(cryptoResult); + return returnValue.should.eventually.equal(cryptoResult); } export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { @@ -90,7 +90,7 @@ export function itShouldEncryptTheMessageWithThePassphraseForTheRecipient() { export function itShouldResolveToTheResultOfEncryptingTheMessage() { const { returnValue, cryptoResult } = this.test.ctx; - return returnValue.should.eventually.eql(cryptoResult); + return returnValue.should.eventually.equal(cryptoResult); } export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheAddress() { @@ -110,7 +110,7 @@ export function itShouldResolveToAnObjectWithThePassphraseAndThePublicKeyAndTheA export function theSignatureShouldBeReturned() { const { returnValue, signature } = this.test.ctx; - return returnValue.should.be.eql(signature); + return returnValue.should.be.equal(signature); } export function liskJSCryptoShouldBeUsedToSignTheMessage() { @@ -146,7 +146,7 @@ export function liskJSCryptoShouldBeUsedToGetTheKeysForThePassphrase() { export function theKeysShouldBeReturned() { const { returnValue, keys } = this.test.ctx; - return returnValue.should.eql(keys); + return returnValue.should.equal(keys); } export function theErrorResponseShouldBeHandled() { @@ -164,7 +164,7 @@ export function liskJSCryptoShouldBeUsedToGetTheEncryptedPassphraseAndIV() { export function theEncryptedPassphraseAndIVShouldBeReturned() { const { returnValue, cipherAndIv } = this.test.ctx; - return returnValue.should.eql(cipherAndIv); + return returnValue.should.equal(cipherAndIv); } export function liskJSCryptoShouldBeUsedToGetTheDecryptedPassphrase() { @@ -191,7 +191,7 @@ export function liskJSCryptoShouldBeUsedToGetTheEncryptedMessageAndNonce() { export function theEncryptedMessageAndNonceShouldBeReturned() { const { returnValue, cipherAndNonce } = this.test.ctx; - return returnValue.should.eql(cipherAndNonce); + return returnValue.should.equal(cipherAndNonce); } export function liskJSCryptoShouldBeUsedToGetTheDecryptedMessage() { @@ -215,7 +215,7 @@ export function theDecryptedMessageShouldBeReturned() { export function itShouldResolveToThePassphrase() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.eventually.eql(passphrase); + return returnValue.should.eventually.equal(passphrase); } export function itShouldReturnAnObjectWithThePassphrase() { diff --git a/test/steps/files/3_then.js b/test/steps/files/3_then.js index 02fd3fa3..8f3f5269 100644 --- a/test/steps/files/3_then.js +++ b/test/steps/files/3_then.js @@ -69,5 +69,5 @@ export function theConfigFileShouldNotBeWritten() { export function itShouldResolveToTheFirstLineOfTheFile() { const { returnValue, passphrase } = this.test.ctx; - return returnValue.should.eventually.eql(passphrase); + return returnValue.should.eventually.equal(passphrase); } diff --git a/test/steps/general/3_then.js b/test/steps/general/3_then.js index 43facf76..59868e2d 100644 --- a/test/steps/general/3_then.js +++ b/test/steps/general/3_then.js @@ -86,17 +86,17 @@ export function itShouldRejectWithTheErrorMessage() { export function itShouldRejectWithFileSystemErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return returnValue.should.be.rejected.then(err => { - return err.should.be.customError(new FileSystemError(message)); - }); + return returnValue.should.be.rejected.then(err => + err.should.be.customError(new FileSystemError(message)), + ); } export function itShouldRejectWithValidationErrorAndMessage() { const { returnValue } = this.test.ctx; const message = getFirstQuotedString(this.test.title); - return returnValue.should.be.rejected.then(err => { - return err.should.be.customError(new ValidationError(message)); - }); + return returnValue.should.be.rejected.then(err => + err.should.be.customError(new ValidationError(message)), + ); } export function itShouldRejectWithMessage() { @@ -139,12 +139,12 @@ export function itShouldReturnString() { export function itShouldResolveToTheOptions() { const { options, returnValue } = this.test.ctx; - return returnValue.should.eventually.eql(options); + return returnValue.should.eventually.equal(options); } export function itShouldResolveToTheDataAsAString() { const { returnValue, data } = this.test.ctx; - return returnValue.should.eventually.eql(data); + return returnValue.should.eventually.equal(data); } export function itShouldReturnAnObjectWithError() { diff --git a/test/steps/inputs/3_then.js b/test/steps/inputs/3_then.js index fcaa6505..9effd359 100644 --- a/test/steps/inputs/3_then.js +++ b/test/steps/inputs/3_then.js @@ -242,9 +242,7 @@ export function itShouldGetTheSecondPassphraseWithASinglePrompt() { const secondPassphraseArgs = inputUtils.getPassphrase.args.filter( args => args[2].displayName === 'your second secret passphrase', )[0]; - return secondPassphraseArgs[2].should.have - .property('shouldRepeat') - .not.be.ok; + return secondPassphraseArgs[2].should.have.property('shouldRepeat').not.be.ok; } export function itShouldGetTheSecondPassphraseWithARepeatedPrompt() { @@ -258,9 +256,7 @@ export function itShouldGetThePassphraseWithASinglePrompt() { const firstPassphraseArgs = inputUtils.getPassphrase.args.filter( args => !args[2] || !args[2].displayName, )[0]; - return firstPassphraseArgs[2].should.have - .property('shouldRepeat') - .not.be.ok; + return firstPassphraseArgs[2].should.have.property('shouldRepeat').not.be.ok; } export function itShouldGetThePassphraseWithARepeatedPrompt() { diff --git a/test/steps/queries/3_then.js b/test/steps/queries/3_then.js index f857c090..0da24699 100644 --- a/test/steps/queries/3_then.js +++ b/test/steps/queries/3_then.js @@ -17,7 +17,7 @@ import { getFirstQuotedString } from '../utils'; export function itShouldResolveToTheResultOfSendingTheRequest() { const { returnValue, sendRequestResult } = this.test.ctx; - return returnValue.should.eventually.eql(sendRequestResult); + return returnValue.should.eventually.equal(sendRequestResult); } export function theQueryInstanceShouldHaveTheLiskAPIInstanceAsAClient() { @@ -33,7 +33,7 @@ export function theQueryInstanceShouldHaveAHandlerFor() { export function itShouldResolveToTheResultOfTheQuery() { const { returnValue, queryResult } = this.test.ctx; - return returnValue.should.eventually.eql(queryResult); + return returnValue.should.eventually.equal(queryResult); } export function itShouldResolveToAnArrayOfQueryResults() { diff --git a/test/steps/transactions/3_then.js b/test/steps/transactions/3_then.js index 0caeb766..12a53896 100644 --- a/test/steps/transactions/3_then.js +++ b/test/steps/transactions/3_then.js @@ -113,7 +113,7 @@ export function itShouldCreateARegisterSecondPassphraseTransactionUsingThePassph export function itShouldResolveToTheCreatedTransaction() { const { returnValue, createdTransaction } = this.test.ctx; - return returnValue.should.eventually.eql(createdTransaction); + return returnValue.should.eventually.equal(createdTransaction); } export function itShouldCreateARegisterDelegateTransactionUsingThePassphraseAndTheDelegateUsername() {