@bitrise/bitkit 10.35.0-alpha-datepicker-rewrite.1 → 10.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit",
|
|
3
3
|
"description": "Bitrise React component library",
|
|
4
|
-
"version": "10.35.0
|
|
4
|
+
"version": "10.35.0",
|
|
5
5
|
"repository": "git@github.com:bitrise-io/bitkit.git",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -47,8 +47,6 @@
|
|
|
47
47
|
"@chakra-ui/cli": "^2.1.2",
|
|
48
48
|
"@commitlint/cli": "^16.3.0",
|
|
49
49
|
"@commitlint/config-conventional": "^16.2.4",
|
|
50
|
-
"@emotion/cache": "^11.10.3",
|
|
51
|
-
"@emotion/jest": "^11.10.0",
|
|
52
50
|
"@google-cloud/storage": "^5.20.5",
|
|
53
51
|
"@semantic-release/changelog": "^6.0.1",
|
|
54
52
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
2
2
|
import { DateTime } from 'luxon';
|
|
3
|
-
import { CacheProvider } from '@emotion/react';
|
|
4
|
-
import createCache from '@emotion/cache';
|
|
5
3
|
import userEventGlobal from '@testing-library/user-event';
|
|
6
4
|
import Provider from '../Provider/Provider';
|
|
7
|
-
import useResponsive from '../../hooks/useResponsive';
|
|
8
5
|
import DatePicker, { DatePickerProps } from './DatePicker';
|
|
9
6
|
import { DateRange } from './useDateRange';
|
|
10
7
|
|
|
11
|
-
const cache = createCache({ key: 'test', stylisPlugins: [] });
|
|
12
|
-
|
|
13
8
|
jest.mock('../../hooks/useResponsive', () => jest.fn(() => ({ isMobile: false })));
|
|
14
9
|
|
|
15
10
|
jest.useFakeTimers();
|
|
16
11
|
jest.setSystemTime(DateTime.local(2022, 1, 2).toJSDate());
|
|
17
12
|
const userEvent = userEventGlobal.setup({ advanceTimers: (t) => jest.advanceTimersByTime(t) });
|
|
18
13
|
const Subject = (props: Partial<DatePickerProps>) => (
|
|
19
|
-
<
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
</Provider>
|
|
25
|
-
</CacheProvider>
|
|
14
|
+
<Provider>
|
|
15
|
+
<DatePicker onClose={() => {}} visible {...props}>
|
|
16
|
+
<div />
|
|
17
|
+
</DatePicker>
|
|
18
|
+
</Provider>
|
|
26
19
|
);
|
|
27
20
|
describe('DatePicker', () => {
|
|
28
21
|
it('works', async () => {
|
|
@@ -51,34 +44,7 @@ describe('DatePicker', () => {
|
|
|
51
44
|
expect(begin?.toObject()).toMatchObject({ year: 2022, month: 10, day: 23 });
|
|
52
45
|
expect(end?.toObject()).toMatchObject({ year: 2023, month: 2, day: 10 });
|
|
53
46
|
});
|
|
54
|
-
describe('defaults', () => {
|
|
55
|
-
it('renders exactly as before', async () => {
|
|
56
|
-
render(<Subject />);
|
|
57
|
-
expect(document.body).toMatchSnapshot();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('with selectable range', () => {
|
|
61
|
-
it('renders exactly as before', async () => {
|
|
62
|
-
render(<Subject selectable={new DateRange(DateTime.local(2022, 2, 1), DateTime.local(2022, 2, 7))} />);
|
|
63
|
-
expect(document.body).toMatchSnapshot();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
47
|
describe('with range pre-selected', () => {
|
|
67
|
-
describe('when range is entirely inside the current month', () => {
|
|
68
|
-
it('renders exactly as before', () => {
|
|
69
|
-
render(<Subject selected={new DateRange(DateTime.local(2022, 2, 1), DateTime.local(2022, 2, 7))} />);
|
|
70
|
-
expect(document.body).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
describe('on mobile', () => {
|
|
74
|
-
describe('when range is partially in the next month', () => {
|
|
75
|
-
it('renders exactly as before', () => {
|
|
76
|
-
jest.mocked(useResponsive).mockReturnValueOnce({ isMobile: true } as any);
|
|
77
|
-
render(<Subject selected={new DateRange(DateTime.local(2022, 2, 20), DateTime.local(2022, 3, 3))} />);
|
|
78
|
-
expect(document.body).toMatchSnapshot();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
48
|
describe('when range start/end is in the same month', () => {
|
|
83
49
|
it('shows the start month on the left and the next month on the right', async () => {
|
|
84
50
|
render(<Subject selected={new DateRange(DateTime.local(2022, 2, 1), DateTime.local(2022, 2, 7))} />);
|
|
@@ -108,13 +74,6 @@ describe('DatePicker', () => {
|
|
|
108
74
|
});
|
|
109
75
|
});
|
|
110
76
|
describe('month selector', () => {
|
|
111
|
-
it('renders correctly', async () => {
|
|
112
|
-
render(<Subject />);
|
|
113
|
-
const left = await screen.findByRole('button', { name: 'January' });
|
|
114
|
-
await userEvent.click(left);
|
|
115
|
-
await screen.findByRole('spinbutton', { name: 'year' });
|
|
116
|
-
expect(document.body).toMatchSnapshot();
|
|
117
|
-
});
|
|
118
77
|
it('shows current month as selected', async () => {
|
|
119
78
|
render(<Subject />);
|
|
120
79
|
const left = await screen.findByRole('button', { name: 'January' });
|
package/src/index.ts
CHANGED
|
@@ -203,7 +203,7 @@ export type { TextareaProps } from './Components/Form/Textarea/Textarea';
|
|
|
203
203
|
export { default as Textarea } from './Components/Form/Textarea/Textarea';
|
|
204
204
|
|
|
205
205
|
export type { DatePickerProps } from './Components/DatePicker/DatePicker';
|
|
206
|
-
export { default as DatePicker } from './Components/DatePicker/DatePicker';
|
|
206
|
+
export { default as DatePicker, DateRange, useDateRange } from './Components/DatePicker/DatePicker';
|
|
207
207
|
|
|
208
208
|
export type { FadeProps } from './Components/Fade/Fade';
|
|
209
209
|
export { default as Fade } from './Components/Fade/Fade';
|