Skip to content

Commit

Permalink
test: Notification when Creating a Container with POST
Browse files Browse the repository at this point in the history
Added a test to check that a PREP notification is correctly emitted when a container is created with POST.
  • Loading branch information
CxRes committed Oct 23, 2024
1 parent 2a277ff commit d08a88f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/integration/prep-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Per Resource Events Protocol', function () {
})

after(() => {
fs.rmSync(path.join(samplePath, 'example-post'), { recursive: true })
server.close()
})

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

it('when a container is created by POST',
async function () {
await fetch('http://localhost:8443/sampleContainer/', {
method: 'POST',
headers: {
slug: 'example-post',
link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
'content-type': 'text/turtle'
}
})
const { value } = await notificationsIterator.next()
expect(value.headers.get('content-type')).to.match(/application\/ld\+json/)
const notification = await value.json()
expect(notification).to.haveOwnProperty('published')
expect(notification.type).to.equal('Add')
expect(notification.object).to.match(/sampleContainer\/$/)
expect(notification.target).to.match(/sampleContainer\/.*example-post\/$/)
})

it('when resource is created by POST',
async function () {
await fetch('http://localhost:8443/sampleContainer/', {
Expand Down

0 comments on commit d08a88f

Please sign in to comment.