Skip to content

Commit

Permalink
Improving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosGamero committed Oct 28, 2024
1 parent 729ca0a commit 5e5b283
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/sns/lib/utils/stsUtils.spec.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})
})

0 comments on commit 5e5b283

Please sign in to comment.