summaryrefslogtreecommitdiff
path: root/tests/backend/specs/api
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2014-11-26 21:19:55 +0000
committerJohn McLear <john@mclear.co.uk>2014-11-26 21:19:55 +0000
commit253d6da2ac4b534d717caf2013aa265d9c1e1711 (patch)
treec22037e019b219712f7747ea8ada48baf99d8d5e /tests/backend/specs/api
parent98cc725300de21c1cb80a26f9ec65fed829af144 (diff)
downloadetherpad-lite-253d6da2ac4b534d717caf2013aa265d9c1e1711.zip
60% of backend api tests written
Diffstat (limited to 'tests/backend/specs/api')
-rw-r--r--tests/backend/specs/api/sessionsAndGroups.js73
1 files changed, 65 insertions, 8 deletions
diff --git a/tests/backend/specs/api/sessionsAndGroups.js b/tests/backend/specs/api/sessionsAndGroups.js
index 41c16b4e..77e8b25d 100644
--- a/tests/backend/specs/api/sessionsAndGroups.js
+++ b/tests/backend/specs/api/sessionsAndGroups.js
@@ -11,6 +11,7 @@ var apiVersion = 1;
var testPadId = makeid();
var groupID = "";
var authorID = "";
+var sessionID = "";
describe('API Versioning', function(){
it('errors if can not connect', function(done) {
@@ -24,6 +25,10 @@ describe('API Versioning', function(){
});
})
+// BEGIN GROUP AND AUTHOR TESTS
+/////////////////////////////////////
+/////////////////////////////////////
+
/* Tests performed
-> createGroup() -- should return a groupID
-> listSessionsOfGroup(groupID) -- should be 0
@@ -142,17 +147,67 @@ describe('getAuthorName', function(){
});
})
+// BEGIN SESSION TESTS
+///////////////////////////////////////
+///////////////////////////////////////
-/* Endpoints Still to interact with..
- -> getAuthorName(authorID) -- should return a name IE "john"
- -> listPadsOfAuthor(authorID)
+describe('createSession', function(){
+ it('Creates a session for an Author', function(done) {
+ api.get(endPoint('createSession')+"&authorID="+authorID+"&groupID="+groupID+"&validUntil=999999999999")
+ .expect(function(res){
+ if(res.body.code !== 0 || !res.body.data.sessionID) throw new Error("Unable to create Session");
+ sessionID = res.body.data.sessionID;
+ })
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ });
+})
--> createSession(groupID, authorID, validUntil)
- -> getSessionInfo(sessionID)
- -> listSessionsOfGroup(groupID) -- should be 1
- -> deleteSession(sessionID)
- -> getSessionInfo(sessionID) -- should have author id etc in
+describe('getSessionInfo', function(){
+ it('Gets session inf', function(done) {
+ api.get(endPoint('getSessionInfo')+"&sessionID="+sessionID)
+ .expect(function(res){
+ if(res.body.code !== 0 || !res.body.data.groupID || !res.body.data.authorID || !res.body.data.validUntil) throw new Error("Unable to get Session info");
+ })
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ });
+})
+describe('listSessionsOfGroup', function(){
+ it('Gets sessions of a group', function(done) {
+ api.get(endPoint('listSessionsOfGroup')+"&groupID="+groupID)
+ .expect(function(res){
+ if(res.body.code !== 0 || typeof res.body.data !== "object") throw new Error("Unable to get sessions of a group");
+ })
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ });
+})
+
+describe('deleteSession', function(){
+ it('Deletes a session', function(done) {
+ api.get(endPoint('deleteSession')+"&sessionID="+sessionID)
+ .expect(function(res){
+ if(res.body.code !== 0) throw new Error("Unable to delete a session");
+ })
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ });
+})
+
+describe('getSessionInfo', function(){
+ it('Gets session info', function(done) {
+ api.get(endPoint('getSessionInfo')+"&sessionID="+sessionID)
+ .expect(function(res){
+ if(res.body.code !== 1) throw new Error("Session was not properly deleted");
+ })
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ });
+})
+
+/* Endpoints Still to interact with..
-> listPads(groupID) -- should be empty array
-> createGroupPad(groupID, padName [, text])
-> listPads(groupID) -- should be empty array
@@ -161,6 +216,8 @@ describe('getAuthorName', function(){
-> isPasswordProtected(padID) -- should be false
-> setPassword(padID, password)
-> isPasswordProtected(padID) -- should be true
+
+ -> listPadsOfAuthor(authorID)
*/