ts-prime
Version:
A utility library for JavaScript and Typescript.
31 lines (30 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var findIndex_1 = require("./findIndex");
var pipe_1 = require("./pipe");
var _counter_1 = require("./_counter");
describe('data first', function () {
test('findIndex', function () {
expect(findIndex_1.findIndex([10, 20, 30], function (x) { return x === 20; })).toBe(1);
});
test('findIndex.indexed', function () {
expect(findIndex_1.findIndex([10, 20, 30], function (x) { return x === 20; })).toBe(1);
});
test('findIndex -1', function () {
expect(findIndex_1.findIndex([2, 3, 4], function (x) { return x === 20; })).toBe(-1);
});
});
describe('data last', function () {
test('findIndex', function () {
var counter = _counter_1.createCounter();
var actual = pipe_1.pipe([10, 20, 30], counter.fn(), findIndex_1.findIndex(function (x) { return x === 20; }));
expect(counter.count).toHaveBeenCalledTimes(2);
expect(actual).toEqual(1);
});
test('findIndex.indexed', function () {
var counter = _counter_1.createCounter();
var actual = pipe_1.pipe([10, 20, 30], counter.fn(), findIndex_1.findIndex.indexed(function (x) { return x === 20; }));
expect(counter.count).toHaveBeenCalledTimes(2);
expect(actual).toEqual(1);
});
});