Skip to content

Commit 0c302be

Browse files
committed
more jest config; more tests
1 parent 17f9c09 commit 0c302be

11 files changed

+334
-258
lines changed

NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Notes for next 4.x release.
22

33
- Minimum react version updated to 16.8.0 (hooks)
4+
- typings now permit any native props on <select> fields

config/jest-setup.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

jest.config.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,10 @@ const config = {
3131
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
3232
// modulePathIgnorePatterns: [],
3333

34-
// Activates notifications for test results
35-
// notify: false,
36-
37-
// An enum that specifies notification mode. Requires { notify: true }
38-
// notifyMode: "failure-change",
39-
40-
// Reset the module registry before running each individual test
41-
// resetModules: false,
42-
43-
// A path to a custom resolver
44-
// resolver: undefined,
45-
46-
// Allows you to use a custom runner instead of Jest's default test runner
47-
// runner: "jest-runner",
48-
4934
// The paths to modules that run some code to configure or set up the testing environment before each test
5035
// setupFiles: [],
5136

52-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
53-
// setupFilesAfterEnv: [],
37+
setupFilesAfterEnv: ['<rootDir>/config/jest-setup.js'],
5438

5539
// The number of seconds after which a test is considered as slow and reported as such in the results.
5640
// slowTestThreshold: 5,

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@rollup/plugin-typescript": "^12.1.1",
5252
"@testing-library/react": "^16.0.1",
5353
"@testing-library/dom": "^10.4.0",
54+
"@testing-library/jest-dom": "^6.6.3",
5455
"@types/jest": "^29.5.14"
5556
},
5657
"files": [

src/RegionDropdown.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FC, useMemo } from 'react';
2-
import CountryRegionData from 'country-region-data/data.json';
2+
import CountryRegionData from '../node_modules/country-region-data/data.json';
33
import { filterRegions } from './helpers';
44
import * as C from './constants';
55
import type { RegionDropdownProps } from './rcrs.types';
@@ -31,24 +31,24 @@ export const RegionDropdown: FC<RegionDropdownProps> = ({
3131
}
3232

3333
const searchIndex = countryValueType === 'full' ? 0 : 1;
34-
let regionArray = [];
34+
let regionArray: any = [];
3535
CountryRegionData.forEach((i) => {
3636
if (i[searchIndex] === country) {
37-
// regionArray = i;
37+
regionArray = i;
3838
}
3939
});
4040

4141
// this could happen if the user is managing the state of the region/country themselves and screws up passing
4242
// in a valid country
43-
if (!regions || regions.length === 0) {
43+
if (!regionArray || regionArray.length === 0) {
4444
console.error(
4545
'Error. Unknown country passed: ' +
4646
country +
4747
'. If you\'re passing a country shortcode, be sure to include countryValueType="short" on the RegionDropdown'
4848
);
4949
return [];
5050
}
51-
const filteredRegions = filterRegions(regions, whitelist, blacklist);
51+
const filteredRegions = filterRegions(regionArray, whitelist, blacklist);
5252

5353
return filteredRegions[2]
5454
.split(C.REGION_LIST_DELIMITER)

src/__tests__/CountryDropdown.js

-167
This file was deleted.

0 commit comments

Comments
 (0)