mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
add unit tests
This commit is contained in:
parent
1d95a02328
commit
08185015ac
@ -15,6 +15,7 @@
|
||||
"webgl": "rollup -c --environment entry:webgl",
|
||||
"core": "rollup -c --environment entry:core",
|
||||
"test": "jest --env=jsdom",
|
||||
"test_watch": "jest --env=jsdom --watch",
|
||||
"lint": "eslint src/og",
|
||||
"generate_types": "rm -rf types; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types; exit 0",
|
||||
"prepare": "husky install"
|
||||
|
||||
@ -16,6 +16,10 @@ import { LonLat } from './LonLat.js';
|
||||
*/
|
||||
export class Extent {
|
||||
|
||||
/**
|
||||
* @param {og.LonLat} [sw] - South West extent corner coordiantes.
|
||||
* @param {og.LonLat} [ne] - North East extent corner coordiantes.
|
||||
*/
|
||||
constructor(sw, ne) {
|
||||
/**
|
||||
* @public
|
||||
|
||||
@ -41,6 +41,11 @@ import { RENDERING } from '../quadTree/quadTree.js';
|
||||
* });
|
||||
*/
|
||||
class XYZ extends Layer {
|
||||
|
||||
/**
|
||||
* @param {string} name - Layer name.
|
||||
* @param {*} options
|
||||
*/
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
|
||||
|
||||
20
tests/Extent.test.js
Normal file
20
tests/Extent.test.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { Extent } from '../src/og/Extent';
|
||||
import { Worker } from './worker';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
window.Worker = Worker;
|
||||
|
||||
const dom = new JSDOM('<html><div id="globus_viewport_0"></p>');
|
||||
global.document = dom.window.document;
|
||||
global.window = dom.window;
|
||||
|
||||
global.URL.createObjectURL = jest.fn(() => '');
|
||||
|
||||
test('Testing Extent', () => {
|
||||
const extent = new Extent();
|
||||
Extent.createByCoordinates([]);
|
||||
Extent.FULL_MERC;
|
||||
Extent.NORTH_POLE_DEG;
|
||||
Extent.SOUTH_POLE_DEG;
|
||||
expect(extent).toBeTruthy();
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
import { Globe } from '../src/og/Globe.js';
|
||||
import { Globe } from '../src/og/Globe';
|
||||
import { Worker } from './worker';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Extent } from '../src/og/Extent.js';
|
||||
import { Planet } from '../src/og/scene/Planet.js';
|
||||
import { SegmentLonLat } from '../src/og/segment/SegmentLonLat.js';
|
||||
import { Extent } from '../src/og/Extent';
|
||||
import { Planet } from '../src/og/scene/Planet';
|
||||
import { SegmentLonLat } from '../src/og/segment/SegmentLonLat';
|
||||
import { Worker } from './worker';
|
||||
|
||||
window.Worker = Worker;
|
||||
16
tests/layer/XYZ.test.js
Normal file
16
tests/layer/XYZ.test.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { XYZ } from '../../src/og/layer/XYZ';
|
||||
import { Worker } from '../worker';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
window.Worker = Worker;
|
||||
|
||||
const dom = new JSDOM('<html><div id="globus_viewport_0"></p>');
|
||||
global.document = dom.window.document;
|
||||
global.window = dom.window;
|
||||
|
||||
global.URL.createObjectURL = jest.fn(() => '');
|
||||
|
||||
test('Testing Extent', () => {
|
||||
const xyz = new XYZ('name', {});
|
||||
expect(xyz).toBeTruthy();
|
||||
});
|
||||
@ -1,10 +1,10 @@
|
||||
export class Worker {
|
||||
constructor(stringUrl) {
|
||||
this.url = stringUrl;
|
||||
this.onmessage = () => { };
|
||||
}
|
||||
constructor(stringUrl) {
|
||||
this.url = stringUrl;
|
||||
this.onmessage = () => { };
|
||||
}
|
||||
|
||||
postMessage(msg) {
|
||||
this.onmessage(msg);
|
||||
}
|
||||
postMessage(msg) {
|
||||
this.onmessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user