From dacd2f218a3774bd200f17c7e9274088043a25ef Mon Sep 17 00:00:00 2001 From: kaeff Date: Wed, 16 Sep 2015 02:12:50 +0200 Subject: Run tests via cli using karma & PhantomJS for Travis Instead of jasmine's HTML runner, use karma to run specs. karma & all other dependencies are installed via npm and executed via node.js. This allows TravisCI to execute the test, and as a side effect, bumps the versions on the testing toolchain. - Install node.js - Run `npm install` once to download dependencies. - Run `npm test` to run all tests Things to bear in mind: - This commit adds general project information in `package.js` - `karma.conf.js` specifies the order in which src, spec and lib files are loaded - Switch to jasmine spies instead of sinon --- spec/login_spec.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'spec/login_spec.js') diff --git a/spec/login_spec.js b/spec/login_spec.js index 461a4bb..24c7f4f 100644 --- a/spec/login_spec.js +++ b/spec/login_spec.js @@ -42,6 +42,10 @@ describe("Login with srp var", function() { beforeEach(function() { specHelper.setupFakeXHR.apply(this); + calculate = new srp.Calculate(); + calculate.randomSalt = function() {return "4c78c3f8"}; + srp.session = new srp.Session(undefined, calculate); + A_ = srp.session.calculateAndSetA(data.a) old_login = $('#srp_username').val(); old_conf = $('#srp_password_confirmation').val(); @@ -68,7 +72,7 @@ describe("Login with srp var", function() { }); it("authenticates successfully", function(){ - srp.loggedIn = sinon.spy(); + srp.loggedIn = jasmine.createSpy(); srp.login(); this.expectRequest('/1/sessions.json', 'login=' +data.username+ '&A=' +data.aa, 'POST'); @@ -80,7 +84,7 @@ describe("Login with srp var", function() { }); it("reports errors during handshake", function(){ - srp.error = sinon.spy(); + srp.error = jasmine.createSpy(); var error = {login: "something went wrong on the server side"}; srp.login(); @@ -88,14 +92,12 @@ describe("Login with srp var", function() { this.respondJSON(error, 422); //this.expectNoMoreRequests(); - expect(srp.error).toHaveBeenCalled; - var args = srp.error.args[0]; - expect(args[0]).toEqual(error); + expect(srp.error).toHaveBeenCalledWith(error); }); it("rejects B = 0", function(){ - srp.loggedIn = sinon.spy(); - srp.error = sinon.spy(); + srp.loggedIn = jasmine.createSpy(); + srp.error = jasmine.createSpy(); srp.login(); this.expectRequest('/1/sessions.json', 'login=' +data.username+ '&A=' +data.aa, 'POST'); -- cgit v1.2.3