UNPKG

trackasia-gl

Version:

BSD licensed community fork of mapbox-gl, a WebGL interactive maps library

82 lines (68 loc) 2.74 kB
import {describe, beforeEach, test, expect} from 'vitest'; import {createMap as globalCreateMap, beforeMapTest} from '../../util/test/util'; function createMap(logoPosition, trackasiaLogo) { const mapobj = { logoPosition, trackasiaLogo, style: { version: 8, sources: {}, layers: [] } }; return globalCreateMap(mapobj); } beforeEach(() => { beforeMapTest(); }); describe('LogoControl', () => { test('does not appear by default', async () => { const map = createMap(undefined, undefined); await map.once('load'); expect(map.getContainer().querySelectorAll( '.trackasiagl-ctrl-logo' )).toHaveLength(0); }); test('is not displayed when the trackasiaLogo property is false', async () => { const map = createMap(undefined, false); await map.once('load'); expect(map.getContainer().querySelectorAll( '.trackasiagl-ctrl-logo' )).toHaveLength(0); }); test('appears in bottom-left when trackasiaLogo is true and logoPosition is undefined', async () => { const map = createMap(undefined, true); await map.once('load'); expect(map.getContainer().querySelectorAll( '.trackasiagl-ctrl-bottom-left .trackasiagl-ctrl-logo' )).toHaveLength(1); }); test('appears in the position specified by the position option', async () => { const map = createMap('top-left', true); await map.once('load'); expect(map.getContainer().querySelectorAll( '.trackasiagl-ctrl-top-left .trackasiagl-ctrl-logo' )).toHaveLength(1); }); test('appears in compact mode if container is less then 640 pixel wide', () => { const map = createMap(undefined, true); const container = map.getContainer(); Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 645, configurable: true}); map.resize(); expect( container.querySelectorAll('.trackasiagl-ctrl-logo:not(.trackasiagl-compact)') ).toHaveLength(1); Object.defineProperty(map.getCanvasContainer(), 'offsetWidth', {value: 635, configurable: true}); map.resize(); expect( container.querySelectorAll('.trackasiagl-ctrl-logo.trackasiagl-compact') ).toHaveLength(1); }); test('has `rel` noopener and nofollow', async () => { const map = createMap(undefined, true); await map.once('load'); const container = map.getContainer(); const logo = container.querySelector('.trackasiagl-ctrl-logo'); expect(logo).toHaveProperty('rel', 'noopener nofollow'); }); });