@@ -5,6 +5,8 @@ const { parseDictionary } = require('structured-headers')
5
5
const prepFetch = require ( 'prep-fetch' ) . default
6
6
const { createServer } = require ( '../utils' )
7
7
8
+ const dateTimeRegex = / ^ - ? \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } (?: \. \d { 3 } ) ? (?: Z | (?: \+ | - ) \d { 2 } : \d { 2 } ) $ /
9
+
8
10
const samplePath = path . join ( __dirname , '../resources' , 'sampleContainer' )
9
11
const sampleFile = fs . readFileSync ( path . join ( samplePath , 'example1.ttl' ) )
10
12
@@ -92,7 +94,8 @@ describe('Per Resource Events Protocol', function () {
92
94
const { value } = await notificationsIterator . next ( )
93
95
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
94
96
const notification = await value . json ( )
95
- expect ( notification ) . to . haveOwnProperty ( 'published' )
97
+ expect ( notification . published ) . to . match ( dateTimeRegex )
98
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
96
99
expect ( notification . type ) . to . equal ( 'Add' )
97
100
expect ( notification . target ) . to . match ( / s a m p l e C o n t a i n e r \/ e x a m p l e - p r e p \. t t l $ / )
98
101
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
@@ -111,7 +114,8 @@ solid:inserts { <u> <v> <z>. }.`
111
114
const { value } = await notificationsIterator . next ( )
112
115
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
113
116
const notification = await value . json ( )
114
- expect ( notification ) . to . haveOwnProperty ( 'published' )
117
+ expect ( notification . published ) . to . match ( dateTimeRegex )
118
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
115
119
expect ( notification . type ) . to . equal ( 'Update' )
116
120
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
117
121
} )
@@ -124,7 +128,8 @@ solid:inserts { <u> <v> <z>. }.`
124
128
const { value } = await notificationsIterator . next ( )
125
129
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
126
130
const notification = await value . json ( )
127
- expect ( notification ) . to . haveOwnProperty ( 'published' )
131
+ expect ( notification . published ) . to . match ( dateTimeRegex )
132
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
128
133
expect ( notification . type ) . to . equal ( 'Remove' )
129
134
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
130
135
expect ( notification . origin ) . to . match ( / s a m p l e C o n t a i n e r \/ .* e x a m p l e - p r e p .t t l $ / )
@@ -140,7 +145,8 @@ solid:inserts { <u> <v> <z>. }.`
140
145
const { value } = await notificationsIterator . next ( )
141
146
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
142
147
const notification = await value . json ( )
143
- expect ( notification ) . to . haveOwnProperty ( 'published' )
148
+ expect ( notification . published ) . to . match ( dateTimeRegex )
149
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
144
150
expect ( notification . type ) . to . equal ( 'Add' )
145
151
expect ( notification . target ) . to . match ( / s a m p l e C o n t a i n e r \/ e x a m p l e - p r e p \/ $ / )
146
152
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
@@ -153,7 +159,8 @@ solid:inserts { <u> <v> <z>. }.`
153
159
const { value } = await notificationsIterator . next ( )
154
160
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
155
161
const notification = await value . json ( )
156
- expect ( notification ) . to . haveOwnProperty ( 'published' )
162
+ expect ( notification . published ) . to . match ( dateTimeRegex )
163
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
157
164
expect ( notification . type ) . to . equal ( 'Remove' )
158
165
expect ( notification . origin ) . to . match ( / s a m p l e C o n t a i n e r \/ e x a m p l e - p r e p \/ $ / )
159
166
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
@@ -172,7 +179,8 @@ solid:inserts { <u> <v> <z>. }.`
172
179
const { value } = await notificationsIterator . next ( )
173
180
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
174
181
const notification = await value . json ( )
175
- expect ( notification ) . to . haveOwnProperty ( 'published' )
182
+ expect ( notification . published ) . to . match ( dateTimeRegex )
183
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
176
184
expect ( notification . type ) . to . equal ( 'Add' )
177
185
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
178
186
expect ( notification . target ) . to . match ( / s a m p l e C o n t a i n e r \/ .* e x a m p l e - p o s t \/ $ / )
@@ -191,7 +199,8 @@ solid:inserts { <u> <v> <z>. }.`
191
199
const { value } = await notificationsIterator . next ( )
192
200
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
193
201
const notification = await value . json ( )
194
- expect ( notification ) . to . haveOwnProperty ( 'published' )
202
+ expect ( notification . published ) . to . match ( dateTimeRegex )
203
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
195
204
expect ( notification . type ) . to . equal ( 'Add' )
196
205
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
197
206
expect ( notification . target ) . to . match ( / s a m p l e C o n t a i n e r \/ .* e x a m p l e - p r e p .t t l $ / )
@@ -254,7 +263,8 @@ solid:inserts { <u> <v> <z>. }.`
254
263
const { value } = await notificationsIterator . next ( )
255
264
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
256
265
const notification = await value . json ( )
257
- expect ( notification ) . to . haveOwnProperty ( 'published' )
266
+ expect ( notification . published ) . to . match ( dateTimeRegex )
267
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
258
268
expect ( notification ) . to . haveOwnProperty ( 'state' )
259
269
expect ( notification . type ) . to . equal ( 'Update' )
260
270
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ e x a m p l e - p r e p \. t t l $ / )
@@ -268,7 +278,8 @@ solid:inserts { <u> <v> <z>. }.`
268
278
const { value } = await notificationsIterator . next ( )
269
279
expect ( value . headers . get ( 'content-type' ) ) . to . match ( / a p p l i c a t i o n \/ l d \+ j s o n / )
270
280
const notification = await value . json ( )
271
- expect ( notification ) . to . haveOwnProperty ( 'published' )
281
+ expect ( notification . published ) . to . match ( dateTimeRegex )
282
+ expect ( isNaN ( ( new Date ( notification . published ) ) . valueOf ( ) ) ) . to . equal ( false )
272
283
expect ( notification ) . to . haveOwnProperty ( 'state' )
273
284
expect ( notification . type ) . to . equal ( 'Delete' )
274
285
expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ e x a m p l e - p r e p \. t t l $ / )
0 commit comments