|
| 1 | +// sum.test.js |
| 2 | +import { expect, test } from "vitest"; |
| 3 | +import { diff } from "."; |
| 4 | + |
| 5 | +test("Test diff", () => { |
| 6 | + let d = diff( |
| 7 | + "Building mr concerns servants in he outlived am breeding.", |
| 8 | + "Building mr conc srvvants i he o am breed." |
| 9 | + ); |
| 10 | + let expected = { |
| 11 | + diff: [ |
| 12 | + { value: "B", type: "correct" }, |
| 13 | + { value: "u", type: "correct" }, |
| 14 | + { value: "i", type: "correct" }, |
| 15 | + { value: "l", type: "correct" }, |
| 16 | + { value: "d", type: "correct" }, |
| 17 | + { value: "i", type: "correct" }, |
| 18 | + { value: "n", type: "correct" }, |
| 19 | + { value: "g", type: "correct" }, |
| 20 | + { value: " ", type: "spacer" }, |
| 21 | + { value: "m", type: "correct" }, |
| 22 | + { value: "r", type: "correct" }, |
| 23 | + { value: " ", type: "spacer" }, |
| 24 | + { value: "c", type: "correct" }, |
| 25 | + { value: "o", type: "correct" }, |
| 26 | + { value: "n", type: "correct" }, |
| 27 | + { value: "c", type: "correct" }, |
| 28 | + { value: "e", type: "missing" }, |
| 29 | + { value: "r", type: "missing" }, |
| 30 | + { value: "n", type: "missing" }, |
| 31 | + { value: "s", type: "missing" }, |
| 32 | + { value: " ", type: "spacer" }, |
| 33 | + { value: "s", type: "correct" }, |
| 34 | + { value: "r", type: "wrong" }, |
| 35 | + { value: "v", type: "wrong" }, |
| 36 | + { value: "v", type: "correct" }, |
| 37 | + { value: "a", type: "correct" }, |
| 38 | + { value: "n", type: "correct" }, |
| 39 | + { value: "t", type: "correct" }, |
| 40 | + { value: "s", type: "correct" }, |
| 41 | + { value: " ", type: "spacer" }, |
| 42 | + { value: "i", type: "correct" }, |
| 43 | + { value: "n", type: "missing" }, |
| 44 | + { value: " ", type: "spacer" }, |
| 45 | + { value: "h", type: "correct" }, |
| 46 | + { value: "e", type: "correct" }, |
| 47 | + { value: " ", type: "spacer" }, |
| 48 | + { value: "o", type: "correct" }, |
| 49 | + { value: "u", type: "missing" }, |
| 50 | + { value: "t", type: "missing" }, |
| 51 | + { value: "l", type: "missing" }, |
| 52 | + { value: "i", type: "missing" }, |
| 53 | + { value: "v", type: "missing" }, |
| 54 | + { value: "e", type: "missing" }, |
| 55 | + { value: "d", type: "missing" }, |
| 56 | + { value: " ", type: "spacer" }, |
| 57 | + { value: "a", type: "correct" }, |
| 58 | + { value: "m", type: "correct" }, |
| 59 | + { value: " ", type: "spacer" }, |
| 60 | + { value: "b", type: "correct" }, |
| 61 | + { value: "r", type: "correct" }, |
| 62 | + { value: "e", type: "correct" }, |
| 63 | + { value: "e", type: "correct" }, |
| 64 | + { value: "d", type: "correct" }, |
| 65 | + { value: ".", type: "wrong" }, |
| 66 | + { value: "n", type: "untouched" }, |
| 67 | + { value: "g", type: "untouched" }, |
| 68 | + { value: ".", type: "untouched" }, |
| 69 | + { value: " ", type: "spacer" }, |
| 70 | + ], |
| 71 | + end: false, |
| 72 | + }; |
| 73 | + expect(d).toStrictEqual(expected); |
| 74 | +}); |
0 commit comments