Skip to content

Commit

Permalink
Update user-ensure.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nanddeepn authored Dec 21, 2024
1 parent 15e1412 commit 1165ef0
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/m365/spo/commands/user/user-ensure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe(commands.USER_ENSURE, () => {
});

it('ensures user in a specific web by loginName', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === `${validWebUrl}/_api/web/ensureuser`) {
return ensuredUserResponse;
}
Expand All @@ -231,13 +231,11 @@ describe(commands.USER_ENSURE, () => {
});

await command.action(logger, { options: { verbose: true, webUrl: validWebUrl, loginName: validLoginName } });
assert(loggerLogSpy.calledWith(ensuredUserResponse));
assert.deepStrictEqual(postStub.firstCall.args[0].data, { logonName: 'c:0t.c|tenant|2056d2f6-3257-4253-8cfc-b73393e414e5' });
});

it('ensures user in a specific web by entraGroupId', async () => {
sinon.stub(entraGroup, 'getGroupById').callsFake(async () => {
return groupM365Response.value[0];
});
sinon.stub(entraGroup, 'getGroupById').resolves(groupM365Response.value[0]);

const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === `${validWebUrl}/_api/web/ensureuser`) {
Expand All @@ -252,9 +250,7 @@ describe(commands.USER_ENSURE, () => {
});

it('ensures security group in a specific web by entraGroupName', async () => {
sinon.stub(entraGroup, 'getGroupByDisplayName').callsFake(async () => {
return groupSecurityResponse.value[0];
});
sinon.stub(entraGroup, 'getGroupByDisplayName').resolves(groupSecurityResponse.value[0]);

const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === `${validWebUrl}/_api/web/ensureuser`) {
Expand All @@ -269,9 +265,7 @@ describe(commands.USER_ENSURE, () => {
});

it('ensures group in a specific web by entraGroupName', async () => {
sinon.stub(entraGroup, 'getGroupByDisplayName').callsFake(async () => {
return groupM365Response.value[0];
});
sinon.stub(entraGroup, 'getGroupByDisplayName').resolves(groupM365Response.value[0]);

const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === `${validWebUrl}/_api/web/ensureuser`) {
Expand Down

0 comments on commit 1165ef0

Please sign in to comment.