Skip to content

Commit

Permalink
move test and fix jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki0410-dev committed Jun 6, 2024
1 parent f52ea2a commit 3136ae0
Show file tree
Hide file tree
Showing 41 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import", "unused-imports"],
parserOptions: {
project: ["./tsconfig.dev.json"],
project: ["./tsconfig.json"],
},
rules: {
"no-unused-vars": "off", // Duplicate with unused-import/no-unused-vars
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
roots: ["./test"],
setupFilesAfterEnv: ["<rootDir>/test/index.ts"],
roots: ["./src/test"],
setupFilesAfterEnv: ["<rootDir>/src/test/index.ts"],
testEnvironment: "jest-environment-jsdom",
collectCoverage: true,
coverageReporters: ["json", "lcov", "text", "clover"],
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"homepage": "https://github.com/Hacker0x01/react-datepicker",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"browser": "dist/react-datepicker.min.js",
"module": "dist/es/index.js",
"unpkg": "dist/react-datepicker.min.js",
Expand Down Expand Up @@ -86,7 +87,7 @@
"react-onclickoutside": "^6.13.0"
},
"scripts": {
"eslint": "eslint --ext .js,.jsx,.ts,.tsx src test",
"eslint": "eslint --ext .js,.jsx,.ts,.tsx ./src",
"precommit": "lint-staged --allow-empty",
"sass-lint": "stylelint 'src/stylesheets/*.scss'",
"lint": "yarn run eslint && yarn run sass-lint",
Expand All @@ -96,15 +97,14 @@
"test": "NODE_ENV=test jest",
"test:ci": "NODE_ENV=test jest --ci --coverage",
"test:watch": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=test jest --watch",
"build": "NODE_ENV=production yarn run build:src && 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 && NODE_ENV=production yarn run build:types",
"build-dev": "NODE_ENV=development yarn run js:dev && NODE_ENV=development yarn run css:dev && NODE_ENV=development yarn run css:modules:dev && NODE_ENV=production yarn run build:types",
"build": "NODE_ENV=production yarn run build:src && 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",
"css:modules:prod": "sass --style compressed src/stylesheets/datepicker-cssmodules.scss | tee dist/react-datepicker-cssmodules.min.css dist/react-datepicker-min.module.css",
"css:dev": "sass --style expanded src/stylesheets/datepicker.scss > dist/react-datepicker.css",
"css:modules:dev": "sass --style expanded src/stylesheets/datepicker-cssmodules.scss | tee dist/react-datepicker-cssmodules.css dist/react-datepicker.module.css",
"type-check": "tsc --noEmit",
"type-check": "tsc --project tsconfig.build.json --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"build:types": "tsc --emitDeclarationOnly",
"build:src": "rollup -c",
"js:dev": "rollup -cw",
"prepare": "husky install"
Expand Down
12 changes: 6 additions & 6 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import typescript from "@rollup/plugin-typescript";
const pkg = JSON.parse(
fs
.readFileSync(
path.join(path.dirname(fileURLToPath(import.meta.url)), "package.json")
path.join(path.dirname(fileURLToPath(import.meta.url)), "package.json"),
)
.toString()
.toString(),
);

const banner = `/*!
Expand All @@ -33,10 +33,10 @@ const dateFnsPackageJson = JSON.parse(
.readFileSync(
path.join(
path.dirname(fileURLToPath(import.meta.url)),
"node_modules/date-fns/package.json"
)
"node_modules/date-fns/package.json",
),
)
.toString()
.toString(),
);
const dateFnsSubpackages = Object.keys(dateFnsPackageJson.exports)
.map((key) => key.replace("./", ""))
Expand Down Expand Up @@ -101,7 +101,7 @@ const config = {
babel(),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
tsconfig: "./tsconfig.build.json",
declaration: true,
declarationDir: "dist",
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";

import CalendarIcon from "../src/calendar_icon";
import CalendarIcon from "../calendar_icon";

import { IconParkSolidApplication } from "./helper_components/calendar_icon";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { eo } from "date-fns/locale/eo";
import { fi } from "date-fns/locale/fi";
import React from "react";

import Calendar from "../src/calendar";
import Calendar from "../calendar";
import {
KeyType,
getMonthInLocale,
Expand All @@ -28,12 +28,12 @@ import {
isSameDay,
subMonths,
subYears,
} from "../src/date_utils";
import DatePicker from "../src/index";
} from "../date_utils";
import DatePicker from "../index";

import { getKey } from "./test_utils";

import type { Locale } from "../src/date_utils";
import type { Locale } from "../date_utils";
import type { Day } from "date-fns";

// TODO Possibly rename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
getMidnightDate,
registerLocale,
isMonthYearDisabled,
} from "../src/date_utils";
} from "../date_utils";

registerLocale("pt-BR", ptBR);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
subMonths,
subWeeks,
subYears,
} from "../src/date_utils";
import DatePicker, { registerLocale } from "../src/index";
} from "../date_utils";
import DatePicker, { registerLocale } from "../index";

import CustomInput from "./helper_components/custom_input";
import TestWrapper from "./helper_components/test_wrapper";
Expand Down
4 changes: 2 additions & 2 deletions test/day_test.test.tsx → src/test/day_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
getHighLightDaysMap,
getHolidaysMap,
registerLocale,
} from "../src/date_utils";
import Day from "../src/day";
} from "../date_utils";
import Day from "../day";

function renderDay(day, props = {}) {
return render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render } from "@testing-library/react";
import { subDays } from "date-fns";
import React from "react";

import DatePicker from "../src/index";
import DatePicker from "../index";

describe("DatePicker", () => {
const excludeDates = [new Date(), subDays(new Date(), 1)];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import * as utils from "../src/date_utils";
import DatePicker from "../src/index";
import * as utils from "../date_utils";
import DatePicker from "../index";

describe("DatePicker", () => {
it("should only display times between minTime and maxTime", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import { setTime, newDate } from "../src/date_utils";
import DatePicker from "../src/index";
import { setTime, newDate } from "../date_utils";
import DatePicker from "../index";

describe("DatePicker", () => {
let now, excludeTimes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import { getHours } from "../src/date_utils";
import TimeComponent from "../src/time";
import { getHours } from "../date_utils";
import TimeComponent from "../time";

describe("TimeComponent", () => {
const HOUR_TO_DISABLE_IN_12_HR = 5;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import * as utils from "../src/date_utils";
import TimeComponent from "../src/time";
import * as utils from "../date_utils";
import TimeComponent from "../time";

describe("TimeComponent", () => {
let today, includeTimes;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import * as utils from "../src/date_utils";
import TimeComponent from "../src/time";
import * as utils from "../date_utils";
import TimeComponent from "../time";

describe("TimeComponent", () => {
it("should show times specified in injectTimes props", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireEvent, render } from "@testing-library/react";
import React, { useState } from "react";

import DatePicker from "../src/index";
import DatePicker from "../index";

const DatePickerWithState = (props) => {
const [selected, setSelected] = useState<Date | null>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import range from "lodash/range";
import React from "react";
import onClickOutside from "react-onclickoutside";

import { getMonthInLocale, registerLocale } from "../src/date_utils";
import MonthDropdown from "../src/month_dropdown";
import MonthDropdownOptions from "../src/month_dropdown_options";
import { getMonthInLocale, registerLocale } from "../date_utils";
import MonthDropdown from "../month_dropdown";
import MonthDropdownOptions from "../month_dropdown_options";

describe("MonthDropdown", () => {
let monthDropdown: HTMLElement | null = null;
Expand Down
6 changes: 3 additions & 3 deletions test/month_test.test.tsx → src/test/month_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { es } from "date-fns/locale";
import range from "lodash/range";
import React from "react";

import DatePicker from "../src";
import * as utils from "../src/date_utils";
import Month from "../src/month";
import DatePicker from "../";
import * as utils from "../date_utils";
import Month from "../month";

import { runAxe } from "./run_axe";
import { getKey } from "./test_utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
formatDate,
isAfter,
registerLocale,
} from "../src/date_utils";
import MonthYearDropdown from "../src/month_year_dropdown";
import MonthYearDropdownOptions from "../src/month_year_dropdown_options";
} from "../date_utils";
import MonthYearDropdown from "../month_year_dropdown";
import MonthYearDropdownOptions from "../month_year_dropdown_options";

describe("MonthYearDropdown", () => {
let monthYearDropdown: HTMLElement | null = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from "@testing-library/react";
import React from "react";

import Calendar from "../src/calendar";
import * as utils from "../src/date_utils";
import Calendar from "../calendar";
import * as utils from "../date_utils";

describe("Multi month calendar", function () {
const dateFormat = "LLLL yyyy";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react";
import React from "react";

import DatePicker from "../src";
import DatePicker from "../";

describe("Multiple Dates Selected", function () {
function getDatePicker(extraProps) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";

import DatePicker from "../src/index";
import TimeComponent from "../src/time";
import DatePicker from "../index";
import TimeComponent from "../time";

describe("DatePicker", () => {
it("should show time component when showTimeSelect prop is present", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.ts → src/test/test_utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyType } from "../src/date_utils";
import { KeyType } from "../date_utils";

interface KeyEvent {
key: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { render, waitFor } from "@testing-library/react";
import { ptBR } from "date-fns/locale/pt-BR";
import React from "react";

import * as utils from "../src/date_utils";
import TimeComponent from "../src/time";
import * as utils from "../date_utils";
import TimeComponent from "../time";

describe("TimeComponent", () => {
utils.registerLocale("pt-BR", ptBR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, fireEvent, act } from "@testing-library/react";
import React from "react";

import DatePicker from "../src/index";
import InputTimeComponent from "../src/input_time";
import DatePicker from "../index";
import InputTimeComponent from "../input_time";

import CustomTimeInput from "./helper_components/custom_time_input";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, fireEvent, waitFor } from "@testing-library/react";
import React from "react";

import { newDate, formatDate, KeyType } from "../src/date_utils";
import DatePicker from "../src/index";
import { newDate, formatDate, KeyType } from "../date_utils";
import DatePicker from "../index";

import { getKey } from "./test_utils";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";

import * as utils from "../src/date_utils";
import WeekNumber from "../src/week_number";
import * as utils from "../date_utils";
import WeekNumber from "../week_number";

function renderWeekNumber(weekNumber, props = {}) {
return render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";

import DatePicker from "../src/index";
import DatePicker from "../index";

describe("WeekPicker", () => {
it("should change the week when clicked on any option in the picker", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/week_test.test.tsx → src/test/week_test.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";

import * as utils from "../src/date_utils";
import Week from "../src/week";
import * as utils from "../date_utils";
import Week from "../week";

describe("Week", () => {
it("should have the week CSS class", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { render, fireEvent } from "@testing-library/react";
import React from "react";
import onClickOutside from "react-onclickoutside";

import * as utils from "../src/date_utils";
import YearDropdownOptions from "../src/year_dropdown_options";
import * as utils from "../date_utils";
import YearDropdownOptions from "../year_dropdown_options";

describe("YearDropdownOptions", () => {
let yearDropdown: HTMLElement | null = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { render, fireEvent } from "@testing-library/react";
import range from "lodash/range";
import React from "react";

import { newDate } from "../src/date_utils";
import YearDropdown from "../src/year_dropdown";
import { newDate } from "../date_utils";
import YearDropdown from "../year_dropdown";

describe("YearDropdown", () => {
let yearDropdown: HTMLElement | null = null;
Expand Down
Loading

0 comments on commit 3136ae0

Please sign in to comment.