Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as supertest from 'supertest';
- import {assert} from 'chai';
- import app from '../../app/app';
- import {prepareTests} from "../../utils/prepareTests";
- import {errors} from "../../submodule/phyzeo-shared";
- import {shared} from "../shared";
- describe('POST /auth/login', () => {
- before(() => {
- prepareTests();
- });
- it('should login when PT User exists', () =>
- supertest(app)
- .post('/auth/login')
- .send({
- email: 'testPT@mail.com',
- password: '123123'
- })
- .expect('Content-Type', /json/)
- .expect(200)
- .expect((res) => {
- const {
- message,
- token
- } = res.body;
- assert.typeOf(message, 'string');
- assert.strictEqual(message, 'PT Login successful');
- assert.typeOf(token, 'string');
- shared.JWT_AUTH_TOKEN = token;
- })
- );
- it("should throw unauthorized error when PT User doesn't exists", () =>
- supertest(app)
- .post('/auth/login')
- .send({
- email: 'badEmail@mail.com',
- password: '123123'
- })
- .expect('Content-Type', /json/)
- .expect(errors.unauthorized.statusCode)
- .expect((res) => {
- assert.deepStrictEqual(res.body,errors.unauthorized.body);
- })
- )
- it("should throw unauthorized error when PA try to login", () =>
- supertest(app)
- .post('/auth/login')
- .send({
- email: 'testPA@mail.com',
- password: '123123'
- })
- .expect('Content-Type', /json/)
- .expect(errors.unauthorized.statusCode)
- .expect((res) => {
- assert.deepStrictEqual(res.body,errors.unauthorized.body);
- })
- )
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement