Skip to content

Commit 3aff02a

Browse files
committed
Fix indentation
Fix toast default props
1 parent 92ad7e4 commit 3aff02a

File tree

6 files changed

+521
-532
lines changed

6 files changed

+521
-532
lines changed

src/__tests__/actions.ts

+114-113
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,127 @@
11
import * as actions from '../actions';
22
import * as types from '../types';
3-
import {toast} from 'react-toastify';
3+
import {toast, ToastType} from 'react-toastify';
44

55
describe('actions', () => {
6-
const message = 'Foo bar';
6+
const message = 'Foo bar';
77

8-
describe('message', () => {
9-
it('should create an action to add a default toast', () => {
10-
const expectedAction = {
11-
type: types.TOAST_MESSAGE,
12-
payload: {
13-
id: 'toast1',
14-
type: toast.TYPE.DEFAULT,
15-
message
16-
}
17-
};
18-
expect(actions.message(message)).toEqual(expectedAction);
19-
});
20-
});
8+
describe('message', () => {
9+
it('should create an action to add a default toast', () => {
10+
const expectedAction = {
11+
type: types.TOAST_MESSAGE,
12+
payload: {
13+
id: 'toast1',
14+
type: toast.TYPE.DEFAULT,
15+
message,
16+
title: 'foo bar'
17+
}
18+
};
19+
expect(actions.message(message, {title: 'foo bar'})).toEqual(expectedAction);
20+
});
21+
});
2122

22-
describe('error', () => {
23-
it('should create an action to add a error toast', () => {
24-
const expectedAction = {
25-
type: types.TOAST_MESSAGE,
26-
payload: {
27-
id: 'toast2',
28-
type: toast.TYPE.ERROR,
29-
message
30-
}
31-
};
32-
expect(actions.error(message)).toEqual(expectedAction);
33-
});
34-
});
23+
describe('error', () => {
24+
it('should create an action to add a error toast', () => {
25+
const expectedAction = {
26+
type: types.TOAST_MESSAGE,
27+
payload: {
28+
id: 'toast2',
29+
type: toast.TYPE.ERROR,
30+
message
31+
}
32+
};
33+
expect(actions.error(message)).toEqual(expectedAction);
34+
});
35+
});
3536

36-
describe('success', () => {
37-
it('should create an action to add a success toast', () => {
38-
const expectedAction = {
39-
type: types.TOAST_MESSAGE,
40-
payload: {
41-
id: 'toast3',
42-
type: toast.TYPE.SUCCESS,
43-
message
44-
}
45-
};
46-
expect(actions.success(message)).toEqual(expectedAction);
47-
});
48-
});
37+
describe('success', () => {
38+
it('should create an action to add a success toast', () => {
39+
const expectedAction = {
40+
type: types.TOAST_MESSAGE,
41+
payload: {
42+
id: 'toast3',
43+
type: toast.TYPE.SUCCESS,
44+
message
45+
}
46+
};
47+
expect(actions.success(message)).toEqual(expectedAction);
48+
});
49+
});
4950

50-
describe('info', () => {
51-
it('should create an action to add a info toast', () => {
52-
const expectedAction = {
53-
type: types.TOAST_MESSAGE,
54-
payload: {
55-
id: 'toast4',
56-
type: toast.TYPE.INFO,
57-
message
58-
}
59-
};
60-
expect(actions.info(message)).toEqual(expectedAction);
61-
});
62-
});
51+
describe('info', () => {
52+
it('should create an action to add a info toast', () => {
53+
const expectedAction = {
54+
type: types.TOAST_MESSAGE,
55+
payload: {
56+
id: 'toast4',
57+
type: toast.TYPE.INFO,
58+
message
59+
}
60+
};
61+
expect(actions.info(message)).toEqual(expectedAction);
62+
});
63+
});
6364

64-
describe('warning', () => {
65-
it('should create an action to add a warning toast', () => {
66-
const expectedAction = {
67-
type: types.TOAST_MESSAGE,
68-
payload: {
69-
id: 'toast5',
70-
type: toast.TYPE.WARNING,
71-
message
72-
}
73-
};
74-
expect(actions.warning(message)).toEqual(expectedAction);
75-
});
76-
});
65+
describe('warning', () => {
66+
it('should create an action to add a warning toast', () => {
67+
const expectedAction = {
68+
type: types.TOAST_MESSAGE,
69+
payload: {
70+
id: 'toast5',
71+
type: toast.TYPE.WARNING,
72+
message
73+
}
74+
};
75+
expect(actions.warning(message)).toEqual(expectedAction);
76+
});
77+
});
7778

78-
describe('dismiss', () => {
79-
it('should create an action to dismiss a toast', () => {
80-
const expectedAction = {
81-
type: types.TOAST_DISMISS,
82-
payload: {
83-
id: 'toast1'
84-
}
85-
};
86-
expect(actions.dismiss('toast1')).toEqual(expectedAction);
87-
});
88-
});
79+
describe('dismiss', () => {
80+
it('should create an action to dismiss a toast', () => {
81+
const expectedAction = {
82+
type: types.TOAST_DISMISS,
83+
payload: {
84+
id: 'toast1'
85+
}
86+
};
87+
expect(actions.dismiss('toast1')).toEqual(expectedAction);
88+
});
89+
});
8990

90-
describe('update', () => {
91-
it('should create an action to update a toast', () => {
92-
const updateOptions = {
93-
message: 'Hello world',
94-
position: toast.POSITION.BOTTOM_CENTER
95-
};
96-
const expectedAction = {
97-
type: types.TOAST_UPDATE,
98-
payload: {
99-
id: 'toast1',
100-
options: {...updateOptions}
101-
}
102-
};
103-
expect(actions.update('toast1', updateOptions)).toEqual(expectedAction);
104-
});
105-
});
91+
describe('update', () => {
92+
it('should create an action to update a toast', () => {
93+
const updateOptions = {
94+
message: 'Hello world',
95+
position: toast.POSITION.BOTTOM_CENTER
96+
};
97+
const expectedAction = {
98+
type: types.TOAST_UPDATE,
99+
payload: {
100+
id: 'toast1',
101+
options: {...updateOptions}
102+
}
103+
};
104+
expect(actions.update('toast1', updateOptions)).toEqual(expectedAction);
105+
});
106+
});
106107

107-
describe('toastActionCreator', () => {
108-
it('should create an action to add a default toast', () => {
109-
const options = {
110-
title: 'Default message',
111-
message: 'Hello world',
112-
position: toast.POSITION.BOTTOM_CENTER
113-
};
114-
const expectedAction = {
115-
type: types.TOAST_MESSAGE,
116-
payload: {
117-
type: toast.TYPE.DEFAULT,
118-
id: 'toast6',
119-
...options,
120-
message
121-
}
122-
};
123-
expect(actions.toastActionCreator(toast.TYPE.DEFAULT)(message, options)).toEqual(expectedAction);
124-
});
125-
});
108+
describe('toastActionCreator', () => {
109+
it('should create an action to add a default toast', () => {
110+
const options = {
111+
title: 'Default message',
112+
message: 'Hello world',
113+
position: toast.POSITION.BOTTOM_CENTER
114+
};
115+
const expectedAction = {
116+
type: types.TOAST_MESSAGE,
117+
payload: {
118+
type: toast.TYPE.DEFAULT,
119+
id: 'toast6',
120+
...options,
121+
message
122+
}
123+
};
124+
expect(actions.toastActionCreator(toast.TYPE.DEFAULT as ToastType)(message, options)).toEqual(expectedAction);
125+
});
126+
});
126127
});

0 commit comments

Comments
 (0)