Skip to content

Commit

Permalink
test(cli): add test for get-userpoolgroup-list.ts (aws-amplify#7227)
Browse files Browse the repository at this point in the history
This commit adds a test for get-userpoolgroup-list.ts
  • Loading branch information
togami2864 authored and cjihrig-aws committed Jul 12, 2021
1 parent edd1ac3 commit bbb16fc
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { getUserPoolGroupList } from '../../../extensions/amplify-helpers/get-userpoolgroup-list';

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']);
});
});

0 comments on commit bbb16fc

Please sign in to comment.