|
1 | 1 | import { beforeEach, describe, it, mock } from 'node:test';
|
2 | 2 | import { AmplifyAuth } from './construct.js';
|
3 | 3 | import { App, SecretValue, Stack, aws_cognito } from 'aws-cdk-lib';
|
4 |
| -import { Template } from 'aws-cdk-lib/assertions'; |
| 4 | +import { Match, Template } from 'aws-cdk-lib/assertions'; |
5 | 5 | import assert from 'node:assert';
|
6 | 6 | import {
|
7 | 7 | BackendOutputEntry,
|
@@ -3062,4 +3062,30 @@ void describe('Auth construct', () => {
|
3062 | 3062 | assert.equal(name.startsWith(expectedPrefix), true);
|
3063 | 3063 | });
|
3064 | 3064 | });
|
| 3065 | + |
| 3066 | + void it('sets the correct userPoolName when name is provided', () => { |
| 3067 | + const app = new App(); |
| 3068 | + const stack = new Stack(app); |
| 3069 | + const customAuthName = 'CustomAuthName'; |
| 3070 | + new AmplifyAuth(stack, 'test', { |
| 3071 | + loginWith: { email: true }, |
| 3072 | + name: customAuthName, |
| 3073 | + }); |
| 3074 | + const template = Template.fromStack(stack); |
| 3075 | + template.hasResourceProperties('AWS::Cognito::UserPool', { |
| 3076 | + UserPoolName: customAuthName, |
| 3077 | + }); |
| 3078 | + }); |
| 3079 | + |
| 3080 | + void it('uses empty string as userPoolName when name is not provided', () => { |
| 3081 | + const app = new App(); |
| 3082 | + const stack = new Stack(app); |
| 3083 | + new AmplifyAuth(stack, 'test', { |
| 3084 | + loginWith: { email: true }, |
| 3085 | + }); |
| 3086 | + const template = Template.fromStack(stack); |
| 3087 | + template.hasResourceProperties('AWS::Cognito::UserPool', { |
| 3088 | + UserPoolName: Match.absent(), |
| 3089 | + }); |
| 3090 | + }); |
3065 | 3091 | });
|
0 commit comments