assertsjs
Version:
ECMA6 Module for Javascript type validations
22 lines (20 loc) • 806 B
JavaScript
jest.unmock('./../../src/Asserts');
describe('Asserts.assertFunction tests', () => {
it('Asserts.assertFunction should return the value', () => {
const Asserts = require('./../../src/Asserts');
const aFunction = function (arg) {
console.log(arg);
};
expect(aFunction).toBe(Asserts.assertFunction(aFunction));
});
it('Asserts.assertFunction should return an error', () => {
const Asserts = require('./../../src/Asserts');
const notFunction = 'Im a string';
const expectedMessageError = 'Assertion error: function must be provided';
try {
Asserts.assertFunction(notFunction);
} catch (error) {
expect(expectedMessageError).toBe(error.message);
}
});
});