Skip to content

Commit bdfc1a9

Browse files
Add test for retrieving calendar group by name with verbose output
- Implemented a new test case to verify the retrieval of a calendar group by name for the signed-in user when verbose output is enabled. - Enhanced logging assertions to ensure correct output during the command execution. - Stubbed API request to simulate expected behavior for the test scenario.
1 parent c4f8bfe commit bdfc1a9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/m365/outlook/commands/calendargroup/calendargroup-get.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,24 @@ describe(commands.CALENDARGROUP_GET, () => {
261261
assert(logToStderrSpy.calledOnce);
262262
});
263263

264+
it('retrieves calendar group by name for the signed-in user with verbose output', async () => {
265+
const logToStderrSpy = sinon.spy(logger, 'logToStderr');
266+
const expectedFilterUrl = `https://graph.microsoft.com/v1.0/me/calendarGroups?$filter=name eq 'Personal%20Events'`;
267+
268+
sinon.stub(request, 'get').callsFake(async (opts) => {
269+
if (opts.url === expectedFilterUrl) {
270+
return calendarGroupsResponseForFilter;
271+
}
272+
273+
throw 'Invalid request';
274+
});
275+
276+
await command.action(logger, { options: commandOptionsSchema.parse({ name: calendarGroupName, verbose: true }) });
277+
278+
assert(loggerLogSpy.calledOnceWith(calendarGroupsResponseForFilter.value[0]));
279+
assert(logToStderrSpy.calledOnceWith(`Retrieving calendar group '${calendarGroupName}'...`));
280+
});
281+
264282
it('throws an error when calendar group name does not match any results', async () => {
265283
const expectedFilterUrl = `https://graph.microsoft.com/v1.0/me/calendarGroups?$filter=name eq 'Personal%20Events'`;
266284
sinon.stub(request, 'get').callsFake(async (opts) => {

0 commit comments

Comments
 (0)