summaryrefslogtreecommitdiff
path: root/javascript/spec/signup.js
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-07-02 12:09:30 +0200
committerAzul <azul@leap.se>2012-07-02 12:09:30 +0200
commitd743601c17a650e189f9c4bf1cab926b94363e45 (patch)
tree9f905a6226d9fb802c7357665c48b34d95df2610 /javascript/spec/signup.js
parent3c141bd046c7f36f4b2636302eff7cd0445c546d (diff)
added integration test for login
* added a small hook in srp to set a, A and Astr for testing * moved generic functions for tests to SpecHelper
Diffstat (limited to 'javascript/spec/signup.js')
-rw-r--r--javascript/spec/signup.js20
1 files changed, 5 insertions, 15 deletions
diff --git a/javascript/spec/signup.js b/javascript/spec/signup.js
index fb5c014..8ead93b 100644
--- a/javascript/spec/signup.js
+++ b/javascript/spec/signup.js
@@ -1,5 +1,3 @@
-
-
describe("Signup", function() {
beforeEach(function() {
@@ -15,7 +13,7 @@ describe("Signup", function() {
this.xhr.restore();
});
- it("instantiates SRP with a register function", function() {
+ it("has a register function", function() {
expect(typeof this.srp.register).toBe('function');
});
@@ -25,7 +23,7 @@ describe("Signup", function() {
this.srp.register();
expect(this.requests.length).toBe(1);
- respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
+ specHelper.respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
expect(callback.called).toBeTruthy();
});
@@ -35,7 +33,7 @@ describe("Signup", function() {
this.srp.register();
expect(this.requests.length).toBe(1);
- respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
+ specHelper.respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
expect(callback).toHaveBeenCalledWith("adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44");
});
@@ -46,23 +44,15 @@ describe("Signup", function() {
expect(this.requests.length).toBe(1);
expect(this.requests[0].url).toBe("register/salt/");
expect(this.requests[0].requestBody).toBe("I=user");
- respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
+ specHelper.respondXML(this.requests[0], "<salt>5d3055e0acd3ddcfc15</salt>");
expect(this.requests.length).toBe(2);
expect(this.requests[1].url).toBe("register/user/");
expect(this.requests[1].requestBody).toBe("v=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44");
- respondXML(this.requests[1], "<ok/>");
+ specHelper.respondXML(this.requests[1], "<ok/>");
expect(callback).toHaveBeenCalled();
});
- // HELPERS
-
- function respondXML(request, content) {
- header = { "Content-Type": "application/xml;charset=utf-8" };
- body = '<?xml version="1.0" encoding="UTF-8"?>\n';
- body += content;
- request.respond(200, header, body);
- }
});