-
-
Notifications
You must be signed in to change notification settings - Fork 430
/
Copy pathordered-list.spec.ts
52 lines (45 loc) · 1.74 KB
/
ordered-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
51
52
import { expect, test } from '@playwright/test'
import { focusEditor, getMarkdown } from '../misc'
test.beforeEach(async ({ page }) => {
await page.goto('/preset-commonmark/')
})
test('ordered list', async ({ page }) => {
const editor = page.locator('.editor')
await focusEditor(page)
await page.keyboard.type('1. First item')
await expect(editor.locator('ol li')).toHaveText('First item')
let markdown = await getMarkdown(page)
expect(markdown).toBe('1. First item\n')
await page.keyboard.press('Enter')
await page.keyboard.type('Second item')
await expect(editor.locator('ol li:last-child')).toHaveText('Second item')
markdown = await getMarkdown(page)
expect(markdown).toBe('1. First item\n2. Second item\n')
await page.keyboard.press('Enter')
await page.keyboard.press('Backspace')
await page.keyboard.type('1. Sub list item 1')
await expect(editor.locator('ol ol li')).toHaveText('Sub list item 1')
markdown = await getMarkdown(page)
expect(markdown).toBe(
'1. First item\n2. Second item\n\n 1. Sub list item 1\n'
)
await page.keyboard.press('Enter')
await page.keyboard.type('Sub list item 2')
await expect(editor.locator('ol ol li:last-child')).toHaveText(
'Sub list item 2'
)
markdown = await getMarkdown(page)
expect(markdown).toBe(
'1. First item\n2. Second item\n\n 1. Sub list item 1\n 2. Sub list item 2\n'
)
await page.keyboard.press('Enter')
await page.keyboard.press('Enter')
await page.keyboard.type('Third item')
await expect(editor.locator('ol:first-child>li:last-child')).toHaveText(
'Third item'
)
markdown = await getMarkdown(page)
expect(markdown).toBe(
'1. First item\n2. Second item\n\n 1. Sub list item 1\n 2. Sub list item 2\n3. Third item\n'
)
})