Skip to content

Commit

Permalink
test(transducers): add fuzzy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed May 14, 2018
1 parent fc6acd1 commit 37362dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/transducers/test/fuzzy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as tx from "../src";

import * as assert from "assert";

describe("fuzzy", () => {
it("strings", () => {
const opts = ["hello", "hallo", "hey", "heyoka"];
assert.deepEqual(tx.transduce(tx.filterFuzzy("hl"), tx.push(), opts), ["hello", "hallo"]);
assert.deepEqual(tx.transduce(tx.filterFuzzy("he"), tx.push(), opts), ["hello", "hey", "heyoka"]);
assert.deepEqual(tx.transduce(tx.filterFuzzy("ho"), tx.push(), opts), ["hello", "hallo", "heyoka"]);
assert.deepEqual(tx.transduce(tx.filterFuzzy("hey"), tx.push(), opts), ["hey", "heyoka"]);
assert.deepEqual(tx.transduce(tx.filterFuzzy("hk"), tx.push(), opts), ["heyoka"]);
});
it("arrays", () => {
const opts = [[1, 2, 3], [1, 3, 4], [4, 5, 6], [1, 3, 6]];
assert.deepEqual(tx.transduce(tx.filterFuzzy([1, 3]), tx.push(), opts), [[1, 2, 3], [1, 3, 4], [1, 3, 6]]);
assert.deepEqual(tx.transduce(tx.filterFuzzy([4]), tx.push(), opts), [[1, 3, 4], [4, 5, 6]]);
assert.deepEqual(tx.transduce(tx.filterFuzzy([3, 6]), tx.push(), opts), [[1, 3, 6]]);
assert.deepEqual(tx.transduce(tx.filterFuzzy([]), tx.push(), opts), opts);
});
});

0 comments on commit 37362dd

Please sign in to comment.