Skip to content

Commit

Permalink
New command: m365 graph directoryextension add
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinM85 committed Jan 7, 2025
1 parent e66a203 commit f3bd083
Showing 1 changed file with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,15 @@ describe(commands.DIRECTORYEXTENSION_ADD, () => {

throw 'Invalid request';
});
await command.action(logger, { options: { appObjectId: appObjectId, name: 'GitHubWorkAccount', dataType: 'String', targetObjects: 'User', verbose: true } });

const parsedSchema = commandOptionsSchema.safeParse({
appObjectId: appObjectId,
name: 'GitHubWorkAccount',
dataType: 'String',
targetObjects: 'User',
verbose: true
});
await command.action(logger, { options: parsedSchema.data });
assert(loggerLogSpy.calledOnceWithExactly(response));
});

Expand All @@ -248,7 +256,15 @@ describe(commands.DIRECTORYEXTENSION_ADD, () => {

throw 'Invalid request';
});
await command.action(logger, { options: { appId: appId, name: 'GitHubAccounts', dataType: 'String', targetObjects: 'User', isMultiValued: true } });

const parsedSchema = commandOptionsSchema.safeParse({
appId: appId,
name: 'GitHubAccounts',
dataType: 'String',
targetObjects: 'User',
isMultiValued: true
});
await command.action(logger, { options: parsedSchema.data });
assert(loggerLogSpy.calledOnceWithExactly(responseForMultiValued));
});

Expand All @@ -261,7 +277,14 @@ describe(commands.DIRECTORYEXTENSION_ADD, () => {

throw 'Invalid request';
});
await command.action(logger, { options: { appName: appName, name: 'ForServiceUseOnly', dataType: 'Boolean', targetObjects: 'User,Application,Device' } });

const parsedSchema = commandOptionsSchema.safeParse({
appName: appName,
name: 'ForServiceUseOnly',
dataType: 'Boolean',
targetObjects: 'User,Application,Device'
});
await command.action(logger, { options: parsedSchema.data });
assert(loggerLogSpy.calledOnceWithExactly(responseWithMultipleTargets));
});

Expand All @@ -277,6 +300,12 @@ describe(commands.DIRECTORYEXTENSION_ADD, () => {
}
});

await assert.rejects(command.action(logger, { options: { appId: appId, name: 'ForServiceUseOnly', dataType: 'Boolean', targetObjects: 'User,Application,Device' } }), new CommandError('An extension property exists with the name extension_7f5df2f49ed64df786d7eefbfc4ab091_ForServiceUseOnly.'));
const parsedSchema = commandOptionsSchema.safeParse({
appId: appId,
name: 'ForServiceUseOnly',
dataType: 'Boolean',
targetObjects: 'User,Application,Device'
});
await assert.rejects(command.action(logger, { options: parsedSchema.data }), new CommandError('An extension property exists with the name extension_7f5df2f49ed64df786d7eefbfc4ab091_ForServiceUseOnly.'));
});
});

0 comments on commit f3bd083

Please sign in to comment.