update areaDetail with data from d3 CDN (#547)

* update areaDetail with data from d3 CDN

- updated constants with d3 CDN info
- placed AreaDetail component in folder
- fixed J40Alert padding-left console warning
- added tests for both J40Alert rendering

* udpates FE to percentile data

* testing CORS on PR'd URL

* testing PR'd URL
This commit is contained in:
Vim 2021-08-18 08:47:34 -07:00 committed by GitHub
commit d449e9c554
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 85 additions and 40 deletions

View file

@ -0,0 +1,47 @@
import * as React from 'react';
import {render} from '@testing-library/react';
import AreaDetail, {getCategorization, readablePercent} from '..';
import {LocalizedComponent} from '../../../test/testHelpers';
import * as constants from '../../../data/constants';
describe('rendering of the AreaDetail', () => {
const properties = {
[constants.POVERTY_PROPERTY_PERCENTILE]: 99,
[constants.EDUCATION_PROPERTY_PERCENTILE]: 98,
[constants.LINGUISTIC_ISOLATION_PROPERTY_PERCENTILE]: 97,
[constants.UNEMPLOYMENT_PROPERTY_PERCENTILE]: 96,
[constants.HOUSING_BURDEN_PROPERTY_PERCENTILE]: 95,
[constants.SCORE_PROPERTY_HIGH]: 95,
[constants.GEOID_PROPERTY]: 98729374234,
[constants.TOTAL_POPULATION]: 3435435,
};
const {asFragment} = render(
<LocalizedComponent>
<AreaDetail properties={properties}/>
</LocalizedComponent>,
)
;
it('checks if various text fields are visible', () => {
expect(asFragment()).toMatchSnapshot();
});
});
describe('tests the readablePercent function', () => {
expect(readablePercent(.9877665443)).toEqual('98.8');
});
describe('tests the getCategorization function', () => {
it(`should equal Prioritized for value >= ${constants.SCORE_BOUNDARY_LOW}`, () => {
expect(getCategorization(.756)).toEqual(['Prioritized', undefined]);
});
it(`should equal Threshold for .60 <= value < ${constants.SCORE_BOUNDARY_THRESHOLD}`, () => {
expect(getCategorization(.65)).toEqual(['Threshold', undefined]);
});
it(`should equal Non-prioritized for value < ${constants.SCORE_BOUNDARY_PRIORITIZED}`, () => {
expect(getCategorization(.53)).toEqual(['Non-prioritized', undefined]);
});
});