deno.land / std@0.224.0 / text / word_similarity_sort_test.ts

word_similarity_sort_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assertEquals } from "../assert/mod.ts";import { wordSimilaritySort } from "./word_similarity_sort.ts";
Deno.test("wordSimilaritySort() handles basic example", function () { const possibleWords: string[] = ["length", "size", "blah", "help"]; const badArg = "hep"; assertEquals( wordSimilaritySort(badArg, possibleWords).join(", "), "help, size, blah, length", );});
Deno.test("wordSimilaritySort() handles empty string", function () { const possibleWords: string[] = ["length", "size", "blah", "help", ""]; const badArg = "";
assertEquals( JSON.stringify(wordSimilaritySort(badArg, possibleWords)), JSON.stringify(["", "size", "blah", "help", "length"]), );});
Deno.test("wordSimilaritySort() handles empty array", function () { const possibleWords: string[] = []; const badArg = "";
assertEquals( JSON.stringify(wordSimilaritySort(badArg, possibleWords)), "[]", );});
std

Version Info

Tagged at
6 months ago