-
-
Notifications
You must be signed in to change notification settings - Fork 883
/
server-mock.spec.tsx
46 lines (34 loc) · 1.15 KB
/
server-mock.spec.tsx
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
38
39
40
41
42
43
44
45
46
import { renderToString, renderToStringAsync, renderToStream } from "../src/server-mock";
const origConsoleError = console.error;
const mockConsoleError = jest.fn();
beforeEach(() => {
console.error = mockConsoleError;
mockConsoleError.mockReset();
});
afterAll(() => {
console.error = origConsoleError;
});
test("renderToString", () => {
const result = renderToString(() => {});
const err: Error = mockConsoleError.mock.calls[0][0];
expect(err.message).toContain(
"renderToString is not supported in the browser, returning undefined"
);
expect(result).toBeUndefined();
});
test("renderToStringAsync", () => {
const result = renderToStringAsync(() => {});
const err: Error = mockConsoleError.mock.calls[0][0];
expect(err.message).toContain(
"renderToStringAsync is not supported in the browser, returning undefined"
);
expect(result).toBeUndefined();
});
test("renderToStream", () => {
const result = renderToStream(() => {});
const err: Error = mockConsoleError.mock.calls[0][0];
expect(err.message).toContain(
"renderToStream is not supported in the browser, returning undefined"
);
expect(result).toBeUndefined();
});