Skip to content

Commit

Permalink
test(datetime): setting the value programmatically updates the display
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-perkins committed Nov 23, 2021
1 parent 27bd317 commit 47607a7
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
37 changes: 37 additions & 0 deletions core/src/components/datetime/test/set-value/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { newE2EPage } from '@stencil/core/testing';

describe('datetime: setting the value', () => {

it('should update the active date', async () => {
const page = await newE2EPage({
url: '/src/components/datetime/test/set-value?ionic:_testing=true'
});

await page.$eval('ion-datetime', (elm: any) => {
elm.value = '2021-11-25T12:40:00.000Z';
});

await page.waitForChanges();

const activeDate = await page.find('ion-datetime >>> .calendar-day-active');

expect(activeDate).toEqualText('25');
});

it('should update the active time', async () => {
const page = await newE2EPage({
url: '/src/components/datetime/test/set-value?ionic:_testing=true'
});

await page.$eval('ion-datetime', (elm: any) => {
elm.value = '2021-11-25T12:40:00.000Z';
});

await page.waitForChanges();

const activeTime = await page.find('ion-datetime >>> .time-body');

expect(activeTime).toEqualText('12:40 PM');
})
})

42 changes: 42 additions & 0 deletions core/src/components/datetime/test/set-value/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
<meta charset="UTF-8">
<title>Datetime - Set Value</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
<script src="../../../../../scripts/testing/scripts.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
<style>
h2 {
font-size: 12px;
font-weight: normal;

color: #6f7378;

margin-top: 10px;
margin-left: 5px;
}

ion-datetime {
width: 350px;
}
</style>
</head>

<body>
<ion-app>
<ion-header translucent="true">
<ion-toolbar>
<ion-title>Datetime - Set Value</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<ion-datetime value="2021-11-22T14:23:00.000Z"></ion-datetime>
</ion-content>
</ion-app>
</body>

</html>

0 comments on commit 47607a7

Please sign in to comment.