-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |