Skip to content

Commit d08a88f

Browse files
committed
test: Notification when Creating a Container with POST
Added a test to check that a PREP notification is correctly emitted when a container is created with POST.
1 parent 2a277ff commit d08a88f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/integration/prep-test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('Per Resource Events Protocol', function () {
2424
})
2525

2626
after(() => {
27+
fs.rmSync(path.join(samplePath, 'example-post'), { recursive: true })
2728
server.close()
2829
})
2930

@@ -129,6 +130,25 @@ solid:inserts { <u> <v> <z>. }.`
129130
expect(notification.origin).to.match(/sampleContainer\/.*example-prep.ttl$/)
130131
})
131132

133+
it('when a container is created by POST',
134+
async function () {
135+
await fetch('http://localhost:8443/sampleContainer/', {
136+
method: 'POST',
137+
headers: {
138+
slug: 'example-post',
139+
link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
140+
'content-type': 'text/turtle'
141+
}
142+
})
143+
const { value } = await notificationsIterator.next()
144+
expect(value.headers.get('content-type')).to.match(/application\/ld\+json/)
145+
const notification = await value.json()
146+
expect(notification).to.haveOwnProperty('published')
147+
expect(notification.type).to.equal('Add')
148+
expect(notification.object).to.match(/sampleContainer\/$/)
149+
expect(notification.target).to.match(/sampleContainer\/.*example-post\/$/)
150+
})
151+
132152
it('when resource is created by POST',
133153
async function () {
134154
await fetch('http://localhost:8443/sampleContainer/', {

0 commit comments

Comments
 (0)