Version 1.0.2 mit node_modules Verzeichnis

This commit is contained in:
ISA
2024-10-02 07:58:24 +02:00
parent f353a06b1b
commit 62b6e55a0a
68228 changed files with 4548477 additions and 651 deletions

View File

@@ -0,0 +1,54 @@
import test from 'ava';
import BouncingMotionCss3 from '../src/BouncingMotionCss3';
import {Point} from 'leaflet';
import BouncingOptions from '../src/BouncingOptions';
test('Test calculate contract scale', t => {
// When
const contractScale1 = BouncingMotionCss3.contractScale(41, 12);
const contractScale2 = BouncingMotionCss3.contractScale(41, 0);
// Then
t.is(contractScale1, 0.7073170731707317);
t.is(contractScale2, 1);
});
test('Test calculate duration of CSS3 animation', t => {
// When
const duration1 = BouncingMotionCss3.calculateDuration(15, 52);
const duration2 = BouncingMotionCss3.calculateDuration(12, 52);
const duration3 = BouncingMotionCss3.calculateDuration(20, 30);
const duration4 = BouncingMotionCss3.calculateDuration(0, 30);
// Then
t.is(duration1, 211);
t.is(duration2, 199);
t.is(duration3, 132);
t.is(duration4, 0);
});
test('Test calculate icon animation params', t => {
// Given
const position = new Point(100, 100);
const bouncingOptions = new BouncingOptions();
const height = 41;
// When
const animationParams = BouncingMotionCss3.animationParams(position, bouncingOptions, height);
// Then
t.deepEqual(animationParams, {
'--pos-x': '100px',
'--pos-y': '100px',
'--pos-y-jump': '85px',
'--pos-y-contract': '112px',
'--scale-contract': 0.7073170731707317,
'--duration-jump': '211ms',
'--duration-contract': '199ms',
'--delays': '0ms, 211ms, 422ms, 621ms'
});
});

View File

@@ -0,0 +1,73 @@
import test from 'ava';
import BouncingOptions from '../src/BouncingOptions';
test('Test default bouncing options', t => {
const defaultBouncingOptions = new BouncingOptions();
t.like(defaultBouncingOptions, {
bounceHeight: 15,
contractHeight: 12,
bounceSpeed: 52,
contractSpeed: 52,
shadowAngle: - Math.PI / 4,
elastic: true,
exclusive: false
});
});
test('Test customized bouncing options', t => {
const customizedBouncingOptions = new BouncingOptions({
contractHeight: 42,
exclusive: true
});
t.like(customizedBouncingOptions, {
bounceHeight: 15,
contractHeight: 42,
bounceSpeed: 52,
contractSpeed: 52,
shadowAngle: - Math.PI / 4,
elastic: true,
exclusive: true
});
});
test('Test clone bouncing options', t => {
// Given
const bouncingOptions = new BouncingOptions({
contractHeight: 42,
exclusive: true
});
// When
const clonedOptions = new BouncingOptions(bouncingOptions);
// Then
t.deepEqual(clonedOptions, bouncingOptions);
t.not(clonedOptions, bouncingOptions);
});
test('Test override', t => {
// Given
const defaultBouncingOptions = new BouncingOptions();
// When
const overriddenOptions = defaultBouncingOptions.override({
contractHeight: 42,
exclusive: true
})
// Then
t.like(overriddenOptions, {
bounceHeight: 15,
contractHeight: 42,
bounceSpeed: 52,
contractSpeed: 52,
shadowAngle: - Math.PI / 4,
elastic: true,
exclusive: true
});
t.not(overriddenOptions, defaultBouncingOptions);
});

View File

@@ -0,0 +1,21 @@
import test from 'ava';
import L from 'leaflet';
import randLatLng from './helpers/random-pos';
import SmoothMarkerBouncing from '../src/SmoothMarkerBouncing';
SmoothMarkerBouncing(L);
const MarkerCluster= L.Marker.extend({});
test('Test isRealMarker', t => {
// Given
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
const marker = L.marker(randLatLng()).addTo(map);
const cluster = new MarkerCluster({});
// Then
t.true(marker.isRealMarker());
t.false(cluster.isRealMarker());
});

View File

@@ -0,0 +1,76 @@
import test from 'ava';
import L from 'leaflet';
import randLatLng from './helpers/random-pos';
import SmoothMarkerBouncing from '../src/SmoothMarkerBouncing';
SmoothMarkerBouncing(L);
test('Test start/stop bouncing of individual markers', t => {
// Given
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
const marker1 = L.marker(randLatLng()).addTo(map);
const marker2 = L.marker(randLatLng()).addTo(map);
const marker3 = L.marker(randLatLng()).addTo(map);
// When
let bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, []);
// When
marker2.bounce();
bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, [ marker2 ]);
// When
marker2.stopBouncing();
bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, []);
});
test('Test start/stop bouncing of exclusive marker', t => {
// Given
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
const marker1 = L.marker(randLatLng()).addTo(map);
const marker2 = L.marker(randLatLng()).addTo(map);
const marker3 = L.marker(randLatLng()).setBouncingOptions({ exclusive: true }).addTo(map);
// When
let bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, []);
// When
marker1.bounce();
marker2.bounce();
bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, [ marker1, marker2 ]);
// When
marker3.bounce();
bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, [ marker3 ]);
// When
marker2.bounce();
bouncingMarkers = L.Marker.prototype._orchestration.getBouncingMarkers();
// Then
t.deepEqual(bouncingMarkers, [ marker2 ]);
});

View File

@@ -0,0 +1,68 @@
import test from 'ava';
import L from 'leaflet';
import SmoothMarkerBouncing from '../src/SmoothMarkerBouncing';
SmoothMarkerBouncing(L);
test('Test both setBouncingOptions', t => {
// Given
L.Marker.setBouncingOptions({
contractSpeed: 32
});
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
// When
const marker = L
.marker([48.847547, 2.351074])
.setBouncingOptions({
bounceHeight: 100,
exclusive: true
})
.addTo(map);
// Then
t.like(marker._bouncingMotion.bouncingOptions, {
bounceHeight: 100,
contractHeight: 12,
bounceSpeed: 52,
contractSpeed: 32,
shadowAngle: - Math.PI / 4,
elastic: true,
exclusive: true
});
});
test('Test getBouncingMarkers', t => {
// Given
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
const marker = L
.marker([48.847547, 2.351074])
.setBouncingOptions({
bounceHeight: 100,
exclusive: true
})
.addTo(map);
// When
// nothing
// Then
t.deepEqual(L.Marker.getBouncingMarkers(), []);
// When
marker.bounce();
// Then
t.deepEqual(L.Marker.getBouncingMarkers(), [ marker ]);
// When
marker.stopBouncing();
// Then
t.deepEqual(L.Marker.getBouncingMarkers(), []);
});

View File

@@ -0,0 +1,113 @@
import test from 'ava';
import Styles from '../src/Styles';
import L from 'leaflet';
test('Test parse', t => {
// Given
const cssText = 'margin-left: -12px; margin-top: -41px; width: 25px; height: 41px; z-index: 658; opacity: 0.76';
// When
const styles = Styles.parse(cssText);
// Then
t.like(styles, {
'height': '41px',
'width': '25px',
'margin-left': '-12px',
'margin-top': '-41px',
'outline': 'none'
});
});
test('Test find opacity', t => {
// Given
const styles1 = new Styles({ width: '25px', height: '41px' });
const styles2 = new Styles({ width: '25px', height: '41px' });
const styles3 = new Styles({ width: '25px', height: '41px' });
// When
styles1.findOpacity({ opacityWhenUnclustered: 0.1, opacity: 0.5 });
styles2.findOpacity({ opacity: 0.5 });
styles3.findOpacity({});
// Then
t.like(styles1, {
width: '25px',
height: '41px',
opacity: 0.1
});
t.like(styles2, {
width: '25px',
height: '41px',
opacity: 0.5
});
t.like(styles3, {
width: '25px',
height: '41px',
opacity: 1
});
});
test('Test copy with styles', t => {
// Given
const styles = new Styles({ width: '25px', height: '41px' });
// When
const copy = styles.withStyles({
'--pos-x': '50px',
'--pos-y': '100px'
})
// Then
t.like(copy, {
width: '25px',
height: '41px',
'--pos-x': '50px',
'--pos-y': '100px'
});
});
test('Test toString', t => {
// Given
const styles = new Styles({
'height': '41px',
'width': '25px',
'margin-left': '-12px',
'margin-top': '-41px'
});
// When
const cssText = styles.toString();
// Then
t.true(cssText.includes('margin-left: -12px;'));
t.true(cssText.includes('margin-top: -41px;'));
t.true(cssText.includes('width: 25px;'));
t.true(cssText.includes('height: 41px;'));
});
test('Test styles from marker', t => {
// Given
const div = document.createElement('div');
const map = L.map(div).setView([48.847547, 2.351074], 14);
const marker = L.marker([48.847547, 2.351074]).addTo(map);
// When
const styles = Styles.ofMarker(marker);
// Then
t.like(styles, {
width: '25px',
height: '41px',
opacity: 1,
'z-index': 0,
'outline': 'none'
});
});

View File

@@ -0,0 +1,12 @@
import {load as esmLoad} from '@istanbuljs/esm-loader-hook';
export function load(url, context, defaultLoad) {
if (url.endsWith('.css')) {
return {
format: 'module',
source: ''
};
}
return esmLoad(url, context, defaultLoad);
}

View File

@@ -0,0 +1,9 @@
import _ from 'lodash';
const parisArea = [[48.824384, 2.284298], [48.872054, 2.409782]];
export default function randLatLng() {
const lat = _.random(parisArea[0][0], parisArea[1][0]);
const lng = _.random(parisArea[0][1], parisArea[1][1]);
return [lat, lng];
}

View File

@@ -0,0 +1,2 @@
import browserEnv from 'browser-env';
browserEnv();

View File

@@ -0,0 +1,33 @@
import test from 'ava';
import {calculateLine} from '../src/line';
test('Test calculate line', t => {
// Given
const x = 100,
y = 100,
angle = - Math.PI / 4,
length = 15;
// When
const line = calculateLine(x, y, angle, length);
// Then
t.deepEqual(line, [
[ 100, 100 ],
[ 101, 99 ],
[ 102, 98 ],
[ 103, 97 ],
[ 104, 96 ],
[ 105, 95 ],
[ 106, 94 ],
[ 107, 93 ],
[ 108, 92 ],
[ 109, 91 ],
[ 110, 90 ],
[ 111, 89 ],
[ 112, 88 ],
[ 113, 87 ],
[ 114, 86 ]
]);
});