mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
update and configure jest to test the code
This commit is contained in:
parent
94db508392
commit
49edcf08ce
@ -1,97 +1,7 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
coverageDirectory: "coverage",
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
coveragePathIgnorePatterns: [
|
||||
"node_modules"
|
||||
],
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: null,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
//rootDir: "tests",
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
// setupFiles: [],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
// setupFilesAfterEnv: [],
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
// testMatch: [
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
testPathIgnorePatterns: [
|
||||
"node_modules"
|
||||
],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
testRegex: [
|
||||
"\\.test\\.js$"
|
||||
],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: null,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jasmine2",
|
||||
|
||||
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
||||
// testURL: "http://localhost",
|
||||
|
||||
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
||||
// timers: "real",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
// transform: null,
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "\\\\node_modules\\\\"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
verbose: true,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
collectCoverage: true,
|
||||
coverageProvider: "v8",
|
||||
testEnvironment: "jsdom",
|
||||
};
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
"build": "rollup -c",
|
||||
"webgl": "rollup -c --environment entry:webgl",
|
||||
"core": "rollup -c --environment entry:core",
|
||||
"test": "jest --coverage",
|
||||
"test": "jest --env=jsdom",
|
||||
"lint": "eslint src/og",
|
||||
"generate_types": "tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir node_modules/@types/openglobus__og",
|
||||
"generate_types": "rm -rf node_modules/@types/openglobus__og; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir node_modules/@types/openglobus__og",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"repository": {
|
||||
@ -52,7 +52,7 @@
|
||||
"eslint-plugin-standard": "^4.1.0",
|
||||
"husky": "^6.0.0",
|
||||
"jaguarjs-jsdoc": "^1.1.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest": "^27.2.3",
|
||||
"jsdoc": "^3.6.7",
|
||||
"lint-staged": "^11.0.0",
|
||||
"local-web-server": "^5.1.1",
|
||||
|
||||
22
tests/classes.test.js
Normal file
22
tests/classes.test.js
Normal file
@ -0,0 +1,22 @@
|
||||
import { Planet } from '../src/og/scene/Planet.js';
|
||||
import { SegmentLonLat } from '../src/og/segment/SegmentLonLat.js';
|
||||
import { Worker } from './worker';
|
||||
|
||||
window.Worker = Worker;
|
||||
global.URL.createObjectURL = jest.fn(() => '');
|
||||
|
||||
const mockPlanet = () => {
|
||||
const planet = new Planet();
|
||||
planet.renderer = {};
|
||||
planet.terrain = { gridSizeByZoom: {} };
|
||||
return planet;
|
||||
}
|
||||
|
||||
const mockExtent = () => {
|
||||
return { southWest: { forwardMercatorEPS01: () => { } }, northEast: { forwardMercatorEPS01: () => { } } };
|
||||
}
|
||||
|
||||
test('Testing SegmentLonLat', () => {
|
||||
const segmentLonLat = new SegmentLonLat({}, mockPlanet(), {}, mockExtent());
|
||||
expect(segmentLonLat).toBeTruthy();
|
||||
});
|
||||
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
test('Waiting for tests', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
14
tests/worker.js
Normal file
14
tests/worker.js
Normal file
@ -0,0 +1,14 @@
|
||||
export class Worker {
|
||||
constructor(stringUrl) {
|
||||
this.url = stringUrl;
|
||||
this.onmessage = () => { };
|
||||
}
|
||||
|
||||
postMessage(msg) {
|
||||
this.onmessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export class URL {
|
||||
createObjectURL(tmp) { return '' }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user