Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
build/
coverage/
webpack.config.js
src/locales
cypress/fixtures/*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
build
coverage
cypress/videos/
cypress/screenshots/
cypress/downloads/
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
.d2
src/locales
build
coverage
cypress/fixtures/*
cypress.env.json
docs/maps.md
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
setupFilesAfterEnv: ['<rootDir>/config/testSetup.js'],
collectCoverageFrom: ['src/**/*.js'],
collectCoverageFrom: ['src/**/*.{js,jsx}'],
testPathIgnorePatterns: ['/node_modules/', '/cypress/'],
transformIgnorePatterns: [
'/node_modules/(?!d3-(array|axis|color|format|interpolate|scale|selection|time)|internmap|array-move)',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "d2-app-scripts build",
"start": "d2-app-scripts start",
"test": "d2-app-scripts test",
"test:coverage": "d2-app-scripts test --coverage",
"deploy": "d2-app-scripts deploy",
"lint": "d2-style check",
"format": "d2-style apply",
Expand Down
13 changes: 13 additions & 0 deletions src/actions/__tests__/aggregations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as types from '../../constants/actionTypes.js'
import { setAggregations } from '../aggregations.js'

describe('setAggregations', () => {
it('creates an AGGREGATIONS_SET action', () => {
const payload = { count: 'sum' }

expect(setAggregations(payload)).toEqual({
type: types.AGGREGATIONS_SET,
payload,
})
})
})
24 changes: 24 additions & 0 deletions src/actions/__tests__/analyticalObject.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as types from '../../constants/actionTypes.js'
import {
setAnalyticalObject,
clearAnalyticalObject,
} from '../analyticalObject.js'

describe('setAnalyticalObject', () => {
it('creates an ANALYTICAL_OBJECT_SET action', () => {
const ao = { id: 'ao1' }

expect(setAnalyticalObject(ao)).toEqual({
type: types.ANALYTICAL_OBJECT_SET,
payload: ao,
})
})
})

describe('clearAnalyticalObject', () => {
it('creates an ANALYTICAL_OBJECT_CLEAR action', () => {
expect(clearAnalyticalObject()).toEqual({
type: types.ANALYTICAL_OBJECT_CLEAR,
})
})
})
43 changes: 43 additions & 0 deletions src/actions/__tests__/basemap.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as types from '../../constants/actionTypes.js'
import {
selectBasemap,
toggleBasemapExpand,
toggleBasemapVisibility,
changeBasemapOpacity,
} from '../basemap.js'

describe('selectBasemap', () => {
it('creates a BASEMAP_SELECTED action', () => {
const payload = { id: 'osm' }

expect(selectBasemap(payload)).toEqual({
type: types.BASEMAP_SELECTED,
payload,
})
})
})

describe('toggleBasemapExpand', () => {
it('creates a BASEMAP_TOGGLE_EXPAND action', () => {
expect(toggleBasemapExpand()).toEqual({
type: types.BASEMAP_TOGGLE_EXPAND,
})
})
})

describe('toggleBasemapVisibility', () => {
it('creates a BASEMAP_TOGGLE_VISIBILITY action', () => {
expect(toggleBasemapVisibility()).toEqual({
type: types.BASEMAP_TOGGLE_VISIBILITY,
})
})
})

describe('changeBasemapOpacity', () => {
it('creates a BASEMAP_CHANGE_OPACITY action', () => {
expect(changeBasemapOpacity(0.5)).toEqual({
type: types.BASEMAP_CHANGE_OPACITY,
opacity: 0.5,
})
})
})
25 changes: 25 additions & 0 deletions src/actions/__tests__/dataFilters.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as types from '../../constants/actionTypes.js'
import { setDataFilter, clearDataFilter } from '../dataFilters.js'

describe('setDataFilter', () => {
it('creates a DATA_FILTER_SET action', () => {
const filter = { operator: 'eq', value: 1 }

expect(setDataFilter('layer1', 'field1', filter)).toEqual({
type: types.DATA_FILTER_SET,
layerId: 'layer1',
fieldId: 'field1',
filter,
})
})
})

describe('clearDataFilter', () => {
it('creates a DATA_FILTER_CLEAR action', () => {
expect(clearDataFilter('layer1', 'field1')).toEqual({
type: types.DATA_FILTER_CLEAR,
layerId: 'layer1',
fieldId: 'field1',
})
})
})
32 changes: 32 additions & 0 deletions src/actions/__tests__/dataTable.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as types from '../../constants/actionTypes.js'
import {
closeDataTable,
toggleDataTable,
resizeDataTable,
} from '../dataTable.js'

describe('closeDataTable', () => {
it('creates a DATA_TABLE_CLOSE action', () => {
expect(closeDataTable()).toEqual({
type: types.DATA_TABLE_CLOSE,
})
})
})

describe('toggleDataTable', () => {
it('creates a DATA_TABLE_TOGGLE action', () => {
expect(toggleDataTable('layer1')).toEqual({
type: types.DATA_TABLE_TOGGLE,
id: 'layer1',
})
})
})

describe('resizeDataTable', () => {
it('creates a DATA_TABLE_RESIZE action', () => {
expect(resizeDataTable(300)).toEqual({
type: types.DATA_TABLE_RESIZE,
height: 300,
})
})
})
13 changes: 13 additions & 0 deletions src/actions/__tests__/download.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as types from '../../constants/actionTypes.js'
import { setDownloadConfig } from '../download.js'

describe('setDownloadConfig', () => {
it('creates a DOWNLOAD_CONFIG_SET action', () => {
const payload = { format: 'png' }

expect(setDownloadConfig(payload)).toEqual({
type: types.DOWNLOAD_CONFIG_SET,
payload,
})
})
})
36 changes: 36 additions & 0 deletions src/actions/__tests__/feature.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as types from '../../constants/actionTypes.js'
import {
highlightFeature,
setFeatureProfile,
closeFeatureProfile,
} from '../feature.js'

describe('highlightFeature', () => {
it('creates a FEATURE_HIGHLIGHT action', () => {
const payload = { id: 'feat1' }

expect(highlightFeature(payload)).toEqual({
type: types.FEATURE_HIGHLIGHT,
payload,
})
})
})

describe('setFeatureProfile', () => {
it('creates a FEATURE_PROFILE_SET action', () => {
const payload = { id: 'feat1' }

expect(setFeatureProfile(payload)).toEqual({
type: types.FEATURE_PROFILE_SET,
payload,
})
})
})

describe('closeFeatureProfile', () => {
it('creates a FEATURE_PROFILE_CLOSE action', () => {
expect(closeFeatureProfile()).toEqual({
type: types.FEATURE_PROFILE_CLOSE,
})
})
})
21 changes: 21 additions & 0 deletions src/actions/__tests__/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { errorActionCreator } from '../helpers.js'

describe('errorActionCreator', () => {
it('creates an action with the given type and stringified error', () => {
const action = errorActionCreator('SOME_ERROR')(new Error('Oops'))

expect(action).toEqual({
type: 'SOME_ERROR',
error: 'Error: Oops',
})
})

it('stringifies non-Error values', () => {
const action = errorActionCreator('SOME_ERROR')('Something went wrong')

expect(action).toEqual({
type: 'SOME_ERROR',
error: 'Something went wrong',
})
})
})
11 changes: 11 additions & 0 deletions src/actions/__tests__/interpretations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as types from '../../constants/actionTypes.js'
import { setInterpretation } from '../interpretations.js'

describe('setInterpretation', () => {
it('creates an INTERPRETATION_SET action', () => {
expect(setInterpretation('int1')).toEqual({
type: types.INTERPRETATION_SET,
payload: 'int1',
})
})
})
Loading
Loading