diff options
author | Azul <azul@riseup.net> | 2012-08-04 16:01:05 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2012-08-04 16:01:05 +0200 |
commit | f0b308e4081a4c804da4f7bfbe4802a8999d4c26 (patch) | |
tree | c577b8973320e1e17ab3d3dbe477f2b01c85b0fe /spec/django/signup.js | |
parent | 94d1938e2e5d0ee5e8e7b9a8ed44a067677e0133 (diff) |
copied jqueryRest and restful specs from django
no real change yet
Diffstat (limited to 'spec/django/signup.js')
-rw-r--r-- | spec/django/signup.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/django/signup.js b/spec/django/signup.js new file mode 100644 index 0000000..b38778a --- /dev/null +++ b/spec/django/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.remote.register_send_verifier = callback; + this.srp.register(); + this.expectRequest('register/salt/', "I=user") + this.respondXML("<salt>5d3055e0acd3ddcfc15</salt>"); + expect(callback).toHaveBeenCalledWith("adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44", this.srp.registered_user); + }); + + 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(); + }); + + +}); + + |