Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parky128 committed Apr 15, 2019
1 parent 496f1ca commit 8e4a890
Show file tree
Hide file tree
Showing 5 changed files with 687 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ yarn-error.log*

# Generated output
dist
coverage

package-lock.json
37 changes: 37 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = function (config) {
config.set({

frameworks: ["mocha", "karma-typescript"],

files: [
{ pattern: "src/**/*.ts" },
{ pattern: "test/**/*.ts" }
],

preprocessors: {
"**/*.ts": ["karma-typescript"]
},

reporters: ["dots", "karma-typescript"],

browsers: ["ChromeHeadless"],

karmaTypescriptConfig: {
reports:
{
"html": {
"directory": "coverage",
"subdirectory": "report"
},
"text-summary": ""
},
compilerOptions: {
lib: [
"es2015"
]
}
},

singleRun: true
});
};
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,29 @@
"module": "./dist/commonjs/index.js",
"types": "./dist/typings/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "karma start",
"test-watch": "karma start --no-single-run --auto-watch",
"build-dev": "npm run clean && tsc && webpack --mode=development",
"build": "webpack",
"prebuild": "npm run clean && npm run lint && tsc",
"prebuild": "npm run clean && npm run lint && npm run test && tsc",
"lint": "tslint -p tsconfig.json",
"clean": "rm -rf dist",
"prepublishOnly": "npm run build",
"interactive": "node -i -e \"const AIMSClient = require('./dist/commonjs/index.js').AIMSClient;\""
"interactive": "npm run build && node -i -e \"const AIMSClient = require('./dist/commonjs/index.js').AIMSClient;\""
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/sinon": "^7.0.11",
"chai": "^4.2.0",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-typescript": "^4.0.0",
"mocha": "^6.1.3",
"peer-deps-externals-webpack-plugin": "^1.0.4",
"sinon": "^7.3.1",
"tslint": "^5.12.1",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.2.4",
Expand Down
8 changes: 4 additions & 4 deletions src/aims-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,16 @@ class AIMSClient {
* /aims/v1/authenticate
* -u username:password "https://api.cloudinsight.alertlogic.com/aims/v1/authenticate"
*/
async authenticate(params: APIRequestParams, user: string, pass: string, mfa?) {
const authenticate = await this.alClient.authenticate(params, user, pass, mfa);
async authenticate(user: string, pass: string, mfa?) {
const authenticate = await this.alClient.authenticate(user, pass, mfa);
return authenticate as AIMSAuthentication;
}

/**
* Authenticate a user's identity with an mfa code and session token
*/
async authenticateWithMFASessionToken(params: APIRequestParams, token: string, mfa: string): Promise<any> {
const authenticate = await this.alClient.authenticateWithMFASessionToken(params, token, mfa);
async authenticateWithMFASessionToken(token: string, mfa: string): Promise<any> {
const authenticate = await this.alClient.authenticateWithMFASessionToken(token, mfa);
return authenticate as AIMSAuthentication;
}

Expand Down
Loading

0 comments on commit 8e4a890

Please sign in to comment.