Update Jest and tests
Move constants to separate file Fix loop compatibility
This commit is contained in:
@ -3,9 +3,9 @@
|
||||
// This import is only necessary if your environment does not provide 'expect' globally
|
||||
import { describe, expect, it } from '@jest/globals';
|
||||
import { getCoordinatesFromZip, SAN_DIEGO_ZIP_COORDINATES } from './location';
|
||||
import { LIBRARY_LOCATIONS as LIBRARY_LOCATIONS_OBJ } from '../api/availability/route';
|
||||
import { LIBRARY_LOCATIONS } from './library-locations';
|
||||
// Convert the object to an array of coordinates for testing
|
||||
const LIBRARY_LOCATIONS = Object.values(LIBRARY_LOCATIONS_OBJ);
|
||||
const LIBRARY_LOCATIONS_ARRAY = Object.values(LIBRARY_LOCATIONS);
|
||||
const ZIP_COORDS = Object.entries(SAN_DIEGO_ZIP_COORDINATES || {});
|
||||
|
||||
describe('San Diego ZIP and Library Coordinates', () => {
|
||||
@ -30,7 +30,8 @@ describe('San Diego ZIP and Library Coordinates', () => {
|
||||
it('all library lat/lngs are unique', () => {
|
||||
const seen = new Map();
|
||||
let duplicate = null;
|
||||
for (const [i, coord] of LIBRARY_LOCATIONS.entries()) {
|
||||
for (let i = 0; i < LIBRARY_LOCATIONS_ARRAY.length; i++) {
|
||||
const coord = LIBRARY_LOCATIONS_ARRAY[i];
|
||||
const key = `${coord.lat},${coord.lng}`;
|
||||
if (seen.has(key)) {
|
||||
duplicate = { idx: i, other: seen.get(key), lat: coord.lat, lng: coord.lng };
|
||||
@ -45,7 +46,7 @@ describe('San Diego ZIP and Library Coordinates', () => {
|
||||
});
|
||||
|
||||
it('no ZIP code lat/lng matches any library lat/lng', () => {
|
||||
const librarySet = new Set(LIBRARY_LOCATIONS.map(c => `${c.lat},${c.lng}`));
|
||||
const librarySet = new Set(LIBRARY_LOCATIONS_ARRAY.map((c: { lat: number; lng: number }) => `${c.lat},${c.lng}`));
|
||||
let conflict = null;
|
||||
for (const [zip, coord] of ZIP_COORDS) {
|
||||
const { lat, lng } = coord as { lat: number; lng: number };
|
||||
|
||||
Reference in New Issue
Block a user