Skip to content

Commit b9c0908

Browse files
author
Jason Smith
committed
Add test for the unix timestamp presentation, went ahead and filled out the other missing test too.
1 parent 1063fbf commit b9c0908

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

elements/rh-datetime/test/rh-datetime_test.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
Mon Jan 2 15:04:05 EST 2006
8585
</rh-datetime>
8686

87+
<rh-datetime
88+
id="simpleUnixtime"
89+
timestamp="1136171045">
90+
Mon Jan 2 15:04:05 EST 2006
91+
</rh-datetime>
92+
8793
<script>
8894
suite('<rh-datetime>', () => {
8995
test('it should upgrade', () => {
@@ -120,12 +126,22 @@
120126
const text = element.shadowRoot.querySelector('span').textContent;
121127

122128
assert.match(text, /\d+ years ago/, "should show a relative time since the date");
123-
})
129+
});
130+
131+
test('unix timestamp should convert and display properly', () => {
132+
const element = document.getElementById('yearsago');
133+
const text = element.shadowRoot.querySelector('span').textContent;
134+
135+
assert.match(text, '1/2/2006', "should show a relative time since the date");
136+
});
124137

125138
test('it should show a formatted date with time for a different locale', () => {
139+
const element = document.getElementById('esLocale');
140+
const text = element.shadowRoot.querySelector('span').textContent;
126141

142+
assert.match(text, 'Monday, 02 Jan 2006, 15:04:05', "should show a (locally) formatted date with time");
127143
});
128-
});
144+
})
129145
</script>
130146
</body>
131147
</html>

0 commit comments

Comments
 (0)