@@ -59,6 +59,23 @@ describe("pat-display-time tests", () => {
59
59
expect ( el . textContent ) . toBe ( "April Donnerstag 22. 2021, 4:00:00" ) ;
60
60
} ) ;
61
61
62
+ it ( "Example setting the output format explicitly in German using the lang attribute" , async ( ) => {
63
+ document . body . innerHTML = `
64
+ <time
65
+ class="pat-display-time"
66
+ datetime="2021-04-22T23:00Z"
67
+ lang="de"
68
+ data-pat-display-time="output-format: MMMM dddd Do YYYY, h:mm:ss">
69
+ </time>
70
+ ` ;
71
+ const el = document . querySelector ( ".pat-display-time" ) ;
72
+
73
+ Pattern . init ( el ) ;
74
+ await utils . timeout ( 1 ) ; // wait a tick for async to settle.
75
+
76
+ expect ( el . textContent ) . toBe ( "April Donnerstag 22. 2021, 4:00:00" ) ;
77
+ } ) ;
78
+
62
79
it ( "Example setting the output format in German due containment in German container" , async ( ) => {
63
80
document . body . innerHTML = `
64
81
<section lang="de">
@@ -139,6 +156,23 @@ describe("pat-display-time tests", () => {
139
156
expect ( el . textContent . indexOf ( "Jahre" ) >= 0 ) . toBe ( true ) ;
140
157
} ) ;
141
158
159
+ it ( "Output formatted as 'from now' with no suffix in german using the lang attribute" , async ( ) => {
160
+ document . body . innerHTML = `
161
+ <time
162
+ class="pat-display-time"
163
+ datetime="2000-04-22T10:00Z"
164
+ lang="de"
165
+ data-pat-display-time="from-now: true; no-suffix: true">
166
+ </time>
167
+ ` ;
168
+ const el = document . querySelector ( ".pat-display-time" ) ;
169
+
170
+ Pattern . init ( el ) ;
171
+ await utils . timeout ( 1 ) ; // wait a tick for async to settle.
172
+
173
+ expect ( el . textContent . indexOf ( "Jahre" ) >= 0 ) . toBe ( true ) ;
174
+ } ) ;
175
+
142
176
it ( "Formating empty datetime clears the display." , async ( ) => {
143
177
document . body . innerHTML = `
144
178
<time class="pat-display-time">
0 commit comments