@@ -5,6 +5,8 @@ const { parseDictionary } = require('structured-headers')
55const prepFetch = require ( 'prep-fetch' ) . default
66const { createServer } = require ( '../utils' )
77
8+ const dateTimeRegex = / ^ - ? \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } (?: \. \d { 3 } ) ? (?: Z | (?: \+ | - ) \d { 2 } : \d { 2 } ) $ /
9+
810const samplePath = path . join ( __dirname , '../resources' , 'sampleContainer' )
911const sampleFile = fs . readFileSync ( path . join ( samplePath , 'example1.ttl' ) )
1012
@@ -92,7 +94,8 @@ describe('Per Resource Events Protocol', function () {
9294 const { value } = await notificationsIterator . next ( )
9395 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 / )
9496 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 )
9699 expect ( notification . type ) . to . equal ( 'Add' )
97100 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 $ / )
98101 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>. }.`
111114 const { value } = await notificationsIterator . next ( )
112115 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 / )
113116 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 )
115119 expect ( notification . type ) . to . equal ( 'Update' )
116120 expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
117121 } )
@@ -124,7 +128,8 @@ solid:inserts { <u> <v> <z>. }.`
124128 const { value } = await notificationsIterator . next ( )
125129 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 / )
126130 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 )
128133 expect ( notification . type ) . to . equal ( 'Remove' )
129134 expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
130135 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>. }.`
140145 const { value } = await notificationsIterator . next ( )
141146 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 / )
142147 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 )
144150 expect ( notification . type ) . to . equal ( 'Add' )
145151 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 \/ $ / )
146152 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>. }.`
153159 const { value } = await notificationsIterator . next ( )
154160 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 / )
155161 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 )
157164 expect ( notification . type ) . to . equal ( 'Remove' )
158165 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 \/ $ / )
159166 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>. }.`
172179 const { value } = await notificationsIterator . next ( )
173180 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 / )
174181 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 )
176184 expect ( notification . type ) . to . equal ( 'Add' )
177185 expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
178186 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>. }.`
191199 const { value } = await notificationsIterator . next ( )
192200 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 / )
193201 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 )
195204 expect ( notification . type ) . to . equal ( 'Add' )
196205 expect ( notification . object ) . to . match ( / s a m p l e C o n t a i n e r \/ $ / )
197206 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>. }.`
254263 const { value } = await notificationsIterator . next ( )
255264 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 / )
256265 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 )
258268 expect ( notification ) . to . haveOwnProperty ( 'state' )
259269 expect ( notification . type ) . to . equal ( 'Update' )
260270 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>. }.`
268278 const { value } = await notificationsIterator . next ( )
269279 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 / )
270280 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 )
272283 expect ( notification ) . to . haveOwnProperty ( 'state' )
273284 expect ( notification . type ) . to . equal ( 'Delete' )
274285 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