@shopgate/pwa-common 7.31.5-beta.6 → 7.31.6-beta.1
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/helpers/mocks/mockRenderOptions.js +21 -0
- package/package.json +3 -3
- package/action-creators/app/spec.js +0 -96
- package/action-creators/client/spec.js +0 -44
- package/action-creators/menu/spec.js +0 -37
- package/action-creators/modal/spec.js +0 -26
- package/action-creators/page/spec.js +0 -38
- package/action-creators/url/spec.js +0 -45
- package/action-creators/user/spec.js +0 -186
- package/components/Backdrop/spec.js +0 -24
- package/components/Button/spec.js +0 -42
- package/components/Checkbox/spec.js +0 -111
- package/components/CountdownTimer/spec.js +0 -141
- package/components/Drawer/spec.js +0 -79
- package/components/Ellipsis/spec.js +0 -15
- package/components/EmbeddedMedia/spec.js +0 -61
- package/components/Grid/components/Item/spec.js +0 -24
- package/components/Grid/spec.js +0 -24
- package/components/HtmlSanitizer/spec.js +0 -229
- package/components/I18n/components/FormatDate/spec.js +0 -54
- package/components/I18n/components/FormatNumber/spec.js +0 -51
- package/components/I18n/components/FormatPrice/spec.js +0 -54
- package/components/I18n/components/FormatTime/spec.js +0 -51
- package/components/I18n/components/I18nProvider/spec.js +0 -40
- package/components/I18n/components/Placeholder/spec.js +0 -37
- package/components/I18n/components/Translate/spec.js +0 -33
- package/components/InfiniteContainer/spec.js +0 -204
- package/components/Input/spec.js +0 -123
- package/components/Link/spec.js +0 -60
- package/components/List/spec.js +0 -26
- package/components/ModalContainer/spec.js +0 -115
- package/components/Select/spec.js +0 -122
- package/components/SelectBox/spec.js +0 -68
- package/components/Swiper/components/SwiperItem/spec.js +0 -26
- package/components/Widgets/components/Widget/spec.js +0 -75
- package/components/Widgets/components/WidgetGrid/spec.js +0 -53
- package/components/Widgets/spec.js +0 -234
- package/helpers/data/spec.js +0 -194
- package/helpers/date/spec.js +0 -92
- package/helpers/style/spec.js +0 -108
- package/helpers/validation/spec.js +0 -10
- package/providers/toast/spec.js +0 -105
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
const options = {
|
|
3
|
+
context: {
|
|
4
|
+
i18n: () => ({
|
|
5
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
6
|
+
__(input) {
|
|
7
|
+
if (input) {
|
|
8
|
+
return input;
|
|
9
|
+
}
|
|
10
|
+
return '';
|
|
11
|
+
},
|
|
12
|
+
_p: () => 'p',
|
|
13
|
+
_d: () => 'd',
|
|
14
|
+
_n: () => 'n'
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
childContextTypes: {
|
|
18
|
+
i18n: PropTypes.func
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export default options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.31.
|
|
3
|
+
"version": "7.31.6-beta.1",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@redux-devtools/extension": "^3.3.0",
|
|
19
19
|
"@sentry/browser": "6.0.1",
|
|
20
|
-
"@shopgate/pwa-benchmark": "7.31.
|
|
20
|
+
"@shopgate/pwa-benchmark": "7.31.6-beta.1",
|
|
21
21
|
"@virtuous/conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/react-conductor": "~2.5.0",
|
|
23
23
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"swiper": "12.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@shopgate/pwa-core": "7.31.
|
|
43
|
+
"@shopgate/pwa-core": "7.31.6-beta.1",
|
|
44
44
|
"@types/lodash": "^4.17.24",
|
|
45
45
|
"@types/react-portal": "^3.0.9",
|
|
46
46
|
"lodash": "^4.17.23",
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { APP_WILL_START, APP_DID_START, PWA_DID_APPEAR, PWA_DID_DISAPPEAR, WILL_REGISTER_LINK_EVENTS, DID_REGISTER_LINK_EVENTS, OPEN_DEEP_LINK, OPEN_PUSH_NOTIFICATION, OPEN_UNIVERSAL_LINK } from "../../constants/ActionTypes";
|
|
2
|
-
import { appWillStart, appDidStart, pwaDidAppear, pwaDidDisappear, willRegisterLinkEvents, didRegisterLinkEvents, openDeepLink, openPushNotification, openUniversalLink } from "./index";
|
|
3
|
-
const dataMock = {
|
|
4
|
-
some: 'data'
|
|
5
|
-
};
|
|
6
|
-
describe('Action Creators: app', () => {
|
|
7
|
-
describe('appWillStart()', () => {
|
|
8
|
-
it('should work as expected', () => {
|
|
9
|
-
const expected = {
|
|
10
|
-
type: APP_WILL_START,
|
|
11
|
-
location: dataMock
|
|
12
|
-
};
|
|
13
|
-
expect(appWillStart(dataMock)).toEqual(expected);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe('appDidStart()', () => {
|
|
17
|
-
it('should work as expected', () => {
|
|
18
|
-
const expected = {
|
|
19
|
-
type: APP_DID_START
|
|
20
|
-
};
|
|
21
|
-
expect(appDidStart()).toEqual(expected);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('pwaDidAppear()', () => {
|
|
25
|
-
it('should work as expected', () => {
|
|
26
|
-
const expected = {
|
|
27
|
-
type: PWA_DID_APPEAR
|
|
28
|
-
};
|
|
29
|
-
expect(pwaDidAppear()).toEqual(expected);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('pwaDidDisappear()', () => {
|
|
33
|
-
it('should work as expected', () => {
|
|
34
|
-
const expected = {
|
|
35
|
-
type: PWA_DID_DISAPPEAR
|
|
36
|
-
};
|
|
37
|
-
expect(pwaDidDisappear()).toEqual(expected);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('willRegisterLinkEvents()', () => {
|
|
41
|
-
it('should work as expected', () => {
|
|
42
|
-
const expected = {
|
|
43
|
-
type: WILL_REGISTER_LINK_EVENTS
|
|
44
|
-
};
|
|
45
|
-
expect(willRegisterLinkEvents()).toEqual(expected);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe('didRegisterLinkEvents()', () => {
|
|
49
|
-
it('should work as expected', () => {
|
|
50
|
-
const expected = {
|
|
51
|
-
type: DID_REGISTER_LINK_EVENTS
|
|
52
|
-
};
|
|
53
|
-
expect(didRegisterLinkEvents()).toEqual(expected);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('openDeepLink()', () => {
|
|
57
|
-
it('should work as expected', () => {
|
|
58
|
-
const expected = {
|
|
59
|
-
type: OPEN_DEEP_LINK,
|
|
60
|
-
payload: dataMock
|
|
61
|
-
};
|
|
62
|
-
expect(openDeepLink(dataMock)).toEqual(expected);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe('openPushNotification()', () => {
|
|
66
|
-
const notificationId = 'abc123';
|
|
67
|
-
const link = '/link/to/somewhere';
|
|
68
|
-
it('should work as expected', () => {
|
|
69
|
-
const expected = {
|
|
70
|
-
type: OPEN_PUSH_NOTIFICATION,
|
|
71
|
-
notificationId,
|
|
72
|
-
link
|
|
73
|
-
};
|
|
74
|
-
expect(openPushNotification(notificationId, link)).toEqual(expected);
|
|
75
|
-
});
|
|
76
|
-
it('should work as expected when the link is empty', () => {
|
|
77
|
-
const expected = {
|
|
78
|
-
type: OPEN_PUSH_NOTIFICATION,
|
|
79
|
-
notificationId,
|
|
80
|
-
link: ''
|
|
81
|
-
};
|
|
82
|
-
expect(openPushNotification(notificationId)).toEqual(expected);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('openUniversalLink()', () => {
|
|
86
|
-
const expected = {
|
|
87
|
-
type: OPEN_UNIVERSAL_LINK,
|
|
88
|
-
payload: {
|
|
89
|
-
link: 'https://testshop.shopgate.com/item/313131313132',
|
|
90
|
-
wasOpenedFromSearchIndex: true,
|
|
91
|
-
linkSerial: 1003
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
expect(openUniversalLink(expected.payload)).toEqual(expected);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { requestClientInformation, receiveClientInformation, errorClientInformation, receiveClientConnectivity } from "./index";
|
|
2
|
-
import { REQUEST_CLIENT_INFORMATION, RECEIVE_CLIENT_INFORMATION, ERROR_CLIENT_INFORMATION, RECEIVE_CLIENT_CONNECTIVITY } from "../../constants/ActionTypes";
|
|
3
|
-
describe('Action Creators: client', () => {
|
|
4
|
-
describe('requestClientInformation()', () => {
|
|
5
|
-
it('should work as expected', () => {
|
|
6
|
-
const expected = {
|
|
7
|
-
type: REQUEST_CLIENT_INFORMATION
|
|
8
|
-
};
|
|
9
|
-
expect(requestClientInformation()).toEqual(expected);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe('receiveClientInformation()', () => {
|
|
13
|
-
it('should work as expected', () => {
|
|
14
|
-
const data = {
|
|
15
|
-
some: 'data'
|
|
16
|
-
};
|
|
17
|
-
const expected = {
|
|
18
|
-
type: RECEIVE_CLIENT_INFORMATION,
|
|
19
|
-
data
|
|
20
|
-
};
|
|
21
|
-
expect(receiveClientInformation(data)).toEqual(expected);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('errorClientInformation()', () => {
|
|
25
|
-
it('should work as expected', () => {
|
|
26
|
-
const expected = {
|
|
27
|
-
type: ERROR_CLIENT_INFORMATION
|
|
28
|
-
};
|
|
29
|
-
expect(errorClientInformation()).toEqual(expected);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('receiveClientConnectivity()', () => {
|
|
33
|
-
it('should work as expected', () => {
|
|
34
|
-
const data = {
|
|
35
|
-
some: 'data'
|
|
36
|
-
};
|
|
37
|
-
const expected = {
|
|
38
|
-
type: RECEIVE_CLIENT_CONNECTIVITY,
|
|
39
|
-
data
|
|
40
|
-
};
|
|
41
|
-
expect(receiveClientConnectivity(data)).toEqual(expected);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { REQUEST_MENU, RECEIVE_MENU, ERROR_MENU } from "../../constants/ActionTypes";
|
|
2
|
-
import { requestMenu, receiveMenu, errorMenu } from "./index";
|
|
3
|
-
const entries = [{
|
|
4
|
-
url: '/',
|
|
5
|
-
label: 'Page Label'
|
|
6
|
-
}];
|
|
7
|
-
const id = 'quicklinks';
|
|
8
|
-
describe('Action Creators: menu', () => {
|
|
9
|
-
describe('requestMenu()', () => {
|
|
10
|
-
it('should work as expected', () => {
|
|
11
|
-
const expected = {
|
|
12
|
-
type: REQUEST_MENU,
|
|
13
|
-
id
|
|
14
|
-
};
|
|
15
|
-
expect(requestMenu(id)).toEqual(expected);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('receiveMenu()', () => {
|
|
19
|
-
it('should work as expected', () => {
|
|
20
|
-
const expected = {
|
|
21
|
-
type: RECEIVE_MENU,
|
|
22
|
-
id,
|
|
23
|
-
entries
|
|
24
|
-
};
|
|
25
|
-
expect(receiveMenu(id, entries)).toEqual(expected);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('errorMenu()', () => {
|
|
29
|
-
it('should work as expected', () => {
|
|
30
|
-
const expected = {
|
|
31
|
-
type: ERROR_MENU,
|
|
32
|
-
id
|
|
33
|
-
};
|
|
34
|
-
expect(errorMenu(id)).toEqual(expected);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CREATE_MODAL, REMOVE_MODAL } from "../../constants/ActionTypes";
|
|
2
|
-
import { createModal, removeModal } from "./index";
|
|
3
|
-
const options = {
|
|
4
|
-
some: 'data'
|
|
5
|
-
};
|
|
6
|
-
const id = 'modalId';
|
|
7
|
-
describe('Action Creators: modal', () => {
|
|
8
|
-
describe('createModal()', () => {
|
|
9
|
-
it('should work as expected', () => {
|
|
10
|
-
const expected = {
|
|
11
|
-
type: CREATE_MODAL,
|
|
12
|
-
options
|
|
13
|
-
};
|
|
14
|
-
expect(createModal(options)).toEqual(expected);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('removeModal()', () => {
|
|
18
|
-
it('should work as expected', () => {
|
|
19
|
-
const expected = {
|
|
20
|
-
type: REMOVE_MODAL,
|
|
21
|
-
id
|
|
22
|
-
};
|
|
23
|
-
expect(removeModal(id)).toEqual(expected);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { REQUEST_PAGE_CONFIG, RECEIVE_PAGE_CONFIG, ERROR_PAGE_CONFIG } from "../../constants/ActionTypes";
|
|
2
|
-
import { requestPageConfig, receivePageConfig, errorPageConfig } from "./index";
|
|
3
|
-
const pageId = 'index';
|
|
4
|
-
const config = {
|
|
5
|
-
some: 'data'
|
|
6
|
-
};
|
|
7
|
-
describe('Action Creators: page', () => {
|
|
8
|
-
describe('requestPageConfig()', () => {
|
|
9
|
-
it('should work as expected', () => {
|
|
10
|
-
const expected = {
|
|
11
|
-
type: REQUEST_PAGE_CONFIG,
|
|
12
|
-
pageId
|
|
13
|
-
};
|
|
14
|
-
expect(requestPageConfig(pageId)).toEqual(expected);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('receivePageConfig()', () => {
|
|
18
|
-
it('should work as expected', () => {
|
|
19
|
-
const expected = {
|
|
20
|
-
type: RECEIVE_PAGE_CONFIG,
|
|
21
|
-
pageId,
|
|
22
|
-
config
|
|
23
|
-
};
|
|
24
|
-
expect(receivePageConfig(pageId, config)).toEqual(expected);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('errorPageConfig()', () => {
|
|
28
|
-
it('should work as expected', () => {
|
|
29
|
-
const errorCode = 'error';
|
|
30
|
-
const expected = {
|
|
31
|
-
type: ERROR_PAGE_CONFIG,
|
|
32
|
-
errorCode,
|
|
33
|
-
pageId
|
|
34
|
-
};
|
|
35
|
-
expect(errorPageConfig(pageId, errorCode)).toEqual(expected);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { RECEIVE_URL, REQUEST_URL, ERROR_URL } from "../../constants/ActionTypes";
|
|
2
|
-
import { receiveUrl, requestUrl, errorUrl } from "./index";
|
|
3
|
-
const url = 'https://www.myshop.com/checkout';
|
|
4
|
-
const urlType = 'checkout';
|
|
5
|
-
const expires = 123456;
|
|
6
|
-
describe('Action Creators: url', () => {
|
|
7
|
-
describe('receiveUrl()', () => {
|
|
8
|
-
it('should work as expected', () => {
|
|
9
|
-
const expected = {
|
|
10
|
-
type: RECEIVE_URL,
|
|
11
|
-
url,
|
|
12
|
-
urlType,
|
|
13
|
-
expires
|
|
14
|
-
};
|
|
15
|
-
expect(receiveUrl(urlType, url, expires)).toEqual(expected);
|
|
16
|
-
});
|
|
17
|
-
it('should work as expected when no expires parameter is passed', () => {
|
|
18
|
-
const expected = {
|
|
19
|
-
type: RECEIVE_URL,
|
|
20
|
-
url,
|
|
21
|
-
urlType,
|
|
22
|
-
expires: null
|
|
23
|
-
};
|
|
24
|
-
expect(receiveUrl(urlType, url)).toEqual(expected);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('requestUrl()', () => {
|
|
28
|
-
it('should work as expected', () => {
|
|
29
|
-
const expected = {
|
|
30
|
-
type: REQUEST_URL,
|
|
31
|
-
urlType
|
|
32
|
-
};
|
|
33
|
-
expect(requestUrl(urlType)).toEqual(expected);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('errorUrl()', () => {
|
|
37
|
-
it('should work as expected', () => {
|
|
38
|
-
const expected = {
|
|
39
|
-
type: ERROR_URL,
|
|
40
|
-
urlType
|
|
41
|
-
};
|
|
42
|
-
expect(errorUrl(urlType)).toEqual(expected);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { requestLogin, successLogin, errorLogin, requestLogout, successLogout, errorLogout, requestUser, receiveUser, errorUser, toggleLoggedIn } from "./index";
|
|
2
|
-
import { REQUEST_LOGIN, SUCCESS_LOGIN, ERROR_LOGIN, REQUEST_LOGOUT, SUCCESS_LOGOUT, ERROR_LOGOUT, REQUEST_USER, RECEIVE_USER, ERROR_USER, TOGGLE_LOGGED_IN } from "../../constants/ActionTypes";
|
|
3
|
-
import { DEFAULT_LOGIN_STRATEGY } from "../../constants/user";
|
|
4
|
-
const messages = [{
|
|
5
|
-
type: 'EUNKNOWN',
|
|
6
|
-
message: 'Something went wrong',
|
|
7
|
-
code: 1337
|
|
8
|
-
}];
|
|
9
|
-
describe('Action Creators: user', () => {
|
|
10
|
-
describe('requestLogin()', () => {
|
|
11
|
-
it('should work as expected', () => {
|
|
12
|
-
const user = 'super@user.com';
|
|
13
|
-
const password = 'super#password';
|
|
14
|
-
const expected = {
|
|
15
|
-
type: REQUEST_LOGIN,
|
|
16
|
-
user,
|
|
17
|
-
password,
|
|
18
|
-
strategy: DEFAULT_LOGIN_STRATEGY
|
|
19
|
-
};
|
|
20
|
-
expect(requestLogin(user, password)).toEqual(expected);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe('successLogin()', () => {
|
|
24
|
-
it('should work as expected with no parameters', () => {
|
|
25
|
-
const expected = {
|
|
26
|
-
type: SUCCESS_LOGIN,
|
|
27
|
-
redirect: undefined,
|
|
28
|
-
strategy: DEFAULT_LOGIN_STRATEGY
|
|
29
|
-
};
|
|
30
|
-
expect(successLogin()).toEqual(expected);
|
|
31
|
-
});
|
|
32
|
-
it('should work as expected with parameters', () => {
|
|
33
|
-
const redirect = '/some/url';
|
|
34
|
-
const strategy = 'custom';
|
|
35
|
-
const expected = {
|
|
36
|
-
type: SUCCESS_LOGIN,
|
|
37
|
-
redirect,
|
|
38
|
-
strategy
|
|
39
|
-
};
|
|
40
|
-
expect(successLogin(redirect, strategy)).toEqual(expected);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe('errorLogin()', () => {
|
|
44
|
-
it('should work as expected', () => {
|
|
45
|
-
const expected = {
|
|
46
|
-
type: ERROR_LOGIN,
|
|
47
|
-
code: 'EUNKNOWN',
|
|
48
|
-
messages
|
|
49
|
-
};
|
|
50
|
-
expect(errorLogin(messages, 'EUNKNOWN')).toEqual(expected);
|
|
51
|
-
});
|
|
52
|
-
it('should work as expected when the messages parameter is empty', () => {
|
|
53
|
-
const expected = {
|
|
54
|
-
type: ERROR_LOGIN,
|
|
55
|
-
code: 'EUNKNOWN',
|
|
56
|
-
messages: []
|
|
57
|
-
};
|
|
58
|
-
expect(errorLogin(undefined, 'EUNKNOWN')).toEqual(expected);
|
|
59
|
-
});
|
|
60
|
-
it('should work as expected when the code paramter is empty', () => {
|
|
61
|
-
const expected = {
|
|
62
|
-
type: ERROR_LOGIN,
|
|
63
|
-
code: '',
|
|
64
|
-
messages
|
|
65
|
-
};
|
|
66
|
-
expect(errorLogin(messages)).toEqual(expected);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('requestLogout()', () => {
|
|
70
|
-
it('should work as expected', () => {
|
|
71
|
-
const expected = {
|
|
72
|
-
type: REQUEST_LOGOUT
|
|
73
|
-
};
|
|
74
|
-
expect(requestLogout()).toEqual(expected);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe('successLogout()', () => {
|
|
78
|
-
it('should work as expected when called without parameter', () => {
|
|
79
|
-
const expected = {
|
|
80
|
-
type: SUCCESS_LOGOUT,
|
|
81
|
-
notify: true,
|
|
82
|
-
autoLogout: false
|
|
83
|
-
};
|
|
84
|
-
expect(successLogout()).toEqual(expected);
|
|
85
|
-
});
|
|
86
|
-
it('should work as expected when called with true', () => {
|
|
87
|
-
const expected = {
|
|
88
|
-
type: SUCCESS_LOGOUT,
|
|
89
|
-
notify: true,
|
|
90
|
-
autoLogout: false
|
|
91
|
-
};
|
|
92
|
-
expect(successLogout(true)).toEqual(expected);
|
|
93
|
-
});
|
|
94
|
-
it('should work as expected when called with false', () => {
|
|
95
|
-
const expected = {
|
|
96
|
-
type: SUCCESS_LOGOUT,
|
|
97
|
-
notify: false,
|
|
98
|
-
autoLogout: false
|
|
99
|
-
};
|
|
100
|
-
expect(successLogout(false)).toEqual(expected);
|
|
101
|
-
});
|
|
102
|
-
it('should work as expected when called with autoLogout parameter', () => {
|
|
103
|
-
const expected = {
|
|
104
|
-
type: SUCCESS_LOGOUT,
|
|
105
|
-
notify: true,
|
|
106
|
-
autoLogout: true
|
|
107
|
-
};
|
|
108
|
-
expect(successLogout(undefined, true)).toEqual(expected);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe('errorLogout()', () => {
|
|
112
|
-
it('should work as expected', () => {
|
|
113
|
-
const expected = {
|
|
114
|
-
type: ERROR_LOGOUT,
|
|
115
|
-
messages,
|
|
116
|
-
autoLogout: false
|
|
117
|
-
};
|
|
118
|
-
expect(errorLogout(messages)).toEqual(expected);
|
|
119
|
-
});
|
|
120
|
-
it('should work as expected when the messages parameter is empty', () => {
|
|
121
|
-
const expected = {
|
|
122
|
-
type: ERROR_LOGOUT,
|
|
123
|
-
messages: [],
|
|
124
|
-
autoLogout: false
|
|
125
|
-
};
|
|
126
|
-
expect(errorLogout()).toEqual(expected);
|
|
127
|
-
});
|
|
128
|
-
it('should work as expected when called with autoLogout parameter', () => {
|
|
129
|
-
const expected = {
|
|
130
|
-
type: ERROR_LOGOUT,
|
|
131
|
-
messages,
|
|
132
|
-
autoLogout: true
|
|
133
|
-
};
|
|
134
|
-
expect(errorLogout(messages, true)).toEqual(expected);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
describe('requestUser()', () => {
|
|
138
|
-
it('should work as expected', () => {
|
|
139
|
-
const expected = {
|
|
140
|
-
type: REQUEST_USER
|
|
141
|
-
};
|
|
142
|
-
expect(requestUser()).toEqual(expected);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('receiveUser()', () => {
|
|
146
|
-
it('should work as expected', () => {
|
|
147
|
-
const user = {
|
|
148
|
-
firstName: 'John',
|
|
149
|
-
lastName: 'Doe',
|
|
150
|
-
mail: 'john@doe.com'
|
|
151
|
-
};
|
|
152
|
-
const expected = {
|
|
153
|
-
type: RECEIVE_USER,
|
|
154
|
-
user
|
|
155
|
-
};
|
|
156
|
-
expect(receiveUser(user)).toEqual(expected);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
describe('errorUser()', () => {
|
|
160
|
-
it('should work as expected', () => {
|
|
161
|
-
const err = new Error();
|
|
162
|
-
// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
163
|
-
const expected = {
|
|
164
|
-
type: ERROR_USER,
|
|
165
|
-
error: err
|
|
166
|
-
};
|
|
167
|
-
expect(errorUser(err)).toEqual(expected);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
describe('toggleLoggedIn()', () => {
|
|
171
|
-
it('should toggle to true', () => {
|
|
172
|
-
const expected = {
|
|
173
|
-
type: TOGGLE_LOGGED_IN,
|
|
174
|
-
value: true
|
|
175
|
-
};
|
|
176
|
-
expect(toggleLoggedIn(true)).toEqual(expected);
|
|
177
|
-
});
|
|
178
|
-
it('should toggle to false', () => {
|
|
179
|
-
const expected = {
|
|
180
|
-
type: TOGGLE_LOGGED_IN,
|
|
181
|
-
value: false
|
|
182
|
-
};
|
|
183
|
-
expect(toggleLoggedIn(false)).toEqual(expected);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import Backdrop from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
describe('<Backdrop />', () => {
|
|
6
|
-
let mockOpen;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
mockOpen = jest.fn();
|
|
9
|
-
});
|
|
10
|
-
it('should render', () => {
|
|
11
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Backdrop, {
|
|
12
|
-
isVisible: true
|
|
13
|
-
}));
|
|
14
|
-
expect(wrapper).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
it('should execute callback when Backdrop is clicked', () => {
|
|
17
|
-
const wrapper = mount(/*#__PURE__*/_jsx(Backdrop, {
|
|
18
|
-
isVisible: true,
|
|
19
|
-
onClick: mockOpen
|
|
20
|
-
}));
|
|
21
|
-
wrapper.find('div').simulate('click');
|
|
22
|
-
expect(mockOpen).toBeCalled();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import Button from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
describe('<Button />', () => {
|
|
6
|
-
it('should render the button', () => {
|
|
7
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Button, {
|
|
8
|
-
children: "My content"
|
|
9
|
-
}));
|
|
10
|
-
expect(wrapper).toMatchSnapshot();
|
|
11
|
-
expect(wrapper.find('button').length).toBe(1);
|
|
12
|
-
});
|
|
13
|
-
it('should render the button in disabled state', () => {
|
|
14
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Button, {
|
|
15
|
-
disabled: true,
|
|
16
|
-
children: "My content"
|
|
17
|
-
}));
|
|
18
|
-
expect(wrapper).toMatchSnapshot();
|
|
19
|
-
expect(wrapper.find('button[disabled]').length).toBe(1);
|
|
20
|
-
});
|
|
21
|
-
it('should trigger the click event', () => {
|
|
22
|
-
const callback = jest.fn();
|
|
23
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Button, {
|
|
24
|
-
onClick: callback,
|
|
25
|
-
children: "My content"
|
|
26
|
-
}));
|
|
27
|
-
wrapper.simulate('click');
|
|
28
|
-
expect(wrapper).toMatchSnapshot();
|
|
29
|
-
expect(callback).toHaveBeenCalled();
|
|
30
|
-
});
|
|
31
|
-
it('should not trigger the click event when disabled', () => {
|
|
32
|
-
const callback = jest.fn();
|
|
33
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Button, {
|
|
34
|
-
disabled: true,
|
|
35
|
-
onClick: callback,
|
|
36
|
-
children: "My content"
|
|
37
|
-
}));
|
|
38
|
-
wrapper.simulate('click');
|
|
39
|
-
expect(wrapper).toMatchSnapshot();
|
|
40
|
-
expect(callback).not.toHaveBeenCalled();
|
|
41
|
-
});
|
|
42
|
-
});
|