Skip to content

Commit

Permalink
#43 update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p-a-s-c-a-l committed Aug 21, 2019
1 parent e991381 commit 0688e4b
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/__tests__/CSISHelpers.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import log from 'loglevel';
import {CSISHelpers} from 'csis-helpers-js';
import { CSISHelpers } from 'csis-helpers-js';
import express from 'express'
import apiResponseStudy from './../__fixtures__/study.json';
import apiResponseDataPackage from './../__fixtures__/dataPackage.json';
Expand Down Expand Up @@ -87,13 +87,36 @@ test('find HC resources with @mapview:ogc:wms references in resource array', ()
const includedArray = apiResponseResources.included;

const filteredResources = CSISHelpers.filterResourcesbyReferenceType(
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
referenceType);
expect(filteredResources.length).toBeLessThan(resourcesArray.length);
//expect(filteredResources).toHaveLength(30);
});

test('get taxonomy_term--hazards tags fro resources ', () => {
const tagType = 'taxonomy_term--hazards';
const resourcesArray = apiResponseResources.data;
const includedArray = apiResponseResources.included;
const distinctTags = new Set();

expect(resourcesArray).not.toBeNull();
expect(resourcesArray.length).toBeGreaterThan(0);
resourcesArray.map(resource => {
const tags = extractTagsfromResource(resourcesArray, includedArray, tagType);
tags(resourcesArray).not.toBeNull();
tags.map(tag => {
distinctTags.add(tag);
});
}
)

expect(distinctTags.length).toBeGreaterThan(0);
distinctTags.map(tag => {
log.debug(`found distinct tag $tag.attributes.name in $resourcesArray.length`);
});
});

test('get 1st "reference" for first HC resource with @mapview:ogc:wms references in resource array', () => {

const tagType = 'taxonomy_term--eu_gl';
Expand All @@ -103,20 +126,20 @@ test('get 1st "reference" for first HC resource with @mapview:ogc:wms references
const includedArray = apiResponseResources.included;

const filteredResources = CSISHelpers.filterResourcesbyReferenceType(
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
referenceType);
expect(filteredResources).not.toBeNull();
expect(filteredResources.length).toBeGreaterThan(0);
const reference = CSISHelpers.extractReferencesfromResource(filteredResources[0],includedArray, referenceType);
const reference = CSISHelpers.extractReferencesfromResource(filteredResources[0], includedArray, referenceType);
expect(reference).not.toBeNull();
expect(reference.length).toBeGreaterThan(0);

//expect(filteredResources).toHaveLength(30);
});

test('check for emikat id in study', () => {
const emikatId = CSISHelpers.extractEmikatIdFromStudyGroupNode(apiResponseStudy.data[0]);
test('check for emikat id in study', () => {
const emikatId = CSISHelpers.extractEmikatIdFromStudyGroupNode(apiResponseStudy.data[0]);
expect(emikatId).toEqual(2846);

});
Expand Down

0 comments on commit 0688e4b

Please sign in to comment.