message: white_check_mark: Add first tests
diff: -import * as chai from 'chai';
  import {FixtureLoader} from '../../fixtures/FixtureLoader';
  import {Server} from '../../src/server';
  -import chaiHttp = require('chai-http');
  import {FixtureUtils} from '../../fixtures/FixtureUtils';
  import {Course} from '../../src/models/Course';
  import {ICourse} from '../../../shared/models/ICourse';
  @@ -18,9 +16,16 @@ import {ICodeKataUnit} from '../../../shared/models/units/ICodeKataUnit';
  import {ITaskUnitModel} from '../../src/models/units/TaskUnit';
  import {ITaskUnit} from '../../../shared/models/units/ITaskUnit';
  import * as winston from 'winston';
  +import {API_NOTIFICATION_TYPE_ALL_CHANGES, NotificationSettings} from '../../src/models/NotificationSettings';
  +import {Notification} from '../../src/models/Notification';
  +
  +import chai = require('chai');
  +import chaiHttp = require('chai-http');
  chai.use(chaiHttp);
  const should = chai.should();
  +const expect = chai.expect;
  +
  const app = new Server().app;
  const BASE_URL = '/api/export';
  const fixtureLoader = new FixtureLoader();
  @@ -144,4 +149,65 @@ describe('Export', async () => {
  }
  });
  });
  +
  + describe(`GET ${BASE_URL}/user`, async () => {
  + it('should export student data', async () => {
  + const student = await FixtureUtils.getRandomStudent();
  + const course1 = await FixtureUtils.getRandomCourse();
  + const course2 = await FixtureUtils.getRandomCourse();
  +
  +
  + await new NotificationSettings({
  + 'user': student, 'course': course1,
  + 'notificationType': API_NOTIFICATION_TYPE_ALL_CHANGES, 'emailNotification': false
  + }).save();
  +
  + await new NotificationSettings({
  + 'user': student, 'course': course2,
  + 'notificationType': API_NOTIFICATION_TYPE_ALL_CHANGES, 'emailNotification': false
  + }).save();
  +
  + await new Notification({
  + user: student,
  + changedCourse: course1,
  + text: 'blubba blubba'
  + }).save();
  +
  + await new Notification({
  + user: student,
  + changedCourse: course2,
  + text: 'blubba blubba'
  + }).save();
  +
  + const result = await chai.request(app)
  + .get(`${BASE_URL}/user`)
  + .set('Authorization', `JWT ${JwtUtils.generateToken(student)}`)
  + .catch((err) => err.response);
  +
  + expect(result).to.have.status(200);
  + });
  +
  + it('should export teacher data', async () => {
  + const teacher = await FixtureUtils.getRandomTeacher();
  +
  + const result = await chai.request(app)
  + .get(`${BASE_URL}/user`)
  + .set('Authorization', `JWT ${JwtUtils.generateToken(teacher)}`)
  + .catch((err) => err.response);
  +
  + expect(result).to.have.status(200);
  + });
  +
  +
  + it('should export admin data', async () => {
  + const admin = await FixtureUtils.getRandomStudent();
  +
  + const result = await chai.request(app)
  + .get(`${BASE_URL}/user`)
  + .set('Authorization', `JWT ${JwtUtils.generateToken(admin)}`)
  + .catch((err) => err.response);
  +
  + expect(result).to.have.status(200);
  + });
  + });
  });
  