Skip to content

Commit 53528ce

Browse files
util: remove constants for const vars in test
1 parent 174826f commit 53528ce

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

packages/util/test/errors.spec.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
import { assert, describe, it } from 'vitest'
22

3-
import { EthereumJSError, EthereumJSErrorWithoutCode } from '../src/errors.js'
3+
import { DEFAULT_ERROR_CODE, EthereumJSError, EthereumJSErrorWithoutCode } from '../src/errors.js'
44

5-
enum EthereumJSErrorType {
6-
ETHEREUMJS_ERROR = 'ETHEREUMJS_ERROR',
7-
ETHEREUMJS_UNSET_ERROR_CODE = 'ETHEREUMJS_UNSET_ERROR_CODE',
8-
}
5+
const TEST_ERROR_CODE = 'TEST_ERROR_CODE'
6+
const TEST_MSG = 'test error message'
97

108
describe('EthereumJSError', () => {
119
it('should create an error with a code', () => {
12-
const error = new EthereumJSError({ code: EthereumJSErrorType.ETHEREUMJS_ERROR }, 'test error')
13-
assert.equal(error.type.code, 'ETHEREUMJS_ERROR')
14-
assert.equal(error.message, 'test error')
10+
const error = new EthereumJSError({ code: TEST_ERROR_CODE }, TEST_MSG)
11+
assert.equal(error.type.code, TEST_ERROR_CODE)
12+
assert.equal(error.message, TEST_MSG)
1513
const object = error.toObject()
16-
assert.equal(object.type.code, 'ETHEREUMJS_ERROR')
17-
assert.equal(object.message, 'test error')
14+
assert.equal(object.type.code, TEST_ERROR_CODE)
15+
assert.equal(object.message, TEST_MSG)
1816
})
1917

20-
it('should create an error using the unset code', () => {
21-
const error = EthereumJSErrorWithoutCode('test error')
22-
assert.equal(error.type.code, 'ETHEREUMJS_UNSET_ERROR_CODE')
23-
assert.equal(error.message, 'test error')
18+
it('should create an error using the ethereumjs error without code', () => {
19+
const error = EthereumJSErrorWithoutCode(TEST_MSG)
20+
assert.equal(error.type.code, DEFAULT_ERROR_CODE)
21+
assert.equal(error.message, TEST_MSG)
2422
const object = error.toObject()
25-
assert.equal(object.type.code, 'ETHEREUMJS_UNSET_ERROR_CODE')
26-
assert.equal(object.message, 'test error')
23+
assert.equal(object.type.code, DEFAULT_ERROR_CODE)
24+
assert.equal(object.message, TEST_MSG)
2725
})
2826
})

0 commit comments

Comments
 (0)