-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
1,049 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Contributing | ||
|
||
## Install | ||
|
||
```sh | ||
# install git repo | ||
git clone git@github.com:bayesimpact/tds-frontend.git | ||
cd tds-frontend | ||
|
||
# install dependencies | ||
yarn | ||
|
||
# recompile and re-run tests when anything changes | ||
yarn run tdd | ||
``` | ||
|
||
Then, open *https://localhost:8081* in your browser. | ||
|
||
## Editor | ||
|
||
I suggest editing this project using [VSCode](https://code.visualstudio.com/). VSCode will automatically suggest a small set of extensions that will surface type and lint errors directly in your editor. It will also auto-format files on save, reducing the need to manually fix lint errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { chain } from 'lodash' | ||
import { averageDistance, averageTime, maxDistance, maxTime, minDistance, minTime, totalPopulation } from './analytics' | ||
|
||
let adequacies1 = chain([ | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 10, timeToClosestProvider: 21, closestProviderByDistance: 63, closestProviderByTime: 63 }, | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 20, timeToClosestProvider: 31, closestProviderByDistance: 63, closestProviderByTime: 63 }, | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 30, timeToClosestProvider: 41, closestProviderByDistance: 63, closestProviderByTime: 63 }, | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 40, timeToClosestProvider: 51, closestProviderByDistance: 63, closestProviderByTime: 63 } | ||
]) | ||
|
||
let adequacies2 = chain([ | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 0, timeToClosestProvider: 0, closestProviderByDistance: 63, closestProviderByTime: 63 }, | ||
{ isAdequate: false, id: 0, distanceToClosestProvider: 0, timeToClosestProvider: 0, closestProviderByDistance: 63, closestProviderByTime: 63 } | ||
]) | ||
|
||
let representativePoints1 = chain([ | ||
{ county: 'Sonoma', id: 1, lat: 123.456, lng: 32.109, population: 100, serviceAreaId: 'Sonoma-90000', zip: '90000' }, | ||
{ county: 'Sonoma', id: 2, lat: 123.457, lng: 32.109, population: 101, serviceAreaId: 'Sonoma-90000', zip: '90001' }, | ||
{ county: 'Sonoma', id: 3, lat: 123.458, lng: 32.109, population: 200, serviceAreaId: 'Sonoma-90000', zip: '90002' }, | ||
{ county: 'Sonoma', id: 4, lat: 123.459, lng: 32.109, population: 102912, serviceAreaId: 'Sonoma-90000', zip: '90003' }, | ||
{ county: 'Sonoma', id: 5, lat: 123.460, lng: 32.109, population: 11, serviceAreaId: 'Sonoma-90000', zip: '90004' } | ||
]) | ||
|
||
let representativePoints2 = chain([ | ||
{ county: 'Napa', id: 6, lat: 123.456, lng: 32.109, population: 0, serviceAreaId: 'Napa-90010', zip: '90010' }, | ||
{ county: 'Napa', id: 7, lat: 123.457, lng: 32.109, population: 0, serviceAreaId: 'Napa-90011', zip: '90011' }, | ||
{ county: 'Napa', id: 8, lat: 123.458, lng: 32.109, population: 0, serviceAreaId: 'Napa-90012', zip: '90012' } | ||
]) | ||
|
||
test('averageDistance', () => { | ||
expect(averageDistance(adequacies1)).toBe(25) | ||
expect(averageDistance(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('maxDistance', () => { | ||
expect(maxDistance(adequacies1)).toBe(40) | ||
expect(maxDistance(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('minDistance', () => { | ||
expect(minDistance(adequacies1)).toBe(10) | ||
expect(minDistance(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('averageTime', () => { | ||
expect(averageTime(adequacies1)).toBe(36) | ||
expect(averageTime(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('maxTime', () => { | ||
expect(maxTime(adequacies1)).toBe(51) | ||
expect(maxTime(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('minTime', () => { | ||
expect(minTime(adequacies1)).toBe(21) | ||
expect(minTime(adequacies2)).toBe(0) | ||
}) | ||
|
||
test('totalPoulation', () => { | ||
expect(totalPopulation(representativePoints1)).toBe(103324) | ||
expect(totalPopulation(representativePoints2)).toBe(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.