-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathbullet-list.spec.ts
50 lines (43 loc) · 1.72 KB
/
bullet-list.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
38
39
40
41
42
43
44
45
46
47
48
49
50
import { expect, test } from '@playwright/test'
import { focusEditor, getMarkdown } from '../misc'
test.beforeEach(async ({ page }) => {
await page.goto('/preset-commonmark/')
})
test('bullet list', async ({ page }) => {
const editor = page.locator('.editor')
await focusEditor(page)
await page.keyboard.type('* List item 1')
await expect(editor.locator('ul li')).toHaveText('List item 1')
let markdown = await getMarkdown(page)
expect(markdown).toBe('* List item 1\n')
await page.keyboard.press('Enter')
await page.keyboard.type('List item 2')
await expect(editor.locator('ul li:last-child')).toHaveText('List item 2')
markdown = await getMarkdown(page)
expect(markdown).toBe('* List item 1\n* List item 2\n')
await page.keyboard.press('Enter')
await page.keyboard.press('Backspace')
await page.keyboard.type('- Sub list item 1')
await expect(editor.locator('ul ul li')).toHaveText('Sub list item 1')
markdown = await getMarkdown(page)
expect(markdown).toBe('* List item 1\n* List item 2\n\n * Sub list item 1\n')
await page.keyboard.press('Enter')
await page.keyboard.type('Sub list item 2')
await expect(editor.locator('ul ul li:last-child')).toHaveText(
'Sub list item 2'
)
markdown = await getMarkdown(page)
expect(markdown).toBe(
'* List item 1\n* List item 2\n\n * Sub list item 1\n * Sub list item 2\n'
)
await page.keyboard.press('Enter')
await page.keyboard.press('Enter')
await page.keyboard.type('List item 3')
await expect(editor.locator('ul:first-child>li:last-child')).toHaveText(
'List item 3'
)
markdown = await getMarkdown(page)
expect(markdown).toBe(
'* List item 1\n* List item 2\n\n * Sub list item 1\n * Sub list item 2\n* List item 3\n'
)
})