Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,552 changes: 1,552 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

130 changes: 50 additions & 80 deletions spec/types/OneNote.ts
Original file line number Diff line number Diff line change
@@ -1,92 +1,62 @@
import {assert} from 'chai'
import { assert } from 'chai'

import { getClient, randomString } from "./test-helper"
import { Notebook, Section, Page } from '@microsoft/microsoft-graph-types-beta'
import { Notebook, OnenoteSection, OnenotePage } from '@microsoft/microsoft-graph-types-beta'

declare const describe, it;

describe('OneNote', function() {
this.timeout(20*1000);
let notebook:Notebook = {
name: "Sample notebook - " + randomString()
};
describe('OneNote', function () {
this.timeout(20 * 1000);
let notebook: Notebook = {
displayName: "Sample notebook - " + randomString()
};

let section:Section = {
name: "Sample section - " + randomString()
}
let section: OnenoteSection = {
displayName: "Sample section - " + randomString()
}

let createdPage:Page;
const PageContent = "Sample page content - " + randomString();
let createdPage: OnenotePage;
const PageContent = "Sample page content - " + randomString();

const HTMLPageTitle = `Another page ${randomString()}!`
const HTMLPageContent = `
<!DOCTYPE html>
<html>
<head>
<title>${HTMLPageTitle}</title>
</head>
<body>
<p>Created a OneNote page from <b>HTML</b></p>
</body>
</html>
`

it('Create a OneNote notebook', function() {
return getClient().api("https://graph.microsoft.com/beta/me/notes/notebooks").post(notebook).then((json) => {
const createdNotebook = json as Notebook;
assert.isDefined(createdNotebook.id);
assert.equal(notebook.name, createdNotebook.name);
assert.isUndefined(createdNotebook['invalidPropertyName']);

// if this passes, use this notebook in the following tests
notebook = createdNotebook;
return Promise.resolve();
});
});

it('Create a OneNote section in a Notebook', function() {
return getClient().api(`https://graph.microsoft.com/beta/me/notes/notebooks/${notebook.id}/sections`).post(section).then((json) => {
const createdSection = json as Section;
assert.isDefined(createdSection.id);
assert.equal(section.name, createdSection.name);
assert.isUndefined(createdSection['invalidPropertyName']);

// if this passes, use this notebook in the following tests
section = createdSection;
return Promise.resolve();

});
});


it('Create a OneNote page in a section with basic text content', function() {
return getClient()
.api(`https://graph.microsoft.com/beta/me/notes/sections/${section.id}/pages`)
.header("Content-Type", "text/html")
.post(PageContent)
.then((json) => {
createdPage = json as Page;
assert.isDefined(createdPage.id);
assert.isDefined(createdPage.contentUrl);
assert.isUndefined(createdPage['invalidPropertyName']);
it('Create a OneNote notebook', function () {
return getClient().api("/me/onenote/notebooks").post(notebook).then((json) => {
const createdNotebook = json as Notebook;
assert.isDefined(createdNotebook.id);
assert.equal(notebook.displayName, createdNotebook.displayName);
assert.isUndefined(createdNotebook['invalidPropertyName']);

// if this passes, use this notebook in the following tests
notebook = createdNotebook;
return Promise.resolve();
});
});

it('Create a OneNote page from application/xhtml+xml content and boundary headers', function() {
return getClient()
.api(`https://graph.microsoft.com/beta/me/notes/sections/${section.id}/pages`)
.header("Content-Type", "application/xhtml+xml")
.header("boundary", `MyPartBoundary${randomString()}`)
.post(HTMLPageContent)
.then((json) => {
let createdPageFromHTML = json as Page;
assert.isDefined(createdPage.id);
assert.isDefined(createdPage.contentUrl);
assert.equal(HTMLPageTitle, createdPageFromHTML.title)
assert.isUndefined(createdPage['invalidPropertyName']);
});
});

it('Create a OneNote section in a Notebook', function () {
return getClient().api(`/me/onenote/notebooks/${notebook.id}/sections`).post(section).then((json) => {
const createdSection = json as OnenoteSection;
assert.isDefined(createdSection.id);
assert.equal(section.displayName, createdSection.displayName);
assert.isUndefined(createdSection['invalidPropertyName']);

// if this passes, use this notebook in the following tests
section = createdSection;
return Promise.resolve();
});
})

});
});

it('Create a OneNote page in a section with basic text content', function () {
return getClient()
.api(`/me/onenote/sections/${section.id}/pages`)
.header("Content-Type", "text/html")
.post(PageContent)
.then((json) => {
createdPage = json as OnenotePage;
assert.isDefined(createdPage.id);
assert.isDefined(createdPage.contentUrl);
assert.isUndefined(createdPage['invalidPropertyName']);

return Promise.resolve();
});
});
});
19 changes: 9 additions & 10 deletions spec/types/delta-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { getClient, randomString } from "./test-helper"

declare const describe, it;

describe('Delta Query', function() {
this.timeout(10*1000);
describe('Delta Query', function () {
this.timeout(10 * 1000);
let today = new Date();
let tomorrow = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000);
let nextWeek = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000);

let deltaLink:string;
let deltaLink: string;

let mockEvent:Event = {
let mockEvent: Event = {
"originalStartTimeZone": tomorrow.toISOString(),
"originalEndTimeZone": tomorrow.toISOString(),
"reminderMinutesBeforeStart": 99,
Expand All @@ -23,14 +23,13 @@ describe('Delta Query', function() {
}


it('Gets the delta link for the initial calendar view list', function() {
it('Gets the delta link for the initial calendar view list', function () {
return getClient()
.api("/me/calendarview/delta")
.query({
"startdatetime" : today.toISOString(),
"startdatetime": today.toISOString(),
"enddatetime": nextWeek.toISOString()
})
.version("beta")
.get()
.then((res) => {
return getClient()
Expand All @@ -42,18 +41,18 @@ describe('Delta Query', function() {
});
});

it('Creates a calendar event to see changes in the delta response', function() {
it('Creates a calendar event to see changes in the delta response', function () {
return getClient()
.api('/me/events')
.post(mockEvent);
});

it('Uses delta token to see changed calendar view', function() {
it('Uses delta token to see changed calendar view', function () {
return getClient()
.api(deltaLink)
.get()
.then((res) => {
let events:Event[] = res.value;
let events: Event[] = res.value;
for (let event of events) {
if (event.subject == mockEvent.subject) {
return Promise.resolve();
Expand Down
100 changes: 53 additions & 47 deletions spec/types/excel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,57 @@ declare const describe, it;

const ExcelFilename = `empty-spreadsheet-${randomString()}.xlsx`;

describe('Excel', function() {
this.timeout(10*1000);
it('Uploads an Excel file to OneDrive', function() {

let file = fs.readFileSync('./spec/types/empty-spreadsheet.xlsx');
return getClient()
.api(`/me/drive/root/children/${ExcelFilename}/content`)
.put(file);
});

it('Lists the worksheets in an excel file', function() {
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets`)
.get()
.then((res) => {
let worksheets = res.value as WorkbookWorksheet[];
let sheet1 = worksheets[0];
assert.isNumber(sheet1.position);
assert.isString(sheet1.visibility);
assert.isString(sheet1.id);
assert.isUndefined(sheet1['random fake property that should be null']);
return Promise.resolve();
})
})

it('Updates workbook worksheet range', function() {
let sampleData:WorkbookRange = {
values: [
['cell a1', 'cell a2'],
['cell b1', 'cell b2']
]
};
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets/Sheet1/range(address='A1:B2')`)
.patch(sampleData)
})

it('GETs the used range of the worksheet', function() {
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets/Sheet1/range/usedrange`)
.get()
.then((res:WorkbookRange) => {
assert.isNumber(res.cellCount);
assert.isString(res.address);
assert.isUndefined(res['other prop'])
})
})
describe('Excel', function () {
this.timeout(10 * 1000);
beforeEach((done) => {
setTimeout(function () {
done();
}, 1000);
});
it('Uploads an Excel file to OneDrive', function () {

let file = fs.readFileSync('./spec/types/empty-spreadsheet.xlsx');
return getClient()
.api(`/me/drive/root/children/${ExcelFilename}/content`)
.put(file);
});

it('Lists the worksheets in an excel file', function () {
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets`)
.get()
.then((res) => {
let worksheets = res.value as WorkbookWorksheet[];
let sheet1 = worksheets[0];
assert.isNumber(sheet1.position);
assert.isString(sheet1.visibility);
assert.isString(sheet1.id);
assert.isUndefined(sheet1['random fake property that should be null']);
return Promise.resolve();
})
})

it('Updates workbook worksheet range', function () {
let sampleData: WorkbookRange = {
values: [
['cell a1', 'cell a2'],
['cell b1', 'cell b2']
]
};
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets/Sheet1/range(address='A1:B2')`)
.patch(sampleData)
})


it('GETs the used range of the worksheet', function () {
return getClient()
.api(`/me/drive/root:/${ExcelFilename}:/workbook/worksheets/Sheet1/range/usedrange`)
.get()
.then((res: WorkbookRange) => {
assert.isNumber(res.cellCount);
assert.isString(res.address);
assert.isUndefined(res['other prop'])
})
})
});
62 changes: 31 additions & 31 deletions spec/types/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ import { Group } from '@microsoft/microsoft-graph-types'

declare const describe, it;

describe('Groups', function() {
this.timeout(10*1000);
it('Fetch a list of groups and access properties on a collection item', function() {
return getClient().api("https://graph.microsoft.com/v1.0/groups/").get().then((json) => {
const group = json.value[0] as Group;
assert.isDefined(group.displayName);
assert.isDefined(group.mail);
assert.isDefined(group.id);
describe('Groups', function () {
this.timeout(10 * 1000);
it('Fetch a list of groups and access properties on a collection item', function () {
return getClient().api("/groups").get().then((json) => {
const group = json.value[0] as Group;
assert.isDefined(group.displayName);
assert.isDefined(group.mail);
assert.isDefined(group.id);

assert.isUndefined(group['invalidPropertyName']);
return Promise.resolve();
});
});
assert.isUndefined(group['invalidPropertyName']);
return Promise.resolve();
});
});

it('Create a group and validate properties were set', function() {
const group:Group = {
displayName: "Sample test group",
description: randomString(),
groupTypes: [
"Unified"
],
mailEnabled: true,
mailNickname: "Group911e5",
securityEnabled: true
};
it('Create a group and validate properties were set', function () {
const group: Group = {
displayName: randomString(),
description: randomString(),
groupTypes: [
"Unified"
],
mailEnabled: true,
mailNickname: randomString(),
securityEnabled: true
};

return getClient().api("https://graph.microsoft.com/v1.0/groups/").post(group).then((groupResponse) => {
let createdGroup = groupResponse as Group;
assert.equal(createdGroup.displayName, group.displayName);
assert.equal(createdGroup.description, group.description);
assert.equal(createdGroup.mailEnabled, group.mailEnabled);
assert.isString(createdGroup.id);
return Promise.resolve();
return getClient().api("/groups").post(group).then((groupResponse) => {
let createdGroup = groupResponse as Group;
assert.equal(createdGroup.displayName, group.displayName);
assert.equal(createdGroup.description, group.description);
assert.equal(createdGroup.mailEnabled, group.mailEnabled);
assert.isString(createdGroup.id);
return Promise.resolve();
});
});
});
});
Loading