Add bamboo reporter & mock Localstorage in tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/commit/70a031a9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/tree/70a031a9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/diff/70a031a9 Branch: refs/heads/add-documentation Commit: 70a031a912721470257a4e025a75b670f8bf580f Parents: 262d472 Author: Boyan Bakov <[email protected]> Authored: Mon Feb 29 16:00:25 2016 +0200 Committer: Boyan Bakov <[email protected]> Committed: Mon Feb 29 16:23:23 2016 +0200 ---------------------------------------------------------------------- .gitignore | 1 + package.json | 5 +++-- test/index.js | 34 ++++++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/70a031a9/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 18e0abb..2cc3e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ npm-debug.log bower_components/ nbproject/ test/coverage.html +mocha.json http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/70a031a9/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index d3c1a1b..cbe0d8a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Mpin frontend library.", "main": "index.js", "scripts": { - "test": "mocha", + "test": "mocha -R mocha-bamboo-reporter", "test2": "mocha test --require blanket --reporter html-cov > test/coverage.html" }, "repository": { @@ -36,6 +36,7 @@ "bower": "^1.6.5", "grunt": "^0.4.5", "grunt-bg-shell": "^2.3.1", - "grunt-contrib-concat": "^0.5.1" + "grunt-contrib-concat": "^0.5.1", + "mocha-bamboo-reporter": "^1.1.0" } } http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-js-lib/blob/70a031a9/test/index.js ---------------------------------------------------------------------- diff --git a/test/index.js b/test/index.js index 0bb83b8..afa7924 100644 --- a/test/index.js +++ b/test/index.js @@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an @@ -22,8 +22,9 @@ if (typeof require !== 'undefined') { var expect = require('chai').expect; var sinon = require('sinon'); var sinonChai = require('sinon-chai'); - var mpinjs = require('../index'); -// var mpinjs = require('../dist/mpinjs'); + //used to generate test coverage with blanket + // var mpinjs = require('../index'); + var mpinjs = require('../dist/mpinjs'); } var Errors = []; @@ -32,6 +33,15 @@ Errors[1] = "INVALID_USERID"; Errors[2] = "MISSING_PARAMETERS"; Errors[3] = "IDENTITY_NOT_VERIFIED"; +var testLocalstorage = { + "accounts": { + "7b226d6f62696c65223a20302c2022697373756564223a2022323031362d30322d32332031363a34393a31302e313039363734222c2022757365724944223a20227465737440746573742e636f6d222c202273616c74223a20223162396336353564343665323238373661333631373033353138616636363037227d": { + "regOTT": "4ac1cca55c09f6d4e47a253d8cd503b5", + "state": "STARTED" + } + } +}; + describe('# Constructor initialization without server Url.', function () { it('should throw Error', function () { var mpin = new mpinjs(); @@ -48,6 +58,9 @@ describe('# Normal iniatilization.', function () { spy = sinon.spy(); mpin.request = spy; + sinon.stub(mpin, "getData", function () { + return testLocalstorage; + }); }); it('should call request method once', function () { @@ -72,6 +85,9 @@ describe('# Init method > clientSettings request.', function () { mpinAuthServerURL: "http://192.168.10.63:8011/rps", registerUrl: "http://192.168.10.63:8011/rps/user" }; + sinon.stub(mpin, "getData", function () { + return testLocalstorage; + }); }); //restore request @@ -103,6 +119,9 @@ describe('# makeNewUser checks.', function () { before(function () { mpin = new mpinjs({server: serverUrl}); + sinon.stub(mpin, "getData", function () { + return testLocalstorage; + }); }); after(function () { @@ -132,6 +151,9 @@ describe('# startRegistration.', function () { mpinAuthServerURL: "http://192.168.10.63:8011/rps", registerURL: "http://192.168.10.63:8011/rps/user" }; + sinon.stub(mpin, "getData", function () { + return testLocalstorage; + }); }); after(function () { @@ -178,9 +200,6 @@ describe('# startRegistration.', function () { }); }); }); - - - }); @@ -205,6 +224,9 @@ describe('# confirmRegistration.', function () { this.fakeCs2 = { clientSecret: "0409ba1a247561ab16c35df3ad0ca9846db9968fa28757005335dc2ca35188b4f51521ac97d45bbdb3a8d1c0fdfe79ab29031054534df8b7cbac12e67e4e99d685" }; + sinon.stub(mpin, "getData", function () { + return testLocalstorage; + }); }); afterEach(function () {
