Files
seasonedShows/tests/system/asADeveloperIWantToLogin.js
Kevin 7168950dfe Feat: es modules (#139)
* All file imports change from commonjs to es-module

* Improved plex error responses back from api

* Converted viewHistory to es module

* Es-module requires file extension, updated all imports

* Fix esmodule not having __dirname defined in scope

* Replace dynamic-require with fs readFileSync

* Short message service module function is exported as default

* Resolved lint issues & ignore import/extension rule until typescript

* All tests file imports changed from commonjs to es-module

* Import json fixtures with new helper
2022-08-25 17:19:23 +02:00

41 lines
1.1 KiB
JavaScript

import assert from "assert";
import chai from "chai";
import chaiHttp from "chai-http";
import server from "../../src/webserver/server.js";
import createUser from "../helpers/createUser.js";
import resetDatabase from "../helpers/resetDatabase.js";
chai.use(chaiHttp);
describe("As a user I want to log in", () => {
beforeEach(() => resetDatabase());
beforeEach(() => createUser("test_user", "password"));
it("should return 200 with a token if correct credentials are given", done => {
chai
.request(server)
.post("/api/v1/user/login")
.send({ username: "test_user", password: "password" })
.end((error, response) => {
// console.log(response);
assert.equal(response?.status, 200);
done();
});
});
it("should return 401 if incorrect credentials are given", done => {
chai
.request(server)
.post("/api/v1/user/login")
.send({ username: "test_user", password: "anti-password" })
.end((error, response) => {
// console.log(response);
assert.equal(response?.status, 401);
done();
});
});
});