Skip to content

Commit bcc718d

Browse files
committedNov 4, 2021
Add tests
1 parent bda86ef commit bcc718d

File tree

173 files changed

+26601
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+26601
-14
lines changed
 

‎scripts/generate-tests

+27-14
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,32 @@ if ask "Are you sure?"; then
3737
for width in 10 20 40 60 80
3838
do
3939
echo "Copying cli-*-100.js to cli-$width.js"
40-
rm test/cli-$width-soft.js 2>/dev/null
41-
rm test/cli-$width-soft-tabbed.js 2>/dev/null
42-
rm test/cli-$width-hard.js 2>/dev/null
43-
rm test/cli-$width-hard-tabbed.js 2>/dev/null
44-
rm test/cli-$width-keep.js 2>/dev/null
45-
rm test/cli-$width-panel.js 2>/dev/null
46-
rm test/cli-$width-stamp.js 2>/dev/null
47-
cp test/cli-100-soft.js test/cli-$width-soft.js
48-
cp test/cli-100-soft-tabbed.js test/cli-$width-soft-tabbed.js
49-
cp test/cli-100-hard.js test/cli-$width-hard.js
50-
cp test/cli-100-hard-tabbed.js test/cli-$width-hard-tabbed.js
51-
cp test/cli-100-keep.js test/cli-$width-keep.js
52-
cp test/cli-100-panel.js test/cli-$width-panel.js
53-
cp test/cli-100-stamp.js test/cli-$width-stamp.js
40+
rm test/stream-$width-soft.js 2>/dev/null
41+
rm test/stream-$width-soft-tabbed.js 2>/dev/null
42+
rm test/stream-$width-hard.js 2>/dev/null
43+
rm test/stream-$width-hard-tabbed.js 2>/dev/null
44+
rm test/stream-$width-keep.js 2>/dev/null
45+
rm test/stream-$width-panel.js 2>/dev/null
46+
rm test/stream-$width-stamp.js 2>/dev/null
47+
cp test/stream-100-soft.js test/stream-$width-soft.js
48+
cp test/stream-100-soft-tabbed.js test/stream-$width-soft-tabbed.js
49+
cp test/stream-100-hard.js test/stream-$width-hard.js
50+
cp test/stream-100-hard-tabbed.js test/stream-$width-hard-tabbed.js
51+
cp test/stream-100-keep.js test/stream-$width-keep.js
52+
cp test/stream-100-panel.js test/stream-$width-panel.js
53+
54+
rm test/direct-$width-soft.js 2>/dev/null
55+
rm test/direct-$width-soft-tabbed.js 2>/dev/null
56+
rm test/direct-$width-hard.js 2>/dev/null
57+
rm test/direct-$width-hard-tabbed.js 2>/dev/null
58+
rm test/direct-$width-keep.js 2>/dev/null
59+
rm test/direct-$width-panel.js 2>/dev/null
60+
rm test/direct-$width-stamp.js 2>/dev/null
61+
cp test/direct-100-soft.js test/direct-$width-soft.js
62+
cp test/direct-100-soft-tabbed.js test/direct-$width-soft-tabbed.js
63+
cp test/direct-100-hard.js test/direct-$width-hard.js
64+
cp test/direct-100-hard-tabbed.js test/direct-$width-hard-tabbed.js
65+
cp test/direct-100-keep.js test/direct-$width-keep.js
66+
cp test/direct-100-panel.js test/direct-$width-panel.js
5467
done
5568
fi

‎test/direct-10-hard-tabbed.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {basename} from 'node:path'
2+
import {fileURLToPath} from 'node:url'
3+
import {readFileSync} from 'node:fs'
4+
import test from 'ava'
5+
import {truwrap} from '../index.js'
6+
7+
const width = basename(fileURLToPath(import.meta.url), '.js').split('-')[1] // 10, 20, 40, 60, 80, 100
8+
9+
const tabbed = readFileSync('test/fixtures/in/tabbed.txt').toString()
10+
11+
for (const right of [0, 1, 5]) {
12+
for (const left of [0, 1, 2, 5, 10]) {
13+
test(`Direct: Hard wrap tabbed source to w${width} l${left} r${right}`, t => {
14+
const renderer = truwrap({
15+
left,
16+
right,
17+
width,
18+
mode: 'hard',
19+
})
20+
renderer.write(tabbed)
21+
t.snapshot(renderer.end())
22+
})
23+
}
24+
}

0 commit comments

Comments
 (0)
Please sign in to comment.