From 58df737121055da1b5f323c8856bf51e67acc290 Mon Sep 17 00:00:00 2001 From: "@thinkinggis" Date: Fri, 2 Sep 2022 23:08:45 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E7=8E=87Ci=20(#1323)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 增加覆盖率Ci * chore: jest locv * fix: layer 单测样例 --- .github/workflows/test.yml | 6 +- .gitignore | 1 + jest.config.js | 2 +- .../src/point/__tests__/layer_init.spec.ts | 98 +++++++++++++++++++ packages/renderer/src/regl/ReglElements.ts | 1 - packages/test-utils/src/create-context.ts | 3 +- packages/test-utils/src/test-scene.ts | 27 ++++- tsconfig.json | 2 +- tslint.prod.json | 1 + 9 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 packages/layers/src/point/__tests__/layer_init.spec.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4277d50c9d..d0a60add88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,4 +16,8 @@ jobs: node-version: ${{ matrix.node-version }} - run: yarn - run: yarn run worker - - run: yarn test-cover \ No newline at end of file + - run: yarn test-cover + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 78f6bd8f4c..72671bdaad 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,4 @@ packages/district/src/data .umi-production/ .umi/ docs-dist +/packages/leaflet diff --git a/jest.config.js b/jest.config.js index 484670c2bc..f551c1684b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -45,7 +45,7 @@ module.exports = { }, setupFilesAfterEnv: [ 'jest/setupTests.ts' ], snapshotSerializers: [ 'enzyme-to-json/serializer' ], - coverageReporters: ["html"], + coverageReporters: ['html', 'lcov', 'clover'], coverageThreshold: { global: { branches: 9, diff --git a/packages/layers/src/point/__tests__/layer_init.spec.ts b/packages/layers/src/point/__tests__/layer_init.spec.ts new file mode 100644 index 0000000000..9255b23977 --- /dev/null +++ b/packages/layers/src/point/__tests__/layer_init.spec.ts @@ -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) + + }); + + + +}); diff --git a/packages/renderer/src/regl/ReglElements.ts b/packages/renderer/src/regl/ReglElements.ts index a9eda29f4a..6c1b2cddc3 100644 --- a/packages/renderer/src/regl/ReglElements.ts +++ b/packages/renderer/src/regl/ReglElements.ts @@ -10,7 +10,6 @@ export default class ReglElements implements IElements { constructor(reGl: regl.Regl, options: IElementsInitializationOptions) { const { data, usage, type, count } = options; - this.elements = reGl.elements({ data, usage: usageMap[usage || gl.STATIC_DRAW], diff --git a/packages/test-utils/src/create-context.ts b/packages/test-utils/src/create-context.ts index 4c323846aa..954e28e58d 100644 --- a/packages/test-utils/src/create-context.ts +++ b/packages/test-utils/src/create-context.ts @@ -2,7 +2,8 @@ import gl from 'gl'; // borrow from regl // @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 const RESIZE = CONTEXT.getExtension('STACKGL_resize_drawingbuffer'); diff --git a/packages/test-utils/src/test-scene.ts b/packages/test-utils/src/test-scene.ts index f8f4a67be8..5f5f471c31 100644 --- a/packages/test-utils/src/test-scene.ts +++ b/packages/test-utils/src/test-scene.ts @@ -11,7 +11,32 @@ export function TestScene(options?: Partial) { body.appendChild(el); 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({ id: el, gl: reGL, diff --git a/tsconfig.json b/tsconfig.json index ddf57c235d..77f40b8b30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,6 +35,6 @@ } }, "include": ["packages"], - "exclude": ["node_modules", "packages/**/dist","packages/site"] + "exclude": ["node_modules", "packages/**/dist","packages/site","packages/leaflet/**",] } diff --git a/tslint.prod.json b/tslint.prod.json index a50db1cc93..8147f282d9 100644 --- a/tslint.prod.json +++ b/tslint.prod.json @@ -13,6 +13,7 @@ "**/*.{test,story}.ts{,x}", "node_modules/**/*.d.ts", "packages/site/**", + "packages/leaflet/**", "packages/site/node_modules/**" ], "include":[