Skip to content

Commit d177723

Browse files
committed
Fixed the test case for local path validation
1 parent a332c7a commit d177723

1 file changed

Lines changed: 36 additions & 27 deletions

File tree

src/o365/teams/commands/report/teams-report-useractivityuserdetail.spec.ts

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
1414
let log: string[];
1515
let cmdInstance: any;
1616
let cmdInstanceLogSpy: sinon.SinonSpy;
17+
let writeFileSyncFake = () => { };
1718

1819
before(() => {
1920
sinon.stub(auth, 'restoreAuth').callsFake(() => Promise.resolve());
@@ -40,7 +41,8 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
4041
afterEach(() => {
4142
Utils.restore([
4243
vorpal.find,
43-
request.get
44+
request.get,
45+
fs.writeFileSync
4446
]);
4547
});
4648

@@ -199,6 +201,32 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
199201
});
200202
});
201203

204+
it('gets details about Microsoft Teams user activity by user for the given date', (done) => {
205+
const requestStub: sinon.SinonStub = sinon.stub(request, 'get').callsFake((opts) => {
206+
if (opts.url === `https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(date=2019-07-13)`) {
207+
return Promise.resolve(`
208+
Report Refresh Date,User Principal Name,Last Activity Date,Is Deleted,Deleted Date,Assigned Products,Team Chat Message Count,Private Chat Message Count,Call Count,Meeting Count,Has Other Action,Report Period
209+
2019-08-14,[email protected],,False,,,0,0,0,0,No,7
210+
2019-08-14,[email protected],2019-05-22,False,,OFFICE 365 E3 DEVELOPER+MICROSOFT FLOW FREE,0,0,0,0,No,7
211+
`);
212+
}
213+
214+
return Promise.reject('Invalid request');
215+
});
216+
217+
cmdInstance.action({ options: { debug: false, date: '2019-07-13' } }, () => {
218+
try {
219+
assert.equal(requestStub.lastCall.args[0].url, "https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(date=2019-07-13)");
220+
assert.equal(requestStub.lastCall.args[0].headers["accept"], 'application/json;odata.metadata=none');
221+
assert.equal(requestStub.lastCall.args[0].json, true);
222+
done();
223+
}
224+
catch (e) {
225+
done(e);
226+
}
227+
});
228+
});
229+
202230
it('gets details about Microsoft Teams user activity by user for the given period and export report data in txt format', (done) => {
203231
const requestStub: sinon.SinonStub = sinon.stub(request, 'get').callsFake((opts) => {
204232
if (opts.url === `https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')`) {
@@ -212,6 +240,8 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
212240
return Promise.reject('Invalid request');
213241
});
214242

243+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
244+
215245
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.txt' } }, () => {
216246
try {
217247
assert.equal(requestStub.lastCall.args[0].url, "https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(period='D7')");
@@ -238,6 +268,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
238268

239269
return Promise.reject('Invalid request');
240270
});
271+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
241272

242273
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.txt', output: 'text' } }, () => {
243274
try {
@@ -265,6 +296,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
265296

266297
return Promise.reject('Invalid request');
267298
});
299+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
268300

269301
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.csv' } }, () => {
270302
try {
@@ -292,6 +324,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
292324

293325
return Promise.reject('Invalid request');
294326
});
327+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
295328

296329
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.csv', output: 'csv' } }, () => {
297330
try {
@@ -319,6 +352,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
319352

320353
return Promise.reject('Invalid request');
321354
});
355+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
322356

323357
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.json' } }, () => {
324358
try {
@@ -342,6 +376,7 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
342376

343377
return Promise.reject('Invalid request');
344378
});
379+
sinon.stub(fs, 'writeFileSync').callsFake(writeFileSyncFake);
345380

346381
cmdInstance.action({ options: { debug: false, period: 'D7', outputFile: '/Users/josephvelliah/Desktop/teams-report-useractivityuserdetail.json', output: 'json' } }, () => {
347382
try {
@@ -357,32 +392,6 @@ describe(commands.TEAMS_REPORT_USERACTIVITYUSERDETAIL, () => {
357392
});
358393
});
359394

360-
it('gets details about Microsoft Teams user activity by user for the given date', (done) => {
361-
const requestStub: sinon.SinonStub = sinon.stub(request, 'get').callsFake((opts) => {
362-
if (opts.url === `https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(date=2019-07-13)`) {
363-
return Promise.resolve(`
364-
Report Refresh Date,User Principal Name,Last Activity Date,Is Deleted,Deleted Date,Assigned Products,Team Chat Message Count,Private Chat Message Count,Call Count,Meeting Count,Has Other Action,Report Period
365-
2019-08-14,[email protected],,False,,,0,0,0,0,No,7
366-
2019-08-14,[email protected],2019-05-22,False,,OFFICE 365 E3 DEVELOPER+MICROSOFT FLOW FREE,0,0,0,0,No,7
367-
`);
368-
}
369-
370-
return Promise.reject('Invalid request');
371-
});
372-
373-
cmdInstance.action({ options: { debug: false, date: '2019-07-13' } }, () => {
374-
try {
375-
assert.equal(requestStub.lastCall.args[0].url, "https://graph.microsoft.com/v1.0/reports/getTeamsUserActivityUserDetail(date=2019-07-13)");
376-
assert.equal(requestStub.lastCall.args[0].headers["accept"], 'application/json;odata.metadata=none');
377-
assert.equal(requestStub.lastCall.args[0].json, true);
378-
done();
379-
}
380-
catch (e) {
381-
done(e);
382-
}
383-
});
384-
});
385-
386395
it('correctly handles random API error', (done) => {
387396
sinon.stub(request, 'get').callsFake((opts) => Promise.reject('An error has occurred'));
388397

0 commit comments

Comments
 (0)