"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
const spy_1 = require("../spy");
const assert = (expected) => ({
    toBe: (resut) => {
        return expected === resut;
    },
    toBeTruthy: () => {
        return !!expected;
    },
    toBeFalsy: () => {
        return !expected;
    },
    toBeNull: () => {
        return expected === null;
    },
    toBeUndefined: () => {
        return expected === undefined;
    },
    toBeDefined: () => {
        return expected !== undefined;
    },
    toBeNaN: () => {
        return expected === NaN;
    },
    toMatch: (result) => {
        if (typeof expected === 'string' && typeof result === 'string') {
            if (expected.indexOf(result) !== -1) {
                return true;
            }
        }
        return false;
    },
    toContain: (result) => {
        if (Array.isArray(expected)) {
            return expected.includes(result);
        }
        return false;
    },
    toBeLessThan: (result) => {
        if (typeof expected === 'number' && typeof result === 'number') {
            return expected < result;
        }
        return false;
    },
    toBeGreaterThan: (result) => {
        if (typeof expected === 'number' && typeof result === 'number') {
            return expected > result;
        }
        return false;
    },
    toBeLessThanOrEqual: (result) => {
        if (typeof expected === 'number' && typeof result === 'number') {
            return expected <= result;
        }
        return false;
    },
    toBeGreaterThanOrEqual: (result) => {
        if (typeof expected === 'number' && typeof result === 'number') {
            return expected >= result;
        }
        return false;
    },
    toBeInstanceOf: (result) => {
        if (typeof result !== 'function') {
            return false;
        }
        if (expected instanceof result) {
            return true;
        }
        return false;
    },
    toHaveBeenCalled: () => {
        if (!(expected instanceof spy_1.Spy)) {
            return false;
        }
        if (expected.called) {
            return true;
        }
        return false;
    },
    toHaveBeenCalledWith: (...args) => {
        if (!(expected instanceof spy_1.Spy)) {
            return false;
        }
        if (!expected.calledArgs.length) {
            return false;
        }
        return expected.calledArgs.some(arg => {
            return arg.every((a, i) => a === args[i]);
        });
    },
    toThrow: () => {
        try {
            if (typeof expected === 'function') {
                expected();
            }
        }
        catch (e) {
            return true;
        }
        return false;
    }
});
exports.assert = assert;
