chore: 增加覆盖率Ci (#1323)

* chore: 增加覆盖率Ci

* chore: jest locv

* fix: layer 单测样例
This commit is contained in:
@thinkinggis 2022-09-02 23:08:45 +08:00 committed by GitHub
parent 2fe8423939
commit 58df737121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 135 additions and 6 deletions

View File

@ -16,4 +16,8 @@ jobs:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- run: yarn - run: yarn
- run: yarn run worker - run: yarn run worker
- run: yarn test-cover - run: yarn test-cover
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -87,3 +87,4 @@ packages/district/src/data
.umi-production/ .umi-production/
.umi/ .umi/
docs-dist docs-dist
/packages/leaflet

View File

@ -45,7 +45,7 @@ module.exports = {
}, },
setupFilesAfterEnv: [ '<rootDir>jest/setupTests.ts' ], setupFilesAfterEnv: [ '<rootDir>jest/setupTests.ts' ],
snapshotSerializers: [ 'enzyme-to-json/serializer' ], snapshotSerializers: [ 'enzyme-to-json/serializer' ],
coverageReporters: ["html"], coverageReporters: ['html', 'lcov', 'clover'],
coverageThreshold: { coverageThreshold: {
global: { global: {
branches: 9, branches: 9,

View File

@ -0,0 +1,98 @@
// @ts-ignore
import { TestScene } from '@antv/l7-test-utils';
import PointLayer from '../';
describe('template', () => {
const el = document.createElement('div');
el.id = 'test-div-id';
const body = document.querySelector('body') as HTMLBodyElement;
body.appendChild(el);
const scene = TestScene({});
const testData = [
{
x: 112,
y: 30,
name:'text1',
v:10,
},
{
x: 112,
y: 32,
name:'text2',
v:20
},
];
it('scene layer fill', async () => {
const layer = new PointLayer().source(
testData,
{
parser: {
type: 'json',
x: 'x',
y: 'y',
},
},
).shape('circle')
.color('red')
.size(10)
scene.addLayer(layer)
});
it('scene layer text', async () => {
const layer = new PointLayer({name:'text'}).source(
testData,
{
parser: {
type: 'json',
x: 'x',
y: 'y',
},
},
).shape('name','text')
.color('name',['red','blue'])
.size('v',[10,20])
scene.addLayer(layer)
expect(layer.name).toEqual('text')
});
it('scene layer extrude', async () => {
const layer = new PointLayer().source(
testData,
{
parser: {
type: 'json',
x: 'x',
y: 'y',
},
},
).shape('cloumn')
.color('red')
.size([5,5,10])
scene.addLayer(layer)
});
it('scene layer simplePoint', async () => {
const layer = new PointLayer().source(
testData,
{
parser: {
type: 'json',
x: 'x',
y: 'y',
},
},
).shape('simple')
.color('red')
.size(1)
scene.addLayer(layer)
});
});

View File

@ -10,7 +10,6 @@ export default class ReglElements implements IElements {
constructor(reGl: regl.Regl, options: IElementsInitializationOptions) { constructor(reGl: regl.Regl, options: IElementsInitializationOptions) {
const { data, usage, type, count } = options; const { data, usage, type, count } = options;
this.elements = reGl.elements({ this.elements = reGl.elements({
data, data,
usage: usageMap[usage || gl.STATIC_DRAW], usage: usageMap[usage || gl.STATIC_DRAW],

View File

@ -2,7 +2,8 @@ import gl from 'gl';
// borrow from regl // borrow from regl
// @see https://github.com/regl-project/regl/blob/gh-pages/test/util/create-context.js#L28 // @see https://github.com/regl-project/regl/blob/gh-pages/test/util/create-context.js#L28
const CONTEXT = gl(1, 1, { preserveDrawingBuffer: true }); const CONTEXT = gl(400, 300, { preserveDrawingBuffer: true});
// @ts-ignore // @ts-ignore
const RESIZE = CONTEXT.getExtension('STACKGL_resize_drawingbuffer'); const RESIZE = CONTEXT.getExtension('STACKGL_resize_drawingbuffer');

View File

@ -11,7 +11,32 @@ export function TestScene(options?: Partial<IMapOptions>) {
body.appendChild(el); body.appendChild(el);
const context = createContext(400, 300); const context = createContext(400, 300);
const reGL = regl(context); const reGL = regl({
gl:context,
attributes: {
alpha: true,
// use TAA instead of MSAA
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
antialias: true,
premultipliedAlpha: true,
preserveDrawingBuffer: false,
stencil: true,
},
extensions: [
'ANGLE_instanced_arrays',
'STACKGL_resize_drawingbuffer',
'STACKGL_destroy_context',
'OES_element_index_uint',
'OES_standard_derivatives',
'OES_texture_float',
'OES_texture_float_linear',
'WEBGL_draw_buffers',
'EXT_blend_minmax',
'EXT_texture_filter_anisotropic',
'OES_vertex_array_object',
],
});
const scene = new Scene({ const scene = new Scene({
id: el, id: el,
gl: reGL, gl: reGL,

View File

@ -35,6 +35,6 @@
} }
}, },
"include": ["packages"], "include": ["packages"],
"exclude": ["node_modules", "packages/**/dist","packages/site"] "exclude": ["node_modules", "packages/**/dist","packages/site","packages/leaflet/**",]
} }

View File

@ -13,6 +13,7 @@
"**/*.{test,story}.ts{,x}", "**/*.{test,story}.ts{,x}",
"node_modules/**/*.d.ts", "node_modules/**/*.d.ts",
"packages/site/**", "packages/site/**",
"packages/leaflet/**",
"packages/site/node_modules/**" "packages/site/node_modules/**"
], ],
"include":[ "include":[