Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit 3d29da1

Browse files
committed
Removing error message assertions
License: MIT Signed-off-by: Adam Uhlir <uhlir.a@gmail.com>
1 parent 494e1c9 commit 3d29da1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

test/index.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,22 @@ describe('index.js', () => {
8787

8888
expect(
8989
() => migrator.getLatestMigrationVersion([])
90-
).to.throw(errors.InvalidValueError, 'Migrations must be non-empty array!').with.property('code', errors.InvalidValueError.code)
90+
).to.throw(errors.InvalidValueError).with.property('code', errors.InvalidValueError.code)
9191
})
9292

9393
describe('revert', () => {
9494
it('should error with out path argument', () => {
9595
const options = createOptions()
9696

9797
return expect(migrator.revert(undefined, undefined, options))
98-
.to.eventually.be.rejectedWith(errors.RequiredParameterError, 'Path argument is required!').with.property('code', errors.RequiredParameterError.code)
98+
.to.eventually.be.rejectedWith(errors.RequiredParameterError).with.property('code', errors.RequiredParameterError.code)
9999
})
100100

101101
it('should error with out toVersion argument', () => {
102102
const options = createOptions()
103103

104104
return expect(migrator.revert('/some/path', undefined, options))
105-
.to.eventually.be.rejectedWith(errors.RequiredParameterError, 'When reverting migrations, you have to specify to which version to revert!').with.property('code', errors.RequiredParameterError.code)
105+
.to.eventually.be.rejectedWith(errors.RequiredParameterError).with.property('code', errors.RequiredParameterError.code)
106106
})
107107

108108
it('should error with invalid toVersion argument', () => {
@@ -111,7 +111,7 @@ describe('index.js', () => {
111111

112112
return Promise.all(
113113
invalidValues.map((value) => expect(migrator.revert('/some/path', value, options))
114-
.to.eventually.be.rejectedWith(errors.InvalidValueError, 'Version has to be positive integer!').with.property('code', errors.InvalidValueError.code))
114+
.to.eventually.be.rejectedWith(errors.InvalidValueError).with.property('code', errors.InvalidValueError.code))
115115
)
116116
})
117117

@@ -143,7 +143,7 @@ describe('index.js', () => {
143143
getVersionStub.returns(4)
144144
return expect(
145145
migrator.revert('/some/path', 1, options)
146-
).to.eventually.be.rejectedWith(errors.NonReversibleMigrationError, 'Migration version 3 is not possible to revert! Cancelling reversion.')
146+
).to.eventually.be.rejectedWith(errors.NonReversibleMigrationError)
147147
.with.property('code', errors.NonReversibleMigrationError.code)
148148
})
149149

@@ -272,15 +272,15 @@ describe('index.js', () => {
272272
const options = createOptions()
273273

274274
return expect(migrator.migrate(undefined, options))
275-
.to.eventually.be.rejectedWith(errors.RequiredParameterError, 'Path argument is required!').with.property('code', errors.RequiredParameterError.code)
275+
.to.eventually.be.rejectedWith(errors.RequiredParameterError).with.property('code', errors.RequiredParameterError.code)
276276
})
277277

278278
it('should error with invalid toVersion argument', () => {
279279
const invalidValues = ['eight', '-1', '1', -1]
280280

281281
return Promise.all(
282282
invalidValues.map((invalidValue) => expect(migrator.migrate('/some/path', createOptions(invalidValue)))
283-
.to.eventually.be.rejectedWith(errors.InvalidValueError, 'Version has to be positive integer!').with.property('code', errors.InvalidValueError.code))
283+
.to.eventually.be.rejectedWith(errors.InvalidValueError).with.property('code', errors.InvalidValueError.code))
284284
)
285285
})
286286

test/version-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ const Datastore = require('datastore-fs')
88
const Key = require('interface-datastore').Key
99
const version = require('../src/repo/version')
1010

11+
const errors = require('../src/errors')
12+
1113
// When new versioning mechanism is introduced in new version don't forget to update
1214
// the range (from/to) of the previous version test's description
1315

1416
module.exports = (setup, cleanup) => {
1517
it('getVersion should fail without any version in repo', async () => {
1618
const dir = await setup()
17-
await expect(version.getVersion(dir)).to.be.eventually.rejectedWith('Repo does not have version file! Is the repo initialized?')
19+
await expect(version.getVersion(dir)).to.be.eventually.rejectedWith(errors.UnknownRepoStructureError).with.property('code', errors.UnknownRepoStructureError.code)
1820
return cleanup(dir)
1921
})
2022

@@ -40,7 +42,7 @@ module.exports = (setup, cleanup) => {
4042
})
4143

4244
it('should set version number', async () => {
43-
await expect(version.getVersion(dir)).to.be.eventually.rejectedWith('Repo does not have version file! Is the repo initialized?')
45+
await expect(version.getVersion(dir)).to.be.eventually.rejectedWith(errors.UnknownRepoStructureError).with.property('code', errors.UnknownRepoStructureError.code)
4446
await version.setVersion(dir, 7)
4547
expect(await version.getVersion(dir)).to.be.equal(7)
4648
})

0 commit comments

Comments
 (0)