Update Jest and tests
Move constants to separate file Fix loop compatibility
This commit is contained in:
@ -1,33 +1,11 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { LIBRARY_LOCATIONS } from '../../utils/library-locations';
|
||||
|
||||
// Force dynamic rendering to prevent caching
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 0;
|
||||
|
||||
// Library branch locations with approximate coordinates
|
||||
const LIBRARY_LOCATIONS: Record<string, { lat: number; lng: number }> = {
|
||||
'Beckwourth': { lat: 32.7157, lng: -117.1611 },
|
||||
'Benjamin': { lat: 32.8328, lng: -117.2713 },
|
||||
'Balboa': { lat: 32.7330, lng: -117.1430 },
|
||||
'Carmel Mountain': { lat: 32.9286, lng: -117.1311 },
|
||||
'Carmel Valley': { lat: 32.9340, lng: -117.2340 },
|
||||
'Central Library': { lat: 32.7216, lng: -117.1574 },
|
||||
'City Heights': { lat: 32.7411, lng: -117.1045 },
|
||||
'Clairemont': { lat: 32.8328, lng: -117.2050 },
|
||||
'College-Rolando': { lat: 32.7482, lng: -117.0704 },
|
||||
'Kensington': { lat: 32.7644, lng: -117.1164 },
|
||||
'La Jolla': { lat: 32.8344, lng: -117.2544 },
|
||||
'Linda Vista': { lat: 32.7714, lng: -117.1789 },
|
||||
'Logan Heights': { lat: 32.7030, lng: -117.1289 },
|
||||
'Malcolm X': { lat: 32.7089, lng: -117.1242 },
|
||||
'Mission Hills': { lat: 32.7469, lng: -117.1978 },
|
||||
'Oak Park': { lat: 32.7328, lng: -117.1461 },
|
||||
'Paradise Hills': { lat: 32.6747, lng: -117.0742 },
|
||||
'Rancho Bernardo': { lat: 33.0200, lng: -117.1156 },
|
||||
'Rancho Penasquitos': { lat: 32.958034, lng: -117.121975 },
|
||||
'San Ysidro': { lat: 32.5592, lng: -117.0431 },
|
||||
'Skyline Hills': { lat: 32.6781, lng: -117.0200 },
|
||||
};
|
||||
// Library branch locations are now imported from a shared file
|
||||
|
||||
interface BibItem {
|
||||
branchName: string;
|
||||
|
||||
26
app/utils/library-locations.ts
Normal file
26
app/utils/library-locations.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// Library branch locations with approximate coordinates
|
||||
// Shared between API route and tests
|
||||
|
||||
export const LIBRARY_LOCATIONS: Record<string, { lat: number; lng: number }> = {
|
||||
'Beckwourth': { lat: 32.7157, lng: -117.1611 },
|
||||
'Benjamin': { lat: 32.8328, lng: -117.2713 },
|
||||
'Balboa': { lat: 32.7330, lng: -117.1430 },
|
||||
'Carmel Mountain': { lat: 32.9286, lng: -117.1311 },
|
||||
'Carmel Valley': { lat: 32.9340, lng: -117.2340 },
|
||||
'Central Library': { lat: 32.7216, lng: -117.1574 },
|
||||
'City Heights': { lat: 32.7411, lng: -117.1045 },
|
||||
'Clairemont': { lat: 32.8328, lng: -117.2050 },
|
||||
'College-Rolando': { lat: 32.7482, lng: -117.0704 },
|
||||
'Kensington': { lat: 32.7644, lng: -117.1164 },
|
||||
'La Jolla': { lat: 32.8344, lng: -117.2544 },
|
||||
'Linda Vista': { lat: 32.7714, lng: -117.1789 },
|
||||
'Logan Heights': { lat: 32.7030, lng: -117.1289 },
|
||||
'Malcolm X': { lat: 32.7089, lng: -117.1242 },
|
||||
'Mission Hills': { lat: 32.7469, lng: -117.1978 },
|
||||
'Oak Park': { lat: 32.7328, lng: -117.1461 },
|
||||
'Paradise Hills': { lat: 32.6747, lng: -117.0742 },
|
||||
'Rancho Bernardo': { lat: 33.0200, lng: -117.1156 },
|
||||
'Rancho Penasquitos': { lat: 32.958034, lng: -117.121975 },
|
||||
'San Ysidro': { lat: 32.5592, lng: -117.0431 },
|
||||
'Skyline Hills': { lat: 32.6781, lng: -117.0200 },
|
||||
};
|
||||
@ -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 };
|
||||
|
||||
@ -34,7 +34,7 @@ echo "✅ Files synced successfully"
|
||||
|
||||
echo "📦 Installing dependencies on remote server..."
|
||||
# shellcheck disable=SC2029
|
||||
ssh "$REMOTE_HOST" "cd $REMOTE_PATH && npm install --omit=dev"
|
||||
ssh "$REMOTE_HOST" "cd $REMOTE_PATH && npm install"
|
||||
|
||||
echo "🏗️ Building application on remote server..."
|
||||
# shellcheck disable=SC2029
|
||||
|
||||
5
jest.config.js
Normal file
5
jest.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
};
|
||||
3892
package-lock.json
generated
3892
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user