-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdiff-test.spec.ts
37 lines (31 loc) · 930 Bytes
/
diff-test.spec.ts
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
34
35
36
37
import * as difflib from "difflib";
import { MatchesSnapshot } from "../src/index";
declare var fail: (message: string) => void;
declare var console: any;
describe("diff test", () =>
{
let lastFailedWith = "";
let consoleErrorCalled = 0;
beforeAll(() =>
{
fail = (message: string) => lastFailedWith = message;
let old_console = console.error;
console.error = (error: string) => { consoleErrorCalled++; old_console(error); };
});
beforeEach(() =>
{
lastFailedWith = "";
consoleErrorCalled = 0;
});
it("matches simple string", () =>
{
MatchesSnapshot("greg", "greg");
expect(lastFailedWith).toBe("");
});
it("fails with diff", () =>
{
MatchesSnapshot("tyler", "moose");
expect(lastFailedWith).toBe("Actual does not match snapshot. See above. ");
expect(consoleErrorCalled).toBe(1);
});
});