Update tests to use jest (#11)

This commit is contained in:
Jaco Greeff
2017-11-21 21:28:20 +01:00
committed by GitHub
parent c4d7aba961
commit 87dd31f72a
17 changed files with 2633 additions and 483 deletions
+6 -8
View File
@@ -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/);
});
});
});