fix bad tests, fix invalid value object validations

This commit is contained in:
sbriat
2023-09-20 11:00:04 +02:00
parent 6b6a169dee
commit c9c682c1fc
16 changed files with 394 additions and 111 deletions

View File

@@ -11,39 +11,31 @@ describe('Point value object', () => {
expect(pointVO.lon).toBe(6.17651);
});
it('should throw an exception if longitude is invalid', () => {
try {
expect(() => {
new Point({
lat: 48.689445,
lon: 186.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
}).toThrow(ArgumentOutOfRangeException);
expect(() => {
new Point({
lat: 48.689445,
lon: -186.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
}).toThrow(ArgumentOutOfRangeException);
});
it('should throw an exception if latitude is invalid', () => {
try {
expect(() => {
new Point({
lat: 148.689445,
lon: 6.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
}).toThrow(ArgumentOutOfRangeException);
expect(() => {
new Point({
lat: -148.689445,
lon: 6.17651,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
}).toThrow(ArgumentOutOfRangeException);
});
});

View File

@@ -18,71 +18,59 @@ describe('Step value object', () => {
expect(stepVO.lon).toBe(6.17651);
});
it('should throw an exception if longitude is invalid', () => {
try {
expect(() => {
new Step({
lat: 48.689445,
lon: 186.17651,
duration: 150,
distance: 12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
}).toThrow(ArgumentOutOfRangeException);
expect(() => {
new Step({
lon: 48.689445,
lat: -186.17651,
lat: 48.689445,
lon: -186.17651,
duration: 150,
distance: 12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
}).toThrow(ArgumentOutOfRangeException);
});
it('should throw an exception if latitude is invalid', () => {
try {
expect(() => {
new Step({
lat: 248.689445,
lon: 6.17651,
duration: 150,
distance: 12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
try {
}).toThrow(ArgumentOutOfRangeException);
expect(() => {
new Step({
lon: -148.689445,
lat: 6.17651,
lat: -148.689445,
lon: 6.17651,
duration: 150,
distance: 12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentOutOfRangeException);
}
}).toThrow(ArgumentOutOfRangeException);
});
it('should throw an exception if distance is invalid', () => {
try {
expect(() => {
new Step({
lat: 48.689445,
lon: 6.17651,
duration: 150,
distance: -12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentInvalidException);
}
}).toThrow(ArgumentInvalidException);
});
it('should throw an exception if duration is invalid', () => {
try {
expect(() => {
new Step({
lat: 48.689445,
lon: 6.17651,
duration: -150,
distance: 12000,
});
} catch (e: any) {
expect(e).toBeInstanceOf(ArgumentInvalidException);
}
}).toThrow(ArgumentInvalidException);
});
});