Skip to content

Commit

Permalink
fix(test): apply vector tiles changes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Nov 5, 2019
1 parent a882b50 commit 02c7555
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
22 changes: 4 additions & 18 deletions test/unit/dataSourceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,16 @@ import GeometryLayer from 'Layer/GeometryLayer';
import PlanarLayer from 'Core/Prefab/Planar/PlanarLayer';
import Feature2Mesh from 'Converter/Feature2Mesh';
import LayeredMaterial from 'Renderer/LayeredMaterial';
import Renderer from './mock';

const renderer = new Renderer();
renderer.setClearColor();

const holes = require('../data/geojson/holesPoints.geojson.json');

supportedFetchers.set('image/png', () => Promise.resolve(new THREE.Texture()));
supportedFetchers.set('application/json', () => Promise.resolve(holes));

// Mock document object for Mocha.
// Warning is overloaded by view test unit
global.document = {
createElement: () => ({
getContext: () => ({
fillRect: () => { },
moveTo: () => { },
lineTo: () => { },
beginPath: () => { },
stroke: () => { },
fill: () => { },
arc: () => { },
setTransform: () => { },
canvas: { width: 256, height: 256 },
}),
}),
};

describe('Provide in Sources', function () {
// Misc var to initialize a TileMesh instance
const geom = new THREE.Geometry();
Expand Down
1 change: 1 addition & 0 deletions test/unit/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Renderer {
fill: () => { },
arc: () => { },
setTransform: () => { },
setLineDash: () => { },
canvas: {
width: 400,
height: 300,
Expand Down
8 changes: 4 additions & 4 deletions test/unit/vectortiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ describe('Vector tiles', function () {
}));
it('should parse hsl to style fill color and opacity', () =>
parse(multipolygon, paints[0], 'fill').then((collection) => {
const style = collection.features[0].geometry[0].properties.style;
const style = collection.features[0].style;
assert.equal(style.fill.color, paints[0]['fill-color'].replace(/ /g, ''));
assert.equal(style.fill.opacity, 0.5);
}));
it('should parse rgba to style fill opacity', () =>
parse(multipolygon, paints[1], 'fill').then((collection) => {
const style = collection.features[0].geometry[0].properties.style;
const style = collection.features[0].style;
assert.equal(style.fill.opacity, 0.5);
}));
it('should parse hsla to style fill color and opacity', () =>
parse(multipolygon, paints[2], 'fill').then((collection) => {
const style = collection.features[0].geometry[0].properties.style;
const style = collection.features[0].style;
assert.equal(style.fill.opacity, 0.3);
assert.equal(style.fill.color, 'hsl(0,10%,0%)');
}));
it('should parse line to style line', () =>
parse(multipolygon, paints[3], 'line').then((collection) => {
const style = collection.features[0].geometry[0].properties.style;
const style = collection.features[0].style;
assert.equal(style.stroke.opacity, 0.4);
assert.equal(style.stroke.width, 3);
assert.equal(style.stroke.color, 'hsl(0,0%,50%)');
Expand Down

0 comments on commit 02c7555

Please sign in to comment.