deno.land / std@0.224.0 / text / word_similarity_sort_test.ts
123456789101112131415161718192021222324252627282930313233// 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)), "[]", );});
Version Info