mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-28 08:05:18 +02:00
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import fetchMock from 'fetch-mock';
|
|
import Stops from '../../../../../app/component/map/tile-layer/Stops';
|
|
|
|
describe('Stops', () => {
|
|
before(() => fetchMock.mockGlobal());
|
|
after(() => fetchMock.unmockGlobal());
|
|
const config = {
|
|
URL: {
|
|
STOP_MAP: { default: 'https://localhost/stopmap/' },
|
|
REALTIME_STOP_MAP: { default: 'https://localhost/realtimestopmap/' },
|
|
},
|
|
stopsMinZoom: 13,
|
|
};
|
|
|
|
const tile = {
|
|
coords: {
|
|
x: 1,
|
|
y: 2,
|
|
z: 3,
|
|
},
|
|
props: {},
|
|
};
|
|
|
|
describe('fetchStatusAndDrawStop', () => {
|
|
it('should make a get to the correct url', () => {
|
|
fetchMock.get(
|
|
'end:3/1/2.pbf',
|
|
{
|
|
status: 200,
|
|
},
|
|
{ repeat: 1 },
|
|
);
|
|
new Stops(tile, config, []).getPromise(); // eslint-disable-line no-new
|
|
expect(fetchMock.callHistory.called('end:/3/1/2.pbf')).to.equal(true);
|
|
});
|
|
|
|
it('should add zoom offset to the z coordinate', () => {
|
|
fetchMock.get(
|
|
'end:/4/1/2.pbf',
|
|
{
|
|
status: 200,
|
|
},
|
|
{ repeat: 1 },
|
|
);
|
|
new Stops({ ...tile, props: { zoomOffset: 1 } }, config, []).getPromise(); // eslint-disable-line no-new
|
|
expect(fetchMock.callHistory.called('end:/4/1/2.pbf')).to.equal(true);
|
|
});
|
|
|
|
it('should make a get to realtime stops uri when zoomed in', () => {
|
|
fetchMock.get(`${config.URL.REALTIME_STOP_MAP.default}13/1/2.pbf`, {
|
|
status: 404,
|
|
});
|
|
new Stops(
|
|
{ ...tile, props: { zoomOffset: 10 } },
|
|
config,
|
|
[],
|
|
).getPromise();
|
|
expect(fetchMock.callHistory.called('end:/13/1/2.pbf')).to.equal(true);
|
|
});
|
|
});
|
|
});
|