|
|
@@ -117,4 +117,42 @@ describe("User Operations", function () {
|
|
117
|
117
|
});
|
|
118
|
118
|
}); //end POST /user/auth/
|
|
119
|
119
|
|
|
120
|
|
-});
|
|
|
120
|
+ describe("GET /user/view/:user", function () {
|
|
|
121
|
+ it("gets an individual user that exists", function (done) {
|
|
|
122
|
+ request(base_url + "/user/view/foo123", function (error, response, body) {
|
|
|
123
|
+ body = JSON.parse(body);
|
|
|
124
|
+ expect(response.statusCode).toBe(200);
|
|
|
125
|
+ expect(body.user).not.toBe(null);
|
|
|
126
|
+ expect(typeof body.user).toBe("object");
|
|
|
127
|
+ expect(body.user.username).toBe("foo123");
|
|
|
128
|
+ expect(Array.isArray(body.user.societies)).toBe(true);
|
|
|
129
|
+ expect(Array.isArray(body.user.friends)).toBe(true);
|
|
|
130
|
+ expect(Array.isArray(body.user.accepted_events)).toBe(true);
|
|
|
131
|
+ expect(Array.isArray(body.user.declined_events)).toBe(true);
|
|
|
132
|
+ expect(body.error).toBe(0);
|
|
|
133
|
+ done();
|
|
|
134
|
+ });
|
|
|
135
|
+ });
|
|
|
136
|
+
|
|
|
137
|
+ it("does not get users that do not exist", function (done) {
|
|
|
138
|
+ request(base_url + "/user/view/foo1233", function (error, response, body) {
|
|
|
139
|
+ body = JSON.parse(body);
|
|
|
140
|
+ expect(response.statusCode).toBe(200);
|
|
|
141
|
+ expect(Object.keys(body.user).length).toBe(0);
|
|
|
142
|
+ expect(JSON.stringify(body.user)).toEqual(JSON.stringify({}));
|
|
|
143
|
+ expect(body.error).toBe(1);
|
|
|
144
|
+ done();
|
|
|
145
|
+ });
|
|
|
146
|
+ });
|
|
|
147
|
+
|
|
|
148
|
+ it("gets all users in the system", function (done) {
|
|
|
149
|
+ request(base_url + "/user/view/", function (error, response, body) {
|
|
|
150
|
+ body = JSON.parse(body);
|
|
|
151
|
+ expect(response.statusCode).toBe(200);
|
|
|
152
|
+ expect(Array.isArray(body.users)).toBe(true);
|
|
|
153
|
+ done();
|
|
|
154
|
+ });
|
|
|
155
|
+ });
|
|
|
156
|
+ }); //end GET /user/view/:user
|
|
|
157
|
+
|
|
|
158
|
+}); //end user ops
|