@eeacms/volto-timeline-block 1.1.1 → 1.1.2
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/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/src/TimelineBlock/View.test.jsx +77 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [1.1.2](https://github.com/eea/volto-timeline-block/compare/1.1.1...1.1.2) - 24 July 2023
|
|
8
|
+
|
|
7
9
|
### [1.1.1](https://github.com/eea/volto-timeline-block/compare/1.1.0...1.1.1) - 12 June 2023
|
|
8
10
|
|
|
9
11
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { unmountComponentAtNode } from 'react-dom';
|
|
4
|
+
import View from './View';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('@plone/volto/helpers/Loadable/Loadable', () => ({
|
|
9
|
+
injectLazyLibs: () => (component) => component,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock('moment', () => {
|
|
13
|
+
const moment = jest.requireActual('moment');
|
|
14
|
+
|
|
15
|
+
return { default: moment };
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('View and Timeline components', () => {
|
|
19
|
+
let container = null;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
container = document.createElement('div');
|
|
23
|
+
document.body.appendChild(container);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
unmountComponentAtNode(container);
|
|
28
|
+
container.remove();
|
|
29
|
+
container = null;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render empty timeline in edit mode', () => {
|
|
33
|
+
render(<View data={{ items: undefined }} mode="edit" />, container);
|
|
34
|
+
|
|
35
|
+
expect(screen.getByText('Add Timeline items')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should render timeline item with correct data', () => {
|
|
39
|
+
const item = {
|
|
40
|
+
datetime: '2023-01-01',
|
|
41
|
+
title: 'Test Event',
|
|
42
|
+
description: 'Test Description',
|
|
43
|
+
color: 'blue',
|
|
44
|
+
icon: 'star',
|
|
45
|
+
};
|
|
46
|
+
const data = { items: [item], reversed: false };
|
|
47
|
+
|
|
48
|
+
const { getByText } = render(
|
|
49
|
+
<View data={data} mode="view" moment={moment} />,
|
|
50
|
+
container,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(getByText('Test Event')).toBeInTheDocument();
|
|
54
|
+
expect(getByText('Test Description')).toBeInTheDocument();
|
|
55
|
+
expect(getByText('Jan 1, 2023 12:00 AM')).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should render timeline item with correct data', () => {
|
|
59
|
+
const item = {
|
|
60
|
+
datetime: '2023-01-01',
|
|
61
|
+
title: 'Test Event',
|
|
62
|
+
description: 'Test Description',
|
|
63
|
+
color: undefined,
|
|
64
|
+
icon: 'star',
|
|
65
|
+
};
|
|
66
|
+
const data = { items: [item], reversed: true, hideTime: true };
|
|
67
|
+
|
|
68
|
+
const { getByText } = render(
|
|
69
|
+
<View data={data} mode="view" moment={moment} />,
|
|
70
|
+
container,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(getByText('Test Event')).toBeInTheDocument();
|
|
74
|
+
expect(getByText('Test Description')).toBeInTheDocument();
|
|
75
|
+
expect(getByText('Jan 1, 2023')).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
});
|