Skip to content

Commit 76f324d

Browse files
authored
feat(calendar): add year and month specification demo and tests (#3039)
1 parent 0a7f0c6 commit 76f324d

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<tiny-calendar :year="2000" :month="5" />
3+
</template>
4+
5+
<script setup>
6+
import { TinyCalendar } from '@opentiny/vue'
7+
</script>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('日历年月显示测试', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
5+
await page.goto('calendar#calendar-year-month')
6+
const pcDemo = page.locator('.pc-demo')
7+
8+
// 验证初始化年月是否正确(2000年5月)
9+
await expect(pcDemo.locator('.tiny-calendar__tool input').first()).toHaveValue('2000年')
10+
await expect(pcDemo.locator('.tiny-calendar__tool input').nth(1)).toHaveValue('5 月')
11+
12+
// 验证年份视图下的月份显示
13+
await pcDemo.locator('.tiny-calendar__tabs').getByText('年').click()
14+
await expect(pcDemo.locator('.tiny-calendar__tool input').first()).toHaveValue('2000年')
15+
await expect(pcDemo.getByRole('cell', { name: '5 月' }).locator('div').first()).toHaveClass(/selected/)
16+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<tiny-calendar :year="2000" :month="5" />
3+
</template>
4+
5+
<script>
6+
import { TinyCalendar } from '@opentiny/vue'
7+
8+
export default {
9+
components: {
10+
TinyCalendar
11+
}
12+
}
13+
</script>

examples/sites/demos/pc/app/calendar/webdoc/calendar.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ export default {
4141
},
4242
codeFiles: ['show-selected-date.vue']
4343
},
44+
{
45+
demoId: 'calendar-year-month',
46+
name: {
47+
'zh-CN': '指定年月',
48+
'en-US': 'Specify Month and Year'
49+
},
50+
desc: {
51+
'zh-CN': '<p>通过 <code>year</code> 属性指定年份,通过 <code>month</code> 属性指定月份。</p>\n',
52+
'en-US':
53+
'<p>Specify the year through the <code>year</code> attribute and the month through the <code>month</code> attribute. </p>\n'
54+
},
55+
codeFiles: ['calendar-year-month.vue']
56+
},
4457
{
4558
demoId: 'custom-day-cell',
4659
name: {

0 commit comments

Comments
 (0)