mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 07:52:41 +00:00
spacetime VO tests
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import {
|
||||
ArgumentInvalidException,
|
||||
ArgumentOutOfRangeException,
|
||||
} from '@mobicoop/ddd-library';
|
||||
import { SpacetimePoint } from '@modules/geography/core/domain/value-objects/spacetime-point.value-object';
|
||||
|
||||
describe('Timepoint value object', () => {
|
||||
it('should create a timepoint value object', () => {
|
||||
const timepointVO = new SpacetimePoint({
|
||||
lon: 48.689445,
|
||||
lat: 6.17651,
|
||||
duration: 150,
|
||||
distance: 12000,
|
||||
});
|
||||
expect(timepointVO.duration).toBe(150);
|
||||
expect(timepointVO.distance).toBe(12000);
|
||||
expect(timepointVO.lon).toBe(48.689445);
|
||||
expect(timepointVO.lat).toBe(6.17651);
|
||||
});
|
||||
it('should throw an exception if longitude is invalid', () => {
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: 348.689445,
|
||||
lat: 6.17651,
|
||||
duration: 150,
|
||||
distance: 12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: -348.689445,
|
||||
lat: 6.17651,
|
||||
duration: 150,
|
||||
distance: 12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
});
|
||||
it('should throw an exception if latitude is invalid', () => {
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: 48.689445,
|
||||
lat: 96.17651,
|
||||
duration: 150,
|
||||
distance: 12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: 48.689445,
|
||||
lat: -96.17651,
|
||||
duration: 150,
|
||||
distance: 12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
|
||||
}
|
||||
});
|
||||
it('should throw an exception if distance is invalid', () => {
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: 48.689445,
|
||||
lat: 6.17651,
|
||||
duration: 150,
|
||||
distance: -12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentInvalidException);
|
||||
}
|
||||
});
|
||||
it('should throw an exception if duration is invalid', () => {
|
||||
try {
|
||||
new SpacetimePoint({
|
||||
lon: 48.689445,
|
||||
lat: 6.17651,
|
||||
duration: -150,
|
||||
distance: 12000,
|
||||
});
|
||||
} catch (e: any) {
|
||||
expect(e).toBeInstanceOf(ArgumentInvalidException);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user