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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ samples/typescript/sample.d.ts
samples/typescript/graph-typings.d.ts
samples/typescript/sample.js.map
src/index.d.ts
test/secrets.json

spec/types/secrets*
spec/types/*.js
spec/types/*.d.ts
spec/types/*.js.map
6 changes: 3 additions & 3 deletions lib/graph-js-sdk-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ window.MicrosoftGraph = require('./lib/src/index.js');
},{"./lib/src/index.js":5}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("./common");
var request = require("superagent");
var es6_promise_1 = require("es6-promise");
var common_1 = require("./common");
var ResponseHandler_1 = require("./ResponseHandler");
var packageInfo = require('../../package.json');
var GraphRequest = (function () {
Expand Down Expand Up @@ -3695,7 +3695,8 @@ module.exports={
},
"scripts": {
"build": "tsc && node node-browserify.js > lib/graph-js-sdk-web.js",
"test": "mocha lib/test"
"test": "mocha lib/test",
"test:types": "mocha lib/test"
},
"dependencies": {
"superagent": "^3.5.2",
Expand All @@ -3706,5 +3707,4 @@ module.exports={
"url": "https://github.com/microsoftgraph/msgraph-sdk-javascript.git"
}
}

},{}]},{},[1]);
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/spec/core/responseHandling.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/spec/core/urlGeneration.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion lib/test/urlParsing.js → lib/spec/core/urlParsing.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/spec/core/urlParsing.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/GraphRequest.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Options, URLComponents, GraphRequestCallback } from "./common";
import { Promise } from 'es6-promise';
import { Options, URLComponents, GraphRequestCallback } from "./common";
export declare class GraphRequest {
config: Options;
urlComponents: URLComponents;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/GraphRequest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/GraphRequest.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion lib/test/responseHandling.js.map

This file was deleted.

1 change: 0 additions & 1 deletion lib/test/urlGeneration.js.map

This file was deleted.

1 change: 0 additions & 1 deletion lib/test/urlParsing.js.map

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"scripts": {
"build": "tsc && node node-browserify.js > lib/graph-js-sdk-web.js",
"test": "mocha lib/test"
"test": "mocha lib/spec/core",
"test:types": "tsc --p spec/types && mocha spec/types"
},
"dependencies": {
"superagent": "^3.5.2",
Expand All @@ -27,4 +28,4 @@
"type": "git",
"url": "https://github.com/microsoftgraph/msgraph-sdk-javascript.git"
}
}
}
4 changes: 2 additions & 2 deletions test/responseHandling.ts → spec/core/responseHandling.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ResponseHandler} from "../src/ResponseHandler"
import {GraphError} from '../src/common'
import {ResponseHandler} from "../../src/ResponseHandler"
import {GraphError} from '../../src/common'
import * as mocha from 'mocha'

import * as assert from 'assert';
Expand Down
2 changes: 1 addition & 1 deletion test/urlGeneration.ts → spec/core/urlGeneration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as assert from 'assert';

import {Client as GraphClient} from "../src/index"
import { Client as GraphClient } from "../../src/index"

const client = GraphClient.init();

Expand Down
2 changes: 1 addition & 1 deletion test/urlParsing.ts → spec/core/urlParsing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as assert from 'assert';

import {Client as GraphClient} from "../src/index"
import {Client as GraphClient} from "../../src/index"

const client = GraphClient.init();

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

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

declare const describe, it;

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

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

let createdPage:Page;
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']);

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']);
return Promise.resolve();
});
})
});
Binary file added spec/types/empty-spreadsheet.xlsx
Binary file not shown.
58 changes: 58 additions & 0 deletions spec/types/excel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { assert } from 'chai'
import * as fs from 'fs';

import { getClient, randomString } from "./test-helper"
import { WorkbookWorksheet, WorkbookRange } from '@microsoft/microsoft-graph-types'

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'])
})
})
});
Loading