From 191982c9a6dabb8f5f119f3b2672c79484c7e628 Mon Sep 17 00:00:00 2001 From: Birk Skyum Date: Sat, 21 Sep 2024 21:29:28 +0200 Subject: [PATCH] fix hash test --- src/ui/hash.test.ts | 44 +++++++++++++++++++++---------------------- vitest.config.unit.ts | 3 +++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/ui/hash.test.ts b/src/ui/hash.test.ts index d7fc8911bd9..5091000e114 100644 --- a/src/ui/hash.test.ts +++ b/src/ui/hash.test.ts @@ -329,69 +329,69 @@ describe('hash', () => { expect(window.location.hash).toBe('#baz&foo=bar'); }); - test('initialize http://localhost/#', () => { - window.location.href = 'http://localhost/#'; + test('initialize http://localhost:3000/#', () => { + window.location.href = 'http://localhost:3000/#'; createHash().addTo(map); map.setZoom(3); expect(window.location.hash).toBe('#3/0/0'); - expect(window.location.href).toBe('http://localhost/#3/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#3/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#3/1/2'); - expect(window.location.href).toBe('http://localhost/#3/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#3/1/2'); }); - test('initialize http://localhost/##', () => { - window.location.href = 'http://localhost/##'; + test('initialize http://localhost:3000/##', () => { + window.location.href = 'http://localhost:3000/##'; createHash().addTo(map); map.setZoom(3); expect(window.location.hash).toBe('#3/0/0'); - expect(window.location.href).toBe('http://localhost/#3/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#3/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#3/1/2'); - expect(window.location.href).toBe('http://localhost/#3/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#3/1/2'); }); - test('initialize http://localhost#', () => { - window.location.href = 'http://localhost#'; + test('initialize http://localhost:3000#', () => { + window.location.href = 'http://localhost:3000#'; createHash().addTo(map); map.setZoom(4); expect(window.location.hash).toBe('#4/0/0'); - expect(window.location.href).toBe('http://localhost/#4/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#4/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#4/1/2'); - expect(window.location.href).toBe('http://localhost/#4/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#4/1/2'); }); - test('initialize http://localhost/', () => { - window.location.href = 'http://localhost/'; + test('initialize http://localhost:3000/', () => { + window.location.href = 'http://localhost:3000/'; createHash().addTo(map); map.setZoom(5); expect(window.location.hash).toBe('#5/0/0'); - expect(window.location.href).toBe('http://localhost/#5/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#5/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#5/1/2'); - expect(window.location.href).toBe('http://localhost/#5/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#5/1/2'); }); test('initialize default value for window.location.href', () => { createHash().addTo(map); map.setZoom(5); expect(window.location.hash).toBe('#5/0/0'); - expect(window.location.href).toBe('http://localhost/#5/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#5/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#5/1/2'); - expect(window.location.href).toBe('http://localhost/#5/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#5/1/2'); }); - test('initialize http://localhost', () => { - window.location.href = 'http://localhost'; + test('initialize http://localhost:3000', () => { + window.location.href = 'http://localhost:3000'; createHash().addTo(map); map.setZoom(4); expect(window.location.hash).toBe('#4/0/0'); - expect(window.location.href).toBe('http://localhost/#4/0/0'); + expect(window.location.href).toBe('http://localhost:3000/#4/0/0'); map.setCenter([2.0, 1.0]); expect(window.location.hash).toBe('#4/1/2'); - expect(window.location.href).toBe('http://localhost/#4/1/2'); + expect(window.location.href).toBe('http://localhost:3000/#4/1/2'); }); test('map#remove', () => { diff --git a/vitest.config.unit.ts b/vitest.config.unit.ts index ca4858571bf..49dbc9d2a4f 100644 --- a/vitest.config.unit.ts +++ b/vitest.config.unit.ts @@ -1,6 +1,9 @@ import {defineConfig} from 'vitest/config'; export default defineConfig({ + server: { + port: 80 + }, test: { name: 'unit', environment: 'jsdom',