From 2d241f99ddf4b7a54be0e5976a6314e43d6a46ed Mon Sep 17 00:00:00 2001 From: Sweta Barman Date: Wed, 25 Sep 2024 07:45:05 -0400 Subject: [PATCH] fix: Add an additional unit test for imports.write --- .../test/unit/models/api-key.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js b/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js index 847ab952..15e54a1f 100644 --- a/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js +++ b/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js @@ -59,6 +59,11 @@ describe('ApiKey Model tests', () => { expect(apiKey.getScopes()).to.deep.equal([{ name: 'imports.write_all_domains', domains: [] }]); }); + it('creates an ApiKey object for a user with scope - imports.write', () => { + const apiKey = createApiKey({ ...validApiKey, scopes: [{ name: 'imports.write', domains: ['https://adobe.com', 'https://test.com'] }] }); + expect(apiKey.getScopes()).to.deep.equal([{ name: 'imports.write', domains: ['https://adobe.com', 'https://test.com'] }]); + }); + it('throws an error if revokedAt is not a valid date', () => { expect(() => createApiKey({ ...validApiKey, revokedAt: 'invalid-date' })).to.throw('revokedAt should be a valid ISO 8601 string: invalid-date'); });