Skip to content

Commit bcc2d8a

Browse files
committed
Tests for delta query and insights
1 parent 9ef909c commit bcc2d8a

File tree

4 files changed

+99
-5
lines changed

4 files changed

+99
-5
lines changed

spec/types/delta-query.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { assert } from 'chai'
2+
3+
import { Event } from '@microsoft/microsoft-graph-types'
4+
5+
import { getClient, randomString } from "./test-helper"
6+
7+
declare const describe, it;
8+
9+
describe('Delta Query', function() {
10+
this.timeout(10*1000);
11+
let today = new Date();
12+
let tomorrow = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000);
13+
let nextWeek = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000);
14+
15+
let deltaLink:string;
16+
17+
let mockEvent:Event = {
18+
"originalStartTimeZone": tomorrow.toISOString(),
19+
"originalEndTimeZone": tomorrow.toISOString(),
20+
"reminderMinutesBeforeStart": 99,
21+
"isReminderOn": true,
22+
"subject": randomString()
23+
}
24+
25+
26+
it('Gets the delta link for the initial calendar view list', function() {
27+
return getClient()
28+
.api("/me/calendarview/delta")
29+
.query({
30+
"startdatetime" : today.toISOString(),
31+
"enddatetime": nextWeek.toISOString()
32+
})
33+
.version("beta")
34+
.get()
35+
.then((res) => {
36+
return getClient()
37+
.api(res['@odata.nextLink'])
38+
.get()
39+
.then((pageTwoRes) => {
40+
deltaLink = pageTwoRes['@odata.deltaLink'];
41+
});
42+
});
43+
});
44+
45+
it('Creates a calendar event to see changes in the delta response', function() {
46+
return getClient()
47+
.api('/me/events')
48+
.post(mockEvent);
49+
});
50+
51+
it('Uses delta token to see changed calendar view', function() {
52+
return getClient()
53+
.api(deltaLink)
54+
.get()
55+
.then((res) => {
56+
let events:Event[] = res.value;
57+
for (let event of events) {
58+
if (event.subject == mockEvent.subject) {
59+
return Promise.resolve();
60+
}
61+
}
62+
throw "Didn't find created event when using delta token";
63+
})
64+
});
65+
});

spec/types/groups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {assert} from 'chai'
1+
import { assert } from 'chai'
22

33
import { getClient, randomString } from "./test-helper"
44
import { Group } from '@microsoft/microsoft-graph-types'
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Person } from '@microsoft/microsoft-graph-types-beta'
55

66
declare const describe, it;
77

8-
describe('People', function() {
8+
describe('Social and Insights', function() {
99
this.timeout(10*1000);
1010
it('Fetch a list of people', function() {
1111
return getClient().api("https://graph.microsoft.com/beta/me/people/").get().then((json) => {
@@ -18,4 +18,27 @@ describe('People', function() {
1818
return Promise.resolve();
1919
});
2020
});
21+
22+
it('Searches the people list', function() {
23+
return getClient()
24+
.api("https://graph.microsoft.com/beta/me/people/")
25+
.query("$search=j")
26+
.get()
27+
});
28+
29+
it('Searches the people list with a topic', function() {
30+
return getClient()
31+
.api("https://graph.microsoft.com/beta/me/people/")
32+
.query(`$search="topic: planning"`)
33+
.get()
34+
});
35+
36+
37+
it('Finds items trending around me', function() {
38+
return getClient()
39+
.api("me/insights/trending")
40+
.version("beta")
41+
.get()
42+
});
43+
2144
});

spec/types/users.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ describe('Users', function() {
6868
});
6969
});
7070
});
71-
72-
7371

7472
it('[Callback] Modify and verify givenName property', function() {
7573
const givenName = randomString();
@@ -92,5 +90,13 @@ describe('Users', function() {
9290
assert.isDefined(users[0].id);
9391
assert.isDefined(users[0].mail);
9492
});
95-
})
93+
});
94+
95+
96+
it('Filters on users list', function() {
97+
return getClient()
98+
.api("https://graph.microsoft.com/v1.0/users")
99+
.filter("Department eq 'Finance'")
100+
.get();
101+
});
96102
});

0 commit comments

Comments
 (0)