'use strict';
const assert = require('assert');
const app = require('../../../src/app');
const registrationService = app.service('registration');
const registrationPinService = app.service('registrationPins');
const chai = require('chai');

describe('registration service', function() {
    it('registered the registration service', () => {
        assert.ok(registrationService);
    });

    it('processes 18+ correctly', () => {
        let email = 'max' + Date.now() + '@mustermann.de';
        return registrationPinService.create({"email": email})
        .then(registrationPin => {
            let registrationInput = {
                classOrSchoolId: "0000d186816abba584714c5f",
                "email-pin": registrationPin.pin,
                "pin-sent": "yes",
                "initial-password": "pw123",
                //stage: "on",
                gender: "male",
                "student-birthdate": "15.10.1999",
                "student-email": email,
                "student-firstname": "Max",
                "student-secondname": "Mustermann",
                Erhebung: "true",
                Forschung: "true",
                Nutzungsbedingungen: "Nutzungsbedingungen", //try "true"
                Pseudonymisierung: "true"
            };
            return registrationService.create(registrationInput);
        })
        .then(response => {
            chai.expect(response.user).to.have.property("_id");
            chai.expect(response.account).to.have.property("_id");
            chai.expect(response.consent).to.have.property("_id");
            chai.expect(response.parent).to.equal(null);
        });
    });
});
@@ -405,11 +405,31 @@
 ses 
-18+
+registration by student
  cor
@@ -1620,29 +1620,1807 @@
 nse.
-parent).to.equal(null
+consent).to.have.property(%22userConsent%22);%0A            chai.expect(response.parent).to.equal(null);%0A        %7D);%0A    %7D);%0A%0A    it('processes registration by parent correctly', () =%3E %7B%0A        let email = 'moritz' + Date.now() + '@mustermann.de';%0A        return registrationPinService.create(%7B%22email%22: email%7D)%0A        .then(registrationPin =%3E %7B%0A            let registrationInput = %7B%0A                classOrSchoolId: %220000d186816abba584714c5f%22,%0A                %22email-pin%22: registrationPin.pin,%0A                %22pin-sent%22: %22yes%22,%0A                %22initial-password%22: %22pw123%22,%0A                //stage: %22on%22,%0A                gender: %22male%22,%0A                %22student-birthdate%22: %2215.10.2014%22,%0A                %22student-email%22: 'max' + Date.now() + '@mustermann.de',%0A                %22student-firstname%22: %22Max%22,%0A                %22student-secondname%22: %22Mustermann%22,%0A                Erhebung: %22true%22,%0A                Forschung: %22true%22,%0A                Nutzungsbedingungen: %22Nutzungsbedingungen%22, //try %22true%22%0A                Pseudonymisierung: %22true%22,%0A                %22parent-email%22: email,%0A                %22parent-firstname%22: %22Moritz%22,%0A                %22parent-secondname%22: %22Mustermann%22%0A            %7D;%0A            return registrationService.create(registrationInput);%0A        %7D)%0A        .then(response =%3E %7B%0A            chai.expect(response.user).to.have.property(%22_id%22);%0A            chai.expect(response.account).to.have.property(%22_id%22);%0A            chai.expect(response.consent).to.have.property(%22_id%22);%0A            chai.expect(response.consent.parentConsents.length).to.be.at.least(1);%0A            chai.expect(response.parent).to.have.property(%22_id%22);%0A            //chai.expect(response.user.parents).to.include(response.parent._id);%0A            chai.expect(response.parent.children).to.include(response.user._id
 );%0A 

test registration by parent