Skip to content

Commit 35ebbca

Browse files
committed
add basic test
1 parent d066627 commit 35ebbca

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/index.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { parseStyles, styleByIndex, styleBySearch } from './index';
2+
3+
test('correctly parses styles', () => {
4+
expect(
5+
parseStyles(`This should be *bold*
6+
and this _should italics_ be`)
7+
).toStrictEqual([
8+
{ content: 'This should be', line: 0, style: 'regular' },
9+
{ content: 'bold', line: 0, style: 'bold' },
10+
{ content: 'and this', line: 1, style: 'regular' },
11+
{ content: 'should italics', line: 1, style: 'italics' },
12+
{ content: 'be', line: 1, style: 'regular' },
13+
]);
14+
});
15+
16+
test('correctly styles by search', () => {
17+
expect(
18+
styleBySearch(
19+
`This should be bold
20+
and this should italics be`,
21+
{ boldString: 'bold', italicsString: 'should italics' }
22+
)
23+
).toStrictEqual([
24+
{ content: 'This should be', line: 0, style: 'regular' },
25+
{ content: 'bold', line: 0, style: 'bold' },
26+
{ content: 'and this', line: 1, style: 'regular' },
27+
{ content: 'should italics', line: 1, style: 'italics' },
28+
{ content: 'be', line: 1, style: 'regular' },
29+
]);
30+
});
31+
32+
test('correctly styles by index', () => {
33+
expect(
34+
styleByIndex(
35+
`This should be bold
36+
and this italics be`,
37+
{ boldIndexes: [3], italicsIndexes: [6] }
38+
)
39+
).toStrictEqual([
40+
{ content: 'This should be', line: 0, style: 'regular' },
41+
{ content: 'bold', line: 0, style: 'bold' },
42+
{ content: 'and this', line: 1, style: 'regular' },
43+
{ content: 'should italics', line: 1, style: 'italics' },
44+
{ content: 'be', line: 1, style: 'regular' },
45+
]);
46+
});

0 commit comments

Comments
 (0)