Skip to content

Commit 47607a7

Browse files
committed
test(datetime): setting the value programmatically updates the display
1 parent 27bd317 commit 47607a7

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { newE2EPage } from '@stencil/core/testing';
2+
3+
describe('datetime: setting the value', () => {
4+
5+
it('should update the active date', async () => {
6+
const page = await newE2EPage({
7+
url: '/src/components/datetime/test/set-value?ionic:_testing=true'
8+
});
9+
10+
await page.$eval('ion-datetime', (elm: any) => {
11+
elm.value = '2021-11-25T12:40:00.000Z';
12+
});
13+
14+
await page.waitForChanges();
15+
16+
const activeDate = await page.find('ion-datetime >>> .calendar-day-active');
17+
18+
expect(activeDate).toEqualText('25');
19+
});
20+
21+
it('should update the active time', async () => {
22+
const page = await newE2EPage({
23+
url: '/src/components/datetime/test/set-value?ionic:_testing=true'
24+
});
25+
26+
await page.$eval('ion-datetime', (elm: any) => {
27+
elm.value = '2021-11-25T12:40:00.000Z';
28+
});
29+
30+
await page.waitForChanges();
31+
32+
const activeTime = await page.find('ion-datetime >>> .time-body');
33+
34+
expect(activeTime).toEqualText('12:40 PM');
35+
})
36+
})
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Datetime - Set Value</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
8+
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
9+
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
10+
<script src="../../../../../scripts/testing/scripts.js"></script>
11+
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
12+
<style>
13+
h2 {
14+
font-size: 12px;
15+
font-weight: normal;
16+
17+
color: #6f7378;
18+
19+
margin-top: 10px;
20+
margin-left: 5px;
21+
}
22+
23+
ion-datetime {
24+
width: 350px;
25+
}
26+
</style>
27+
</head>
28+
29+
<body>
30+
<ion-app>
31+
<ion-header translucent="true">
32+
<ion-toolbar>
33+
<ion-title>Datetime - Set Value</ion-title>
34+
</ion-toolbar>
35+
</ion-header>
36+
<ion-content class="ion-padding">
37+
<ion-datetime value="2021-11-22T14:23:00.000Z"></ion-datetime>
38+
</ion-content>
39+
</ion-app>
40+
</body>
41+
42+
</html>

0 commit comments

Comments
 (0)