From c933a7430ec85788b4cbeee6ce2685fb20c5cb2d Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Wed, 23 Oct 2024 19:41:57 +0530 Subject: [PATCH] test: Notification when Creating/Deleting Container in Container Added tests to check that PREP notifications are correctly emitted on a container, when a container inside it is created or deleted. --- test/integration/prep-test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/integration/prep-test.js b/test/integration/prep-test.js index bb85b541..7dea73ed 100644 --- a/test/integration/prep-test.js +++ b/test/integration/prep-test.js @@ -130,6 +130,35 @@ solid:inserts { . }.` expect(notification.origin).to.match(/sampleContainer\/.*example-prep.ttl$/) }) + it('when a contained container is created', async function () { + await fetch('http://localhost:8443/sampleContainer/example-prep/', { + method: 'PUT', + headers: { + '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.target).to.match(/sampleContainer\/example-prep\/$/) + expect(notification.object).to.match(/sampleContainer\/$/) + }) + + it('when a contained container is deleted', async function () { + await fetch('http://localhost:8443/sampleContainer/example-prep/', { + method: 'DELETE' + }) + 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('Remove') + expect(notification.origin).to.match(/sampleContainer\/example-prep\/$/) + expect(notification.object).to.match(/sampleContainer\/$/) + }) + it('when a container is created by POST', async function () { await fetch('http://localhost:8443/sampleContainer/', {