UNPKG

earljs

Version:

Ergonomic, modern and type-safe assertion library

43 lines (42 loc) 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadMatchers = exports.expect = void 0; const Expectation_1 = require("./Expectation"); const matchers_1 = require("./matchers"); const ArrayOfLength_1 = require("./matchers/ArrayOfLength"); const ObjectWith_1 = require("./matchers/ObjectWith"); /** * The `expect` function is used every time you want to test a value. * * @param actual - the value to match against. * @param options - optional configuration. */ const expect = (actual, options = {}) => { return Expectation_1.__ExpectationImplementation.make(actual, false, options); }; exports.expect = expect; exports.expect.anything = matchers_1.AnythingMatcher.make; exports.expect.a = matchers_1.AMatcher.make; exports.expect.stringMatching = matchers_1.StringMatchingMatcher.make; exports.expect.numberCloseTo = matchers_1.NumberCloseToMatcher.make; exports.expect.containerWith = matchers_1.ContainerWithMatcher.make; exports.expect.arrayOfLength = ArrayOfLength_1.ArrayOfLengthMatcher.make; exports.expect.arrayWith = matchers_1.ArrayWithMatcher.make; exports.expect.objectWith = ObjectWith_1.ObjectWithMatcher.make; exports.expect.numberGreaterThan = matchers_1.NumberGreaterThanMatcher.make; exports.expect.numberGreaterThanOrEqualTo = matchers_1.NumberGreaterThanOrEqualToMatcher.make; exports.expect.numberLessThan = matchers_1.NumberLessThanMatcher.make; exports.expect.numberLessThanOrEqualTo = matchers_1.NumberLessThanOrEqualToMatcher.make; exports.expect.truthy = matchers_1.TruthyMatcher.make; exports.expect.falsy = matchers_1.FalsyMatcher.make; exports.expect.defined = matchers_1.DefinedMatcher.make; exports.expect.nullish = matchers_1.NullishMatcher.make; // dynamically load new matchers and attach to expect object // used by plugin loader function loadMatchers(matchers) { for (const [name, matcher] of Object.entries(matchers)) { ; exports.expect[name] = matcher; } } exports.loadMatchers = loadMatchers;