-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcreate-organization_test.js
42 lines (38 loc) · 2.17 KB
/
create-organization_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createOrganization } from '../../../../lib/domain/usecases/create-organization.js';
import * as organizationCreationValidator from '../../../../lib/domain/validators/organization-creation-validator.js';
import { OrganizationForAdmin } from '../../../../src/organizational-entities/domain/models/OrganizationForAdmin.js';
import * as dataProtectionOfficerRepository from '../../../../src/organizational-entities/infrastructure/repositories/data-protection-officer.repository.js';
import { organizationForAdminRepository } from '../../../../src/organizational-entities/infrastructure/repositories/organization-for-admin.repository.js';
import * as schoolRepository from '../../../../src/school/infrastructure/repositories/school-repository.js';
import { databaseBuilder, expect, insertMultipleSendingFeatureForNewOrganization } from '../../../test-helper.js';
describe('Integration | UseCases | create-organization', function () {
it('returns newly created organization', async function () {
// given
const superAdminUserId = databaseBuilder.factory.buildUser().id;
await insertMultipleSendingFeatureForNewOrganization();
await databaseBuilder.commit();
const organization = new OrganizationForAdmin({
name: 'ACME',
type: 'PRO',
documentationUrl: 'https://pix.fr',
createdBy: superAdminUserId,
});
// when
const createdOrganization = await createOrganization({
organization,
dataProtectionOfficerRepository,
organizationForAdminRepository,
organizationCreationValidator,
schoolRepository,
});
// then
expect(createdOrganization).to.be.instanceOf(OrganizationForAdmin);
expect(createdOrganization.createdBy).to.be.equal(superAdminUserId);
expect(createdOrganization.name).to.be.equal(organization.name);
expect(createdOrganization.type).to.be.equal(organization.type);
expect(createdOrganization.documentationUrl).to.be.equal(organization.documentationUrl);
expect(createdOrganization.dataProtectionOfficer.firstName).to.equal('');
expect(createdOrganization.dataProtectionOfficer.lastName).to.equal('');
expect(createdOrganization.dataProtectionOfficer.email).to.equal('');
});
});