Skip to content

Commit

Permalink
feat(unit-tests): implemented and integrated (#37)
Browse files Browse the repository at this point in the history
* feat(unit-tests): implemented and integrated

* fix(pr-comments): fixed
  • Loading branch information
alebinson authored Feb 16, 2021
1 parent 508df46 commit 8f4a1d9
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 11 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# reports of jest tests
reports
3 changes: 3 additions & 0 deletions src/models/layerMetadata/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export * from './layerMetadata';
export * from './layerMetadata-StatusFields';

export { IShpMapping } from './decorators/shp.decorator';
export { IPYCSWMapping } from './decorators/csw.decorator';
File renamed without changes.
51 changes: 51 additions & 0 deletions tests/unit/layerMetadata.spec.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
11 changes: 0 additions & 11 deletions tests/unit/some-test.spec.ts

This file was deleted.

0 comments on commit 8f4a1d9

Please sign in to comment.