diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..ae54179 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,23 @@ +name: Test + +on: [pull_request] + +jobs: + lint: + name: Run tests + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm ci + + - name: Unit/Integration tests + run: npm run test diff --git a/.gitignore b/.gitignore index ed39e00..cb34280 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +# reports of jest tests +reports diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index 7636424..9ed23e9 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -1,2 +1,5 @@ export * from './layerMetadata'; export * from './layerMetadata-StatusFields'; + +export { IShpMapping } from './decorators/shp.decorator'; +export { IPYCSWMapping } from './decorators/csw.decorator'; diff --git a/tests/integration/some-test.spec.ts b/tests/integration/dummy-test.spec.ts similarity index 100% rename from tests/integration/some-test.spec.ts rename to tests/integration/dummy-test.spec.ts diff --git a/tests/unit/layerMetadata.spec.ts b/tests/unit/layerMetadata.spec.ts new file mode 100644 index 0000000..0695638 --- /dev/null +++ b/tests/unit/layerMetadata.spec.ts @@ -0,0 +1,51 @@ +import { LayerMetadata, IPYCSWMapping, IShpMapping, IPropPYCSWMapping, IPropSHPMapping } from '../../src/models'; + +describe('LayerMetadata class static methods', () => { + it('getPyCSWMapping(): mapped to PYCSW prop', () => { + const PROPERTY_NAME = 'geometry'; + const pycswMapping: IPYCSWMapping | undefined = LayerMetadata.getPyCSWMapping(PROPERTY_NAME); + + expect(pycswMapping).toHaveProperty('xmlElement'); + expect(pycswMapping).toHaveProperty('queryableField'); + }); + + it('getPyCSWMapping(): NOT mapped to PYCSW prop', () => { + const PROPERTY_NAME = 'dummy_geometry'; + const pycswMapping: IPYCSWMapping | undefined = LayerMetadata.getPyCSWMapping(PROPERTY_NAME); + + expect(pycswMapping).toBeUndefined(); + }); + + it('getShpMapping(): mapped to SHAPE prop', () => { + const PROPERTY_NAME = 'geometry'; + const shpMapping: IShpMapping | undefined = LayerMetadata.getShpMapping(PROPERTY_NAME); + + expect(shpMapping).toHaveProperty('shpFile'); + expect(shpMapping).toHaveProperty('valuePath'); + }); + + it('getShpMapping(): NOT mapped to SHAPE prop', () => { + const PROPERTY_NAME = 'dummy_geometry'; + const shpMapping: IShpMapping | undefined = LayerMetadata.getShpMapping(PROPERTY_NAME); + + expect(shpMapping).toBeUndefined(); + }); + + it('getPyCSWMappings(): HAS props mapped to PYCSW', () => { + const pycswMappings: IPropPYCSWMapping[] = LayerMetadata.getPyCSWMappings(); + + expect(pycswMappings.length).toBeGreaterThan(0); + expect(pycswMappings[0]).toHaveProperty('prop'); + expect(pycswMappings[0]).toHaveProperty('xmlElement'); + expect(pycswMappings[0]).toHaveProperty('queryableField'); + }); + + it('getShpMappings(): HAS props mapped to SHAPE', () => { + const shpMappings: IPropSHPMapping[] = LayerMetadata.getShpMappings(); + + expect(shpMappings.length).toBeGreaterThan(0); + expect(shpMappings[0]).toHaveProperty('prop'); + expect(shpMappings[0]).toHaveProperty('shpFile'); + expect(shpMappings[0]).toHaveProperty('valuePath'); + }); +}); diff --git a/tests/unit/some-test.spec.ts b/tests/unit/some-test.spec.ts deleted file mode 100644 index a4bc9cb..0000000 --- a/tests/unit/some-test.spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { cat } from '../../src'; - -describe('plus', function () { - it('should equal 2 for 1 plus 1', function () { - const expectedResult = 2; - expect(1 + 1).toEqual(expectedResult); - }); - it('cat should say meow', function () { - expect(cat).toHaveProperty('say', 'meow'); - }); -});