tiny-vue/examples/docs/resources/pc/demo/numeric/about-step.spec.ts

18 lines
740 B
TypeScript

import { test, expect } from '@playwright/test'
test('步长', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('http://localhost:7130/pc/numeric/about-step')
const input = page.getByRole('spinbutton')
const increaseBtn = page.locator('#preview .tiny-numeric__increase')
const decreaseBtn = page.locator('#preview .tiny-numeric__decrease')
const value = Number(await input.inputValue())
const step = 2
await decreaseBtn.click()
const decreasedVal = Number(await input.inputValue())
expect(value).toEqual(decreasedVal + step)
await increaseBtn.click()
const increasedVal = Number(await input.inputValue())
expect(decreasedVal).toEqual(increasedVal - step)
})