diff options
author | Azul <azul@leap.se> | 2012-07-20 10:56:36 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-07-20 10:56:36 +0200 |
commit | 50de80c5e817476ac95a096c718a66f5555fcd05 (patch) | |
tree | e05a25868a999557e2788a91f41da3a5a8a1a0b0 /spec/signup.js | |
parent | 07fe2d8976db0ec267bd57ded90778f0d7695478 (diff) |
INCOMPATIBLE: major restructuring of the repository
* removed Django code - we're keeping the tests - so I hope the two can still be used together
* removed js packer - everyone has their own packaging strategy these days
* cleaned up the repository - we only have js so javascript directory does not make much sense
Diffstat (limited to 'spec/signup.js')
-rw-r--r-- | spec/signup.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/signup.js b/spec/signup.js new file mode 100644 index 0000000..b5099b8 --- /dev/null +++ b/spec/signup.js @@ -0,0 +1,59 @@ +describe("Signup", function() { + + beforeEach(function() { + this.srp = new SRP(); + specHelper.setupFakeXHR.apply(this); + }); + + afterEach(function() { + this.xhr.restore(); + }); + + it("has a register function", function() { + expect(typeof this.srp.register).toBe('function'); + }); + + it("fetches a salt from /register/salt", function(){ + var callback = sinon.spy(); + this.srp.register_receive_salt = callback; + this.srp.register(); + this.expectRequest('register/salt/', "I=user") + this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>"); + expect(callback.called).toBeTruthy(); + }); + + it("receives the salt from /register/salt", function(){ + var callback = sinon.spy(); + this.srp.register_send_verifier = callback; + this.srp.register(); + this.expectRequest('register/salt/', "I=user") + this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>"); + expect(callback).toHaveBeenCalledWith("adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44"); + }); + + it("identifies after successful registration (INTEGRATION)", function(){ + var callback = sinon.spy(); + this.srp.identify = callback; + this.srp.register(); + this.expectRequest('register/salt/', "I=user") + this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>"); + this.expectRequest('register/user/', "v=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44"); + this.respondXML("<ok />"); + expect(callback).toHaveBeenCalled(); + }); + + it("identifies after successful registration with JSON (INTEGRATION)", function(){ + var callback = sinon.spy(); + this.srp.identify = callback; + this.srp.register(); + this.expectRequest('register/salt/', "I=user") + this.respondJSON({salt: "5d3055e0acd3ddcfc15"}); + this.expectRequest('register/user/', "v=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44"); + this.respondJSON({ok: true}); + expect(callback).toHaveBeenCalled(); + }); + + +}); + + |