diff --git a/packages/sns/lib/utils/stsUtils.spec.ts b/packages/sns/lib/utils/stsUtils.spec.ts index a1dba067..69eb6615 100644 --- a/packages/sns/lib/utils/stsUtils.spec.ts +++ b/packages/sns/lib/utils/stsUtils.spec.ts @@ -1,22 +1,35 @@ +import type { SNSClient } from '@aws-sdk/client-sns' import type { STSClient } from '@aws-sdk/client-sts' -import { beforeAll, describe, expect, it } from 'vitest' +import { beforeAll, beforeEach, describe, expect, it } from 'vitest' import { registerDependencies } from '../../test/utils/testContext' -import { buildTopicArn } from './stsUtils' +import { assertTopic, deleteTopic } from './snsUtils' describe('stsUtils', () => { let stsClient: STSClient + let snsClient: SNSClient beforeAll(async () => { const diContainer = await registerDependencies({}, false) stsClient = diContainer.cradle.stsClient + snsClient = diContainer.cradle.snsClient }) describe('buildTopicArn', () => { + const topicName = 'my-test-topic' + + beforeEach(async () => { + await deleteTopic(snsClient, stsClient, topicName) + }) + it('build ARN for topic', async () => { - const topicName = 'my-test-topic' - await expect(buildTopicArn(stsClient, topicName)).resolves.toMatchInlineSnapshot( + const expectedTopicArn = `arn:aws:sns:eu-west-1:000000000000:${topicName}` + expect(expectedTopicArn).toMatchInlineSnapshot( `"arn:aws:sns:eu-west-1:000000000000:my-test-topic"`, ) + + // creating real topic to make sure arn is correct + const topicArn = await assertTopic(snsClient, stsClient, { Name: topicName }) + expect(topicArn).toBe(expectedTopicArn) }) }) })