Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"version": "2.1.0",
"dependencies": {
"@azure/ms-rest-js": "^1.6.0",
"@azure/ms-rest-nodeauth": "^3.0.0",
"assert": "^2.0.0",
"tslib": "^1.9.3"
},
"keywords": [
Expand All @@ -19,10 +21,12 @@
"module": "./esm/lUISAuthoringClient.js",
"types": "./esm/lUISAuthoringClient.d.ts",
"devDependencies": {
"typescript": "^3.1.1",
"@types/mocha": "^5.2.7",
"rollup": "^0.66.2",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"typescript": "^3.1.1",
"typings": "^2.1.1",
"uglify-js": "^3.4.9"
},
"homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-luis-authoring",
Expand Down Expand Up @@ -50,8 +54,9 @@
"scripts": {
"build": "tsc && rollup -c rollup.config.js && npm run minify",
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-luis-authoring.js.map'\" -o ./dist/cognitiveservices-luis-authoring.min.js ./dist/cognitiveservices-luis-authoring.js",
"prepack": "npm install && npm run build"
"prepack": "npm install && npm run build",
"test": "mocha -r ts-node/register test/**/*.test.ts --timeout 100000"
},
"sideEffects": false,
"autoPublish": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as helper from "./helper";
import * as assert from "assert";

before(() => {
return helper.interactiveLogin();
});

describe("apps.test.ts", () => {
it("lists applications", () => {
let app_name = "New Luis App Name"
return helper.addApp(app_name).then(appId => {
return helper.listApps().then(list => {
assert.notEqual(list.length, 0);

// To-Do: assert the list has an app with "New Luis App Name"
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
import { LUISAuthoringClient } from "../src/lUISAuthoringClient";

var global_client: LUISAuthoringClient;
var subscription = "b15ebe3a1ec446a08f8021fe6f95f0f6";

export function interactiveLogin() {
return msRestNodeAuth.interactiveLogin().then((credentials: any) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we expecting the interactive login to work in CI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should change this in a future PR. the purpose of this PR is to make sure the provided structure (using mocha and typescript) fits the SDK testing in this repo.

const client = new LUISAuthoringClient(
"https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/",
credentials
);
global_client = client;
});
}

export function addApp(app_name) {
return global_client.apps.add(
{
name: app_name,
description: "New LUIS App",
culture: "en-us",
domain: "Comics",
usageScenario: "IoT"
},
{
customHeaders: {
"Ocp-Apim-Subscription-Key": subscription
}
}
);
}


export function listApps() {
return global_client.apps.list({
customHeaders: {
"Ocp-Apim-Subscription-Key": subscription
}
});
}