diff --git a/packages/core/src/services/config/__tests__/schema.spec.ts b/packages/core/src/services/config/__tests__/schema.spec.ts deleted file mode 100644 index 4e44415c10..0000000000 --- a/packages/core/src/services/config/__tests__/schema.spec.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { Container } from 'inversify'; -import 'reflect-metadata'; -import { TYPES } from '../../../index'; -import GlobalConfigService from '../ConfigService'; -import { IGlobalConfigService } from '../IConfigService'; - -describe('ConfigService', () => { - let container: Container; - let configService: IGlobalConfigService; - - beforeAll(() => { - container = new Container(); - container - .bind(TYPES.IGlobalConfigService) - .to(GlobalConfigService); - configService = container.get( - TYPES.IGlobalConfigService, - ); - }); - - afterAll(() => { - container.unbind(TYPES.IGlobalConfigService); - }); - - it("should validate scene's options according to JSON schema", () => { - const { valid, errorText } = configService.validateSceneConfig({ - id: 0, - }); - expect(valid).toBeFalsy(); - expect(errorText).toMatch('id should be string'); - - expect( - configService.validateSceneConfig({ - id: 'map', - }).valid, - ).toBeTruthy(); - }); - - it("should validate map's `zoom` option", () => { - const { valid, errorText } = configService.validateMapConfig({ - zoom: 100, - minZoom: 100, - maxZoom: -2, - }); - expect(valid).toBeFalsy(); - expect(errorText).toMatch('zoom should be <= 24'); - expect(errorText).toMatch('minZoom should be <= 24'); - expect(errorText).toMatch('maxZoom should be >= -1'); - - expect( - configService.validateMapConfig({ - zoom: 10, - minZoom: 1, - maxZoom: 15, - }).valid, - ).toBeTruthy(); - }); - - it("should validate map's `pitch` option", () => { - const { valid, errorText } = configService.validateMapConfig({ - pitch: '1', - }); - expect(valid).toBeFalsy(); - expect(errorText).toMatch('pitch should be number'); - - expect( - configService.validateMapConfig({ - pitch: 10, - }).valid, - ).toBeTruthy(); - }); - - it("should validate map's `center` option", () => { - const { valid, errorText } = configService.validateMapConfig({ - center: [1, 2, 3], - }); - expect(valid).toBeFalsy(); - expect(errorText).toMatch('center should NOT have more than 2 items'); - - const { valid: v2, errorText: e2 } = configService.validateMapConfig({ - center: [1], - }); - expect(v2).toBeFalsy(); - expect(e2).toMatch('center should NOT have fewer than 2 items'); - - const { valid: v3, errorText: e3 } = configService.validateMapConfig({ - center: 100, - }); - expect(v3).toBeFalsy(); - expect(e3).toMatch('center should be array'); - - expect( - configService.validateMapConfig({ - center: [100, 100], - }).valid, - ).toBeTruthy(); - }); - - it("should validate layer's options according to JSON schema", () => { - configService.registerLayerConfigSchemaValidator('testLayer', { - properties: { - opacity: { - type: 'number', - minimum: 0, - maximum: 1, - }, - enablePicking: { - type: 'boolean', - }, - }, - }); - - const { valid, errorText } = configService.validateLayerConfig( - 'testLayer', - { opacity: 'invalid' }, - ); - expect(valid).toBeFalsy(); - expect(errorText).toMatch('opacity should be number'); - - expect( - configService.validateLayerConfig('testLayer', { - opacity: 1.5, - }).valid, - ).toBeFalsy(); - - expect( - configService.validateLayerConfig('testLayer', { - enablePicking: 1.5, - }).valid, - ).toBeFalsy(); - - expect( - configService.validateLayerConfig('testLayer', { - opacity: 1.0, - }).valid, - ).toBeTruthy(); - - expect( - configService.validateLayerConfig('testLayer', { - opacity: 0.0, - }).valid, - ).toBeTruthy(); - }); -}); diff --git a/packages/scene/__tests__/index.spec.ts b/packages/scene/__tests__/index.spec.ts index b7b3223818..f1cbcc8cc2 100644 --- a/packages/scene/__tests__/index.spec.ts +++ b/packages/scene/__tests__/index.spec.ts @@ -24,10 +24,9 @@ describe('template', () => { expect(center.lng).toEqual(110.19382669582967); expect(center.lat).toEqual(30.258134); expect(scene.getRotation()).toEqual(-0); - expect(scene.getBounds()).toEqual([ - [88.22117044582802, 9.751305353647084], - [132.1664829458271, 47.2486735705956], - ]); + expect(scene.getBounds()[0].map((v) => v.toFixed(5))).toEqual( + [88.22117044582802, 9.751305353647084].map((v) => v.toFixed(5)), + ); scene.setZoom(5); expect(scene.getZoom()).toEqual(5); scene.setPitch(5);