mirror of
https://github.com/denoland/deno.git
synced 2024-10-31 09:14:20 -04:00
caa383a583
After some discussion it was found that assertEquals is more common
in JS (vs assertEqual, assertEq) and sounds better in the negated form:
assertNotEquals vs assertNE.
Original: 4cf39d4a14
111 lines
2.4 KiB
TypeScript
111 lines
2.4 KiB
TypeScript
import diff from "./diff.ts";
|
|
import { assertEquals } from "../testing/asserts.ts";
|
|
import { test } from "./mod.ts";
|
|
|
|
test({
|
|
name: "empty",
|
|
fn() {
|
|
assertEquals(diff([], []), []);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"a" vs "b"',
|
|
fn() {
|
|
assertEquals(diff(["a"], ["b"]), [
|
|
{ type: "removed", value: "a" },
|
|
{ type: "added", value: "b" }
|
|
]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"a" vs "a"',
|
|
fn() {
|
|
assertEquals(diff(["a"], ["a"]), [{ type: "common", value: "a" }]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"a" vs ""',
|
|
fn() {
|
|
assertEquals(diff(["a"], []), [{ type: "removed", value: "a" }]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"" vs "a"',
|
|
fn() {
|
|
assertEquals(diff([], ["a"]), [{ type: "added", value: "a" }]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"a" vs "a, b"',
|
|
fn() {
|
|
assertEquals(diff(["a"], ["a", "b"]), [
|
|
{ type: "common", value: "a" },
|
|
{ type: "added", value: "b" }
|
|
]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"strength" vs "string"',
|
|
fn() {
|
|
assertEquals(diff(Array.from("strength"), Array.from("string")), [
|
|
{ type: "common", value: "s" },
|
|
{ type: "common", value: "t" },
|
|
{ type: "common", value: "r" },
|
|
{ type: "removed", value: "e" },
|
|
{ type: "added", value: "i" },
|
|
{ type: "common", value: "n" },
|
|
{ type: "common", value: "g" },
|
|
{ type: "removed", value: "t" },
|
|
{ type: "removed", value: "h" }
|
|
]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"strength" vs ""',
|
|
fn() {
|
|
assertEquals(diff(Array.from("strength"), Array.from("")), [
|
|
{ type: "removed", value: "s" },
|
|
{ type: "removed", value: "t" },
|
|
{ type: "removed", value: "r" },
|
|
{ type: "removed", value: "e" },
|
|
{ type: "removed", value: "n" },
|
|
{ type: "removed", value: "g" },
|
|
{ type: "removed", value: "t" },
|
|
{ type: "removed", value: "h" }
|
|
]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"" vs "strength"',
|
|
fn() {
|
|
assertEquals(diff(Array.from(""), Array.from("strength")), [
|
|
{ type: "added", value: "s" },
|
|
{ type: "added", value: "t" },
|
|
{ type: "added", value: "r" },
|
|
{ type: "added", value: "e" },
|
|
{ type: "added", value: "n" },
|
|
{ type: "added", value: "g" },
|
|
{ type: "added", value: "t" },
|
|
{ type: "added", value: "h" }
|
|
]);
|
|
}
|
|
});
|
|
|
|
test({
|
|
name: '"abc", "c" vs "abc", "bcd", "c"',
|
|
fn() {
|
|
assertEquals(diff(["abc", "c"], ["abc", "bcd", "c"]), [
|
|
{ type: "common", value: "abc" },
|
|
{ type: "added", value: "bcd" },
|
|
{ type: "common", value: "c" }
|
|
]);
|
|
}
|
|
});
|