diff options
author | kaeff <hi@kaeff.net> | 2015-09-16 02:12:50 +0200 |
---|---|---|
committer | kaeff <hi@kaeff.net> | 2015-09-16 02:35:55 +0200 |
commit | dacd2f218a3774bd200f17c7e9274088043a25ef (patch) | |
tree | 14ee131f49bfa103f3f46547decb69d38745bd42 /spec/login_spec.js | |
parent | 8f33d32d40b1e21ae7fb9a92c78a275422af4217 (diff) |
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
Diffstat (limited to 'spec/login_spec.js')
-rw-r--r-- | spec/login_spec.js | 16 |
1 files changed, 9 insertions, 7 deletions
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'); |