Skip to content

Commit 5563d88

Browse files
authored
BREAKING CHANGE: remove sheet specific methods (#115)
These cases will be handled at mistica level Telefonica/mistica-web#840
1 parent cf6f899 commit 5563d88

3 files changed

Lines changed: 41 additions & 447 deletions

File tree

index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,7 @@ export {renewSession, onSessionRenewed, logout} from './src/sessions';
8686

8787
export {showAppRating} from './src/app-rating';
8888

89-
export {
90-
bottomSheet,
91-
// @deprecated - use Mistica implementation
92-
bottomSheetSingleSelector,
93-
// @deprecated - use Mistica implementation
94-
bottomSheetActionSelector,
95-
// @deprecated - use Mistica implementation
96-
bottomSheetInfo,
97-
} from './src/bottom-sheet';
89+
export {bottomSheet} from './src/bottom-sheet';
9890
export type {
9991
SheetRowItem,
10092
SheetActionItem,

src/__tests__/bottom-sheet-test.ts

Lines changed: 40 additions & 249 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,39 @@
1-
import {
2-
bottomSheetActions,
3-
bottomSheetActionSelector,
4-
bottomSheetInfo,
5-
bottomSheetSingleSelector,
6-
SheetActionItem,
7-
SheetInfoItem,
8-
} from '../bottom-sheet';
1+
import {bottomSheet} from '../bottom-sheet';
92
import {createFakeAndroidPostMessage} from './fake-post-message';
103

11-
import type {SheetRowItem} from '../bottom-sheet';
12-
13-
test('single selection', (done) => {
4+
test('bottomSheet', (done) => {
145
const title = 'any title';
156
const subtitle = 'any subtitle';
167
const description = 'any description';
178
const selectedId = 'item-0';
18-
const items: Array<SheetRowItem> = [
19-
{
20-
id: 'item-0',
21-
title: 'item 0 title',
22-
description: 'item 0 description',
23-
icon: {
24-
url: 'https://example.com/icon.png',
25-
urlDark: 'https://example.com/dark-icon.png',
26-
},
27-
},
28-
{
29-
id: 'item-1',
30-
title: 'item 1 title',
31-
description: 'item 1 description',
32-
},
33-
{
34-
id: 'item-2',
35-
title: 'item 2 title',
36-
description: 'item 2 description',
37-
},
38-
];
39-
40-
createFakeAndroidPostMessage({
41-
checkMessage: (message) => {
42-
expect(message.type).toBe('SHEET');
43-
expect(message.payload).toEqual({
44-
title,
45-
subtitle,
46-
description,
47-
content: [
48-
{
49-
id: 'list-0',
50-
type: 'LIST',
51-
listType: 'SINGLE_SELECTION',
52-
autoSubmit: true,
53-
selectedIds: [selectedId],
54-
items,
55-
},
56-
],
57-
});
58-
},
59-
getResponse: (message) => ({
60-
type: message.type,
61-
id: message.id,
62-
payload: {
63-
action: 'SUBMIT',
64-
result: [
65-
{
66-
id: 'list-0',
67-
selectedIds: ['item-2'],
68-
},
69-
],
70-
},
71-
}),
72-
});
73-
74-
bottomSheetSingleSelector({
75-
title,
76-
subtitle,
77-
description,
78-
selectedId,
79-
items,
80-
}).then((res) => {
81-
expect(res).toEqual({action: 'SUBMIT', selectedId: 'item-2'});
82-
done();
83-
});
84-
});
85-
86-
test('actions', (done) => {
87-
const title = 'any title';
88-
const subtitle = 'any subtitle';
89-
const description = 'any description';
90-
const items: Array<SheetActionItem> = [
91-
{
92-
id: 'item-0',
93-
title: 'item 0 title',
94-
icon: {
95-
url: 'https://example.com/icon.png',
96-
urlDark: 'https://example.com/dark-icon.png',
97-
},
98-
},
99-
{
100-
id: 'item-1',
101-
title: 'item 1 title',
102-
style: 'normal',
103-
},
9+
const content = [
10410
{
105-
id: 'item-2',
106-
title: 'item 2 title',
107-
style: 'destructive',
108-
},
109-
];
110-
111-
createFakeAndroidPostMessage({
112-
checkMessage: (message) => {
113-
expect(message.type).toBe('SHEET');
114-
expect(message.payload).toEqual({
115-
title,
116-
subtitle,
117-
description,
118-
content: [
119-
{
120-
id: 'list-0',
121-
type: 'LIST',
122-
listType: 'ACTIONS',
123-
autoSubmit: true,
124-
selectedIds: [],
125-
items,
126-
},
127-
],
128-
});
129-
},
130-
getResponse: (message) => ({
131-
type: message.type,
132-
id: message.id,
133-
payload: {
134-
action: 'SUBMIT',
135-
result: [
136-
{
137-
id: 'list-0',
138-
selectedIds: ['item-2'],
11+
id: 'list-0',
12+
type: 'LIST' as const,
13+
listType: 'SINGLE_SELECTION' as const,
14+
autoSubmit: true,
15+
selectedIds: [selectedId],
16+
items: [
17+
{
18+
id: 'item-0',
19+
title: 'item 0 title',
20+
description: 'item 0 description',
21+
icon: {
22+
url: 'https://example.com/icon.png',
23+
urlDark: 'https://example.com/dark-icon.png',
13924
},
140-
],
141-
},
142-
}),
143-
});
144-
145-
bottomSheetActionSelector({
146-
title,
147-
subtitle,
148-
description,
149-
items,
150-
}).then((res) => {
151-
expect(res).toEqual({action: 'SUBMIT', selectedId: 'item-2'});
152-
done();
153-
});
154-
});
155-
156-
test('informative', (done) => {
157-
const title = 'any title';
158-
const subtitle = 'any subtitle';
159-
const description = 'any description';
160-
const items: Array<SheetInfoItem> = [
161-
{
162-
id: 'item-0',
163-
title: 'item 0 title',
164-
icon: {
165-
url: 'https://example.com/icon.png',
166-
urlDark: 'https://example.com/dark-icon.png',
167-
type: 'regular',
168-
},
169-
},
170-
{
171-
id: 'item-1',
172-
title: 'item 1 title',
173-
icon: {
174-
type: 'small',
175-
url: 'https://example.com/icon.png',
176-
},
177-
},
178-
{
179-
id: 'item-2',
180-
title: 'item 2 title',
181-
icon: {
182-
type: 'bullet',
183-
},
25+
},
26+
{
27+
id: 'item-1',
28+
title: 'item 1 title',
29+
description: 'item 1 description',
30+
},
31+
{
32+
id: 'item-2',
33+
title: 'item 2 title',
34+
description: 'item 2 description',
35+
},
36+
],
18437
},
18538
];
18639

@@ -191,16 +44,7 @@ test('informative', (done) => {
19144
title,
19245
subtitle,
19346
description,
194-
content: [
195-
{
196-
id: 'list-0',
197-
type: 'LIST',
198-
listType: 'INFORMATIVE',
199-
autoSubmit: false,
200-
selectedIds: [],
201-
items,
202-
},
203-
],
47+
content,
20448
});
20549
},
20650
getResponse: (message) => ({
@@ -218,74 +62,21 @@ test('informative', (done) => {
21862
}),
21963
});
22064

221-
bottomSheetInfo({
222-
title,
223-
subtitle,
224-
description,
225-
items,
226-
}).then((res) => {
227-
expect(res).toBe(undefined);
228-
done();
229-
});
230-
});
231-
232-
test('actions', (done) => {
233-
const title = 'any title';
234-
const subtitle = 'any subtitle';
235-
const description = 'any description';
236-
const button = {
237-
text: 'button text',
238-
};
239-
const link = {
240-
text: 'link text',
241-
chevron: true,
242-
};
243-
const secondaryButton = {
244-
text: 'secondary button text',
245-
};
246-
247-
createFakeAndroidPostMessage({
248-
checkMessage: (message) => {
249-
expect(message.type).toBe('SHEET');
250-
expect(message.payload).toEqual({
251-
title,
252-
subtitle,
253-
description,
254-
content: [
255-
{
256-
id: 'bottom-actions-0',
257-
type: 'BOTTOM_ACTIONS',
258-
button,
259-
link,
260-
secondaryButton,
261-
},
262-
],
263-
});
264-
},
265-
getResponse: (message) => ({
266-
type: message.type,
267-
id: message.id,
268-
payload: {
269-
action: 'SUBMIT',
270-
result: [
271-
{
272-
id: 'bottom-actions-0',
273-
selectedIds: ['PRIMARY'],
274-
},
275-
],
276-
},
277-
}),
278-
});
279-
280-
bottomSheetActions({
65+
bottomSheet({
28166
title,
28267
subtitle,
28368
description,
284-
button,
285-
secondaryButton,
286-
link,
69+
content,
28770
}).then((res) => {
288-
expect(res).toEqual({action: 'PRIMARY'});
71+
expect(res).toEqual({
72+
action: 'SUBMIT',
73+
result: [
74+
{
75+
id: 'list-0',
76+
selectedIds: ['item-2'],
77+
},
78+
],
79+
});
28980
done();
29081
});
29182
});

0 commit comments

Comments
 (0)