Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cli): add test for get-userpoolgroup-list.ts #7227

Merged
merged 2 commits into from
May 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { getUserPoolGroupList } from '../../../../src/extensions/amplify-helpers/get-userpoolgroup-list';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify this a bit:

Suggested change
import { getUserPoolGroupList } from '../../../../src/extensions/amplify-helpers/get-userpoolgroup-list';
import { getUserPoolGroupList } from '../../../extensions/amplify-helpers/get-userpoolgroup-list';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I fixed it.


jest.mock('amplify-cli-core', () => ({
pathManager: {
getBackendDirPath: jest.fn().mockImplementation(() => ''),
},
JSONUtilities: {
readJson: jest.fn().mockImplementation(() => [
{
groupName: 'Admins',
precedence: 1,
customPolicies: [
{
PolicyName: 'admin-group-policy',
PolicyDocument: {
Version: '2012-10-17',
Statement: [
{
Sid: 'statement1',
Effect: 'Allow',
Action: ['s3:CreateBucket'],
Resource: ['arn:aws:s3:::*'],
},
],
},
},
],
},
{
groupName: 'Editors',
precedence: 2,
},
]),
},
}));

describe('getUserPoolGroupList', () => {
const mock_context = {};
it('should return array of groupNames', () => {
const userPoolGroupList = getUserPoolGroupList(mock_context);
expect(userPoolGroupList).toStrictEqual(['Admins', 'Editors']);
});
});