mirror of
https://github.com/immich-app/immich.git
synced 2025-07-03 21:40:00 +02:00
* add unicorn to eslint * fix lint errors for cli * fix merge * fix album name extraction * Update cli/src/commands/upload.command.ts Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * es2k23 * use lowercase os * return undefined album name * fix bug in asset response dto * auto fix issues * fix server code style * es2022 and formatting * fix compilation error * fix test * fix config load * fix last lint errors * set string type * bump ts * start work on web * web formatting * Fix UUIDParamDto as UUIDParamDto * fix library service lint * fix web errors * fix errors * formatting * wip * lints fixed * web can now start * alphabetical package json * rename error * chore: clean up --------- Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { parseLatitude, parseLongitude } from './coordinates';
|
|
|
|
describe('parsing latitude from string input', () => {
|
|
it('returns null for invalid inputs', () => {
|
|
expect(parseLatitude('')).toBeNull();
|
|
expect(parseLatitude('NaN')).toBeNull();
|
|
expect(parseLatitude('Infinity')).toBeNull();
|
|
expect(parseLatitude('-Infinity')).toBeNull();
|
|
expect(parseLatitude('90.001')).toBeNull();
|
|
expect(parseLatitude(-90.000_001)).toBeNull();
|
|
expect(parseLatitude('1000')).toBeNull();
|
|
expect(parseLatitude(-1000)).toBeNull();
|
|
});
|
|
|
|
it('returns the numeric coordinate for valid inputs', () => {
|
|
expect(parseLatitude('90')).toBeCloseTo(90);
|
|
expect(parseLatitude('-90')).toBeCloseTo(-90);
|
|
expect(parseLatitude(89.999_999)).toBeCloseTo(89.999_999);
|
|
expect(parseLatitude('-89.9')).toBeCloseTo(-89.9);
|
|
expect(parseLatitude(0)).toBeCloseTo(0);
|
|
expect(parseLatitude('-0.0')).toBeCloseTo(-0);
|
|
});
|
|
});
|
|
|
|
describe('parsing latitude from null input', () => {
|
|
it('returns null for null input', () => {
|
|
expect(parseLatitude(null)).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('parsing longitude from string input', () => {
|
|
it('returns null for invalid inputs', () => {
|
|
expect(parseLongitude('')).toBeNull();
|
|
expect(parseLongitude('NaN')).toBeNull();
|
|
expect(parseLongitude(Number.POSITIVE_INFINITY)).toBeNull();
|
|
expect(parseLongitude('-Infinity')).toBeNull();
|
|
expect(parseLongitude('180.001')).toBeNull();
|
|
expect(parseLongitude('-180.000001')).toBeNull();
|
|
expect(parseLongitude(1000)).toBeNull();
|
|
expect(parseLongitude('-1000')).toBeNull();
|
|
});
|
|
|
|
it('returns the numeric coordinate for valid inputs', () => {
|
|
expect(parseLongitude(180)).toBeCloseTo(180);
|
|
expect(parseLongitude('-180')).toBeCloseTo(-180);
|
|
expect(parseLongitude('179.999999')).toBeCloseTo(179.999_999);
|
|
expect(parseLongitude(-179.9)).toBeCloseTo(-179.9);
|
|
expect(parseLongitude('0')).toBeCloseTo(0);
|
|
expect(parseLongitude('-0.0')).toBeCloseTo(-0);
|
|
});
|
|
});
|
|
|
|
describe('parsing longitude from null input', () => {
|
|
it('returns null for null input', () => {
|
|
expect(parseLongitude(null)).toBeNull();
|
|
});
|
|
});
|