Skip to content

Commit

Permalink
Add tests for school do
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedwiper committed Nov 9, 2023
1 parent 0115ba9 commit 2ce8f7a
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions apps/server/src/modules/school/domain/do/school.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { schoolFactory } from '../testing';
import { SchoolFeature } from '../type';

describe('School', () => {
describe('addFeature', () => {
it('should add the given feature to the features set', () => {
const school = schoolFactory.build();

school.addFeature('test feature' as SchoolFeature);

expect(school.getProps().features).toContain('test feature');
});
});

describe('removeFeature', () => {
it('should remove the given feature from the features set', () => {
const feature = 'test feature' as SchoolFeature;

const school = schoolFactory.build({
features: new Set([feature]),
});

school.removeFeature(feature);

expect(school.getProps().features).not.toContain('test feature');
});
});

describe('isInMaintenance', () => {
it('should return true if inMaintenanceSince is in the past', () => {
const school = schoolFactory.build({
inMaintenanceSince: new Date('2020-01-01'),
});

const result = school.isInMaintenance();

expect(result).toBe(true);
});

it('should return false if inMaintenanceSince is in the future', () => {
const school = schoolFactory.build({
inMaintenanceSince: new Date('2100-01-01'),
});

const result = school.isInMaintenance();

expect(result).toBe(false);
});

it('should return false if inMaintenanceSince is undefined', () => {
const school = schoolFactory.build();

const result = school.isInMaintenance();

expect(result).toBe(false);
});
});

describe('isExternal', () => {
it('should return true if externalId is set', () => {
const school = schoolFactory.build({
externalId: 'test',
});

const result = school.isExternal();

expect(result).toBe(true);
});

it('should return false if externalId is undefined', () => {
const school = schoolFactory.build();

const result = school.isExternal();

expect(result).toBe(false);
});
});
});

0 comments on commit 2ce8f7a

Please sign in to comment.