Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

karma to jest migration completed #4229

Merged
merged 3 commits into from
Sep 1, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
17 changes: 17 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
roots: ["./test"],
setupFiles: ["<rootDir>/test/text_encoder.js"],
setupFilesAfterEnv: ["<rootDir>/test/index.js"],
testEnvironment: "jest-environment-jsdom",
collectCoverageFrom: [
"**/*.{js,jsx}",
"!**/node_modules/**",
"!**/vendor/**",
],
transformIgnorePatterns: ["/node_modules/(?!(@popperjs)|date-fns)"],
transform: {
"^.+\\.(js|jsx)$": "babel-jest",
"^.+\\.ts?$": "ts-jest",
"node_modules/(?!date-fns/.*)": "ts-jest",
},
};
68 changes: 0 additions & 68 deletions karma.conf.js

This file was deleted.

26 changes: 10 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@
"@babel/helpers": "^7.22.6",
"@babel/plugin-external-helpers": "^7.22.5",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.22.7",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.4",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"axe-core": "^4.4.1",
"babel-jest": "^29.6.4",
"babel-loader": "^9.1.3",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"babel-preset-airbnb": "^5.0.0",
"chai": "^4.2.0",
"codecov": "^3.5.0",
"core-js": "^3.29.1",
"css-loader": "^6.8.1",
Expand All @@ -63,17 +65,9 @@
"highlight.js": "^11.0.1",
"husky": "8",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
"karma-coverage": "^2.2.1",
martijnrusschen marked this conversation as resolved.
Show resolved Hide resolved
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"lint-staged": "^14.0.1",
"mocha": "^10.0.0",
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-docgen": "^5.3.0",
Expand All @@ -92,13 +86,13 @@
"rollup-plugin-uglify": "^6.0.4",
"sass": "1.66.1",
martijnrusschen marked this conversation as resolved.
Show resolved Hide resolved
"sass-loader": "^13.3.2",
"sinon": "^15.0.3",
"slugify": "^1.6.6",
"style-loader": "^3.3.3",
"stylelint": "^15.10.1",
"stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "^10.0.0",
"stylelint-scss": "^5.0.1",
"ts-jest": "^29.1.1",
"webpack": "^5.88",
"webpack-cli": "^5.1",
"webpack-dev-middleware": "^6.1.1",
Expand All @@ -124,9 +118,9 @@
"lint": "yarn run eslint && yarn run sass-lint",
"prettier": "prettier --write '**/*.{js,jsx}'",
"start": "yarn --cwd docs-site install && yarn --cwd docs-site start",
"test": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=test karma start karma.conf.js --single-run",
"test:ci": "NODE_ENV=test karma start karma.conf.js --single-run",
"test:watch": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=test karma start karma.conf.js --watch",
"test": "NODE_ENV=test jest",
"test:ci": "NODE_ENV=test jest --ci",
"test:watch": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=test jest --watch",
"build": "NODE_ENV=production yarn run build:js && NODE_ENV=production yarn run css:prod && NODE_ENV=production yarn run css:modules:dev && NODE_ENV=production yarn run css:dev && NODE_ENV=production yarn run css:modules:dev",
"build-dev": "NODE_ENV=development yarn run js:dev && NODE_ENV=development yarn run css:dev && NODE_ENV=development yarn run css:modules:dev",
"css:prod": "sass --style compressed src/stylesheets/datepicker.scss > dist/react-datepicker.min.css",
Expand Down
6 changes: 3 additions & 3 deletions src/day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Day extends React.Component {
handleOnKeyDown: PropTypes.func,
containerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
PropTypes.shape({ current: PropTypes.object }),
]),
monthShowsDuplicateDaysEnd: PropTypes.bool,
monthShowsDuplicateDaysStart: PropTypes.bool,
Expand Down Expand Up @@ -275,7 +275,7 @@ export default class Day extends React.Component {
this.isAfterMonth() || this.isBeforeMonth(),
},
this.getHighLightedClass("react-datepicker__day--highlighted"),
this.getHolidaysClass()
this.getHolidaysClass(),
);
};

Expand Down Expand Up @@ -359,7 +359,7 @@ export default class Day extends React.Component {
}
}

shouldFocusDay && this.dayEl.current.focus({ preventScroll: true });
shouldFocusDay && this.dayEl.current?.focus({ preventScroll: true });
};

renderDayContents = () => {
Expand Down
48 changes: 24 additions & 24 deletions src/month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const MONTH_NAVIGATION_HORIZONTAL_OFFSET = 1;

function getMonthColumnsLayout(
showFourColumnMonthYearPicker,
showTwoColumnMonthYearPicker
showTwoColumnMonthYearPicker,
) {
if (showFourColumnMonthYearPicker) return MONTH_COLUMNS_LAYOUT.FOUR_COLUMNS;
if (showTwoColumnMonthYearPicker) return MONTH_COLUMNS_LAYOUT.TWO_COLUMNS;
Expand All @@ -68,7 +68,7 @@ export default class Month extends React.Component {
PropTypes.shape({
start: PropTypes.instanceOf(Date),
end: PropTypes.instanceOf(Date),
})
}),
),
filterDate: PropTypes.func,
fixedHeight: PropTypes.bool,
Expand Down Expand Up @@ -116,7 +116,7 @@ export default class Month extends React.Component {
weekAriaLabelPrefix: PropTypes.string,
containerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
PropTypes.shape({ current: PropTypes.object }),
]),
monthShowsDuplicateDaysEnd: PropTypes.bool,
monthShowsDuplicateDaysStart: PropTypes.bool,
Expand Down Expand Up @@ -294,7 +294,7 @@ export default class Month extends React.Component {
let currentWeekStart = utils.getStartOfWeek(
utils.getStartOfMonth(this.props.day),
this.props.locale,
this.props.calendarStartDay
this.props.calendarStartDay,
);

while (true) {
Expand Down Expand Up @@ -343,7 +343,7 @@ export default class Month extends React.Component {
calendarStartDay={this.props.calendarStartDay}
monthShowsDuplicateDaysEnd={this.props.monthShowsDuplicateDaysEnd}
monthShowsDuplicateDaysStart={this.props.monthShowsDuplicateDaysStart}
/>
/>,
);

if (breakAfterNextPush) break;
Expand Down Expand Up @@ -373,13 +373,13 @@ export default class Month extends React.Component {
onMonthClick = (e, m) => {
this.handleDayClick(
utils.getStartOfMonth(utils.setMonth(this.props.day, m)),
e
e,
);
};

onMonthMouseEnter = (m) => {
this.handleDayMouseEnter(
utils.getStartOfMonth(utils.setMonth(this.props.day, m))
utils.getStartOfMonth(utils.setMonth(this.props.day, m)),
);
};

Expand Down Expand Up @@ -407,7 +407,7 @@ export default class Month extends React.Component {
if (!disabledKeyboardNavigation) {
const monthColumnsLayout = getMonthColumnsLayout(
showFourColumnMonthYearPicker,
showTwoColumnMonthYearPicker
showTwoColumnMonthYearPicker,
);
const verticalOffset =
MONTH_COLUMNS[monthColumnsLayout].verticalNavigationOffset;
Expand All @@ -420,13 +420,13 @@ export default class Month extends React.Component {
case "ArrowRight":
this.handleMonthNavigation(
month === 11 ? 0 : month + MONTH_NAVIGATION_HORIZONTAL_OFFSET,
utils.addMonths(preSelection, MONTH_NAVIGATION_HORIZONTAL_OFFSET)
utils.addMonths(preSelection, MONTH_NAVIGATION_HORIZONTAL_OFFSET),
);
break;
case "ArrowLeft":
this.handleMonthNavigation(
month === 0 ? 11 : month - MONTH_NAVIGATION_HORIZONTAL_OFFSET,
utils.subMonths(preSelection, MONTH_NAVIGATION_HORIZONTAL_OFFSET)
utils.subMonths(preSelection, MONTH_NAVIGATION_HORIZONTAL_OFFSET),
);
break;
case "ArrowUp":
Expand All @@ -435,7 +435,7 @@ export default class Month extends React.Component {
monthsGrid[0].includes(month)
? month + 12 - verticalOffset
: month - verticalOffset,
utils.subMonths(preSelection, verticalOffset)
utils.subMonths(preSelection, verticalOffset),
);
break;
case "ArrowDown":
Expand All @@ -444,7 +444,7 @@ export default class Month extends React.Component {
monthsGrid[monthsGrid.length - 1].includes(month)
? month - 12 + verticalOffset
: month + verticalOffset,
utils.addMonths(preSelection, verticalOffset)
utils.addMonths(preSelection, verticalOffset),
);
break;
}
Expand All @@ -454,13 +454,13 @@ export default class Month extends React.Component {
onQuarterClick = (e, q) => {
this.handleDayClick(
utils.getStartOfQuarter(utils.setQuarter(this.props.day, q)),
e
e,
);
};

onQuarterMouseEnter = (q) => {
this.handleDayMouseEnter(
utils.getStartOfQuarter(utils.setQuarter(this.props.day, q))
utils.getStartOfQuarter(utils.setQuarter(this.props.day, q)),
);
};

Expand All @@ -482,13 +482,13 @@ export default class Month extends React.Component {
case "ArrowRight":
this.handleQuarterNavigation(
quarter === 4 ? 1 : quarter + 1,
utils.addQuarters(this.props.preSelection, 1)
utils.addQuarters(this.props.preSelection, 1),
);
break;
case "ArrowLeft":
this.handleQuarterNavigation(
quarter === 1 ? 4 : quarter - 1,
utils.subQuarters(this.props.preSelection, 1)
utils.subQuarters(this.props.preSelection, 1),
);
break;
}
Expand Down Expand Up @@ -523,7 +523,7 @@ export default class Month extends React.Component {
"react-datepicker__month-text--selected": this.isSelectedMonth(
day,
m,
selected
selected,
),
"react-datepicker__month-text--keyboard-selected":
!this.props.disabledKeyboardNavigation &&
Expand All @@ -534,7 +534,7 @@ export default class Month extends React.Component {
startDate,
endDate,
m,
day
day,
),
"react-datepicker__month-text--range-start": this.isRangeStartMonth(m),
"react-datepicker__month-text--range-end": this.isRangeEndMonth(m),
Expand All @@ -543,7 +543,7 @@ export default class Month extends React.Component {
"react-datepicker__month-text--selecting-range-end":
this.isSelectingMonthRangeEnd(m),
"react-datepicker__month-text--today": this.isCurrentMonth(day, m),
}
},
);
};

Expand Down Expand Up @@ -603,7 +603,7 @@ export default class Month extends React.Component {
"react-datepicker__quarter-text--selected": this.isSelectedQuarter(
day,
q,
selected
selected,
),
"react-datepicker__quarter-text--keyboard-selected":
utils.getQuarter(preSelection) === q,
Expand All @@ -613,12 +613,12 @@ export default class Month extends React.Component {
startDate,
endDate,
q,
day
day,
),
"react-datepicker__quarter-text--range-start":
this.isRangeStartQuarter(q),
"react-datepicker__quarter-text--range-end": this.isRangeEndQuarter(q),
}
},
);
};

Expand Down Expand Up @@ -652,7 +652,7 @@ export default class Month extends React.Component {
MONTH_COLUMNS[
getMonthColumnsLayout(
showFourColumnMonthYearPicker,
showTwoColumnMonthYearPicker
showTwoColumnMonthYearPicker,
)
].grid;
return monthColumns.map((month, i) => (
Expand Down Expand Up @@ -727,7 +727,7 @@ export default class Month extends React.Component {
selectingDate && (selectsStart || selectsEnd),
},
{ "react-datepicker__monthPicker": showMonthYearPicker },
{ "react-datepicker__quarterPicker": showQuarterYearPicker }
{ "react-datepicker__quarterPicker": showQuarterYearPicker },
);
};

Expand Down