@transferwise/components 0.0.0-experimental-12689ca → 0.0.0-experimental-b002e6f

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-12689ca",
3
+ "version": "0.0.0-experimental-b002e6f",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -92,8 +92,8 @@
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
94
  "@transferwise/less-config": "3.1.0",
95
- "@wise/components-theming": "1.6.1",
96
- "@transferwise/neptune-css": "14.20.1"
95
+ "@transferwise/neptune-css": "14.20.1",
96
+ "@wise/components-theming": "1.6.1"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
@@ -0,0 +1,69 @@
1
+ import { render, screen } from '../test-utils';
2
+ import SlidingPanel, { SlidingPanelProps } from './SlidingPanel';
3
+
4
+ describe('SlidingPanel', () => {
5
+ const initialProps: SlidingPanelProps = {
6
+ open: true,
7
+ children: <div data-testid="content">Content</div>,
8
+ testId: 'wrapper',
9
+ };
10
+
11
+ const customRender = (overrides: Partial<SlidingPanelProps> = {}) =>
12
+ render(<SlidingPanel {...initialProps} {...overrides} />);
13
+
14
+ describe('open', () => {
15
+ it('should respect open=false', () => {
16
+ customRender({ open: false });
17
+ expect(screen.queryByTestId('wrapper')).not.toBeInTheDocument();
18
+ });
19
+
20
+ it('should respect open=true', () => {
21
+ customRender();
22
+ expect(screen.getByTestId('wrapper')).toBeInTheDocument();
23
+ });
24
+ });
25
+
26
+ describe('position', () => {
27
+ it(`should default to 'left'`, () => {
28
+ customRender();
29
+ expect(screen.queryByTestId('wrapper')).toHaveClass(`sliding-panel--open-left`);
30
+ });
31
+
32
+ (['left', 'right', 'top', 'bottom'] as const).forEach((position) => {
33
+ describe(position, () => {
34
+ it(`should add the classname`, () => {
35
+ customRender({ position });
36
+ expect(screen.queryByTestId('wrapper')).toHaveClass(`sliding-panel--open-${position}`);
37
+ });
38
+
39
+ it(`should add the classname for 'showSlidingPanelBorder'`, () => {
40
+ customRender({ position, showSlidingPanelBorder: true });
41
+ expect(screen.queryByTestId('wrapper')).toHaveClass(`sliding-panel--border-${position}`);
42
+ });
43
+ });
44
+ });
45
+ });
46
+
47
+ it('should render children', () => {
48
+ customRender();
49
+ expect(screen.getByTestId('content')).toBeInTheDocument();
50
+ });
51
+
52
+ it('should respect className', () => {
53
+ const className = 'customClass';
54
+ customRender({ className });
55
+ expect(screen.getByTestId('wrapper')).toHaveClass(className);
56
+ });
57
+
58
+ describe('slidingPanelPositionFixed', () => {
59
+ it('should not be fixed by default', () => {
60
+ customRender();
61
+ expect(screen.getByTestId('wrapper')).not.toHaveClass('sliding-panel--fixed');
62
+ });
63
+
64
+ it('should respect slidingPanelPositionFixed=true', () => {
65
+ customRender({ slidingPanelPositionFixed: true });
66
+ expect(screen.getByTestId('wrapper')).toHaveClass('sliding-panel--fixed');
67
+ });
68
+ });
69
+ });
@@ -1,56 +0,0 @@
1
- import { shallow, mount } from 'enzyme';
2
-
3
- import SlidingPanel from './SlidingPanel';
4
-
5
- describe('SlidingPanel', () => {
6
- let component;
7
- const props = {
8
- open: true,
9
- position: 'left',
10
- children: null,
11
- className: undefined,
12
- slidingPanelPositionFixed: false,
13
- showSlidingPanelBorder: false,
14
- testId: undefined,
15
- };
16
-
17
- it('renders with right props', () => {
18
- component = mount(<SlidingPanel {...props} />);
19
- expect(component.find(SlidingPanel)).toHaveLength(1);
20
- expect(component.find(SlidingPanel).props()).toStrictEqual({ ...props });
21
- });
22
-
23
- it('renders CSSTransition with right props', () => {
24
- component = shallow(<SlidingPanel {...props} />);
25
-
26
- expect(cssTransition()).toHaveLength(1);
27
-
28
- expect(cssTransition().props()).toEqual({
29
- className: 'sliding-panel sliding-panel--open-left',
30
- children: null,
31
- });
32
- });
33
-
34
- it('adds fixed class', () => {
35
- component = shallow(<SlidingPanel {...props} slidingPanelPositionFixed />);
36
- expect(cssTransition().prop('className')).toBe(
37
- 'sliding-panel sliding-panel--open-left sliding-panel--fixed',
38
- );
39
- });
40
-
41
- it('adds border classes if showSlidingPanelBorder is set to true', () => {
42
- component = shallow(<SlidingPanel {...props} showSlidingPanelBorder />);
43
- expect(cssTransition().prop('className')).toBe(
44
- 'sliding-panel sliding-panel--open-left sliding-panel--border-left',
45
- );
46
- component = shallow(<SlidingPanel {...props} showSlidingPanelBorder={false} position="left" />);
47
- expect(cssTransition().prop('className')).toBe('sliding-panel sliding-panel--open-left');
48
-
49
- component = shallow(<SlidingPanel {...props} showSlidingPanelBorder position="top" />);
50
- expect(cssTransition().prop('className')).toBe(
51
- 'sliding-panel sliding-panel--open-top sliding-panel--border-top',
52
- );
53
- });
54
-
55
- const cssTransition = () => component.find('div');
56
- });