UNPKG

@academyjs/rover

Version:

Rover allows you to learn programming interactively.

77 lines 4.99 kB
/* eslint-disable no-empty-function */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const request = require("supertest"); const { users } = require("../helper"); const { identifierPattern } = require("../../app/util/constants"); const [testUser] = users; describe("User controller", () => { it("POST /users/session -- should create a new session", function () { return __awaiter(this, void 0, void 0, function* () { const { body } = yield request(this.test.app) .post("/api/v1/users/session") .expect("Content-Type", /json/) .expect(201); assert.isTrue(identifierPattern.test(body.id), "The corect ObjectId should be returned."); assert.strictEqual(testUser.firstName, body.firstName, "The specified first name should be used by the endpoint."); assert.strictEqual(testUser.lastName, body.lastName, "The specified last name should be used by the endpoint."); assert.strictEqual(body.userName, body.id, "By default, the user name should be equal to the ObjectId."); assert.strictEqual(testUser.pictureURL, body.pictureURL, "The specified picture URL should be used by the endpoint."); assert.strictEqual(testUser.emailAddress, body.emailAddress, "The specified email address should be used by the endpoint."); assert.strictEqual(testUser.emailVerified, body.emailVerified, "The specified email verified flag should be used by the endpoint."); assert.deepEqual(["regular"], body.roles, "By default, a user should be created with the regular role."); assert.isNull(body.birthday, "By default, birthday should be null."); assert.deepEqual(["en"], body.contentLanguageCodes, "By default, content language codes should be ['en']."); assert.strictEqual("en", body.displayLanguageCode, "By default, the display language code should be 'en'."); assert.strictEqual("", body.about, "By default, about should be an empty string."); // TODO: Assertions for createdAt and updatedAt. }); }); it("PATCH /users/:id -- should update the specified user", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("PATCH /users/:id -- should fail with status code 404 for unauthorized users", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("PATCH /users/:id -- should fail with status code 400 for bad requests", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("PATCH /users/user-name -- should update user name", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("PATCH /users/user-name -- should fail with status code 400 for existing user names", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("PATCH /users/user-name -- should fail with status code 400 for invalid user names", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should list the first twenty users, by default.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should list the correct records when page is specified.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should fail with status code 400 when page number is negative.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should return an empty list when page number does not exist.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should list the correct records when limit is specified.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should fail with status code 400 when limit is below minimum.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); it("GET /users -- should fail with status code 400 when limit is above maximum.", function () { return __awaiter(this, void 0, void 0, function* () { }); }); }); //# sourceMappingURL=users.test.js.map