Update tests to use jest (#11)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// ISC, Copyright 2017 Jaco Greeff
|
||||
|
||||
/* eslint-disable no-unused-expressions */
|
||||
|
||||
const { bufferFromHex, bufferToHex } = require('./');
|
||||
|
||||
describe('buffer', () => {
|
||||
@@ -9,7 +7,7 @@ describe('buffer', () => {
|
||||
it('returns an empty buffer when null provided', () => {
|
||||
expect(
|
||||
bufferFromHex(null).length
|
||||
).to.equal(0);
|
||||
).toEqual(0);
|
||||
});
|
||||
|
||||
it('returns a buffer with the correct values', () => {
|
||||
@@ -17,13 +15,13 @@ describe('buffer', () => {
|
||||
Buffer.from([128, 0, 10]).equals(
|
||||
bufferFromHex('0x80000a')
|
||||
)
|
||||
).to.be.true;
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('throws error on non-hex inputs', () => {
|
||||
expect(
|
||||
() => bufferFromHex('notAHex')
|
||||
).to.throw(/Cannot convert non-hex value/);
|
||||
).toThrow(/Cannot convert non-hex value/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,19 +29,19 @@ describe('buffer', () => {
|
||||
it('returns 0x when the buffer is null', () => {
|
||||
expect(
|
||||
bufferToHex(null)
|
||||
).to.equal('0x');
|
||||
).toEqual('0x');
|
||||
});
|
||||
|
||||
it('returns the hex value for the buffer', () => {
|
||||
expect(
|
||||
bufferToHex(Buffer.from([128, 0, 10]))
|
||||
).to.equal('0x80000a');
|
||||
).toEqual('0x80000a');
|
||||
});
|
||||
|
||||
it('throws when non-buffer value is supplied', () => {
|
||||
expect(
|
||||
() => bufferToHex('noABuffer')
|
||||
).to.throw(/Cannot convert non-buffer/);
|
||||
).toThrow(/Cannot convert non-buffer/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user