-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
test.tsx
63 lines (53 loc) · 1.29 KB
/
test.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import process from 'node:process';
import test from 'ava';
import React, {type FC as ReactFC, type ReactNode} from 'react';
import {Text} from 'ink';
import {render} from 'ink-testing-library';
import Link from './source/index.js';
test.afterEach(() => {
delete process.env.FORCE_HYPERLINK;
});
test('render', t => {
if (process.env.CI) {
t.pass();
return;
}
process.env.FORCE_HYPERLINK = 1;
const {lastFrame} = render(
<Link url='https://sindresorhus.com'>
My{' '}<Text color='green'>Website</Text>
</Link>,
);
console.log(lastFrame());
t.snapshot(lastFrame());
});
test('render fallback', t => {
process.env.FORCE_HYPERLINK = 0;
const {lastFrame} = render(
<Link url='https://sindresorhus.com'>
My Website
</Link>,
);
console.log(lastFrame());
t.snapshot(lastFrame());
});
test('exclude fallback if disabled', t => {
process.env.FORCE_HYPERLINK = 0;
const {lastFrame} = render(
<Link url='https://sindresorhus.com' fallback={false}>
My Website
</Link>,
);
console.log(lastFrame());
t.snapshot(lastFrame());
});
test('include fallback if explicitly enabled', t => {
process.env.FORCE_HYPERLINK = 0;
const {lastFrame} = render(
<Link fallback url='https://sindresorhus.com'>
My Website
</Link>,
);
console.log(lastFrame());
t.snapshot(lastFrame());
});