Skip to content

Commit

Permalink
fix hash test
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum committed Sep 21, 2024
1 parent 4766cba commit 191982c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/ui/hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
3 changes: 3 additions & 0 deletions vitest.config.unit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {defineConfig} from 'vitest/config';

export default defineConfig({
server: {
port: 80
},
test: {
name: 'unit',
environment: 'jsdom',
Expand Down

0 comments on commit 191982c

Please sign in to comment.