@@ -19,14 +19,7 @@ describe('MessageBox', () => {
19
19
</MessageBox>
20
20
);
21
21
cy.findByText(buttonText).click();
22
- cy.wrap(callback).should(
23
- 'have.been.calledWith',
24
- Cypress.sinon.match({
25
- detail: {
26
- action: buttonText
27
- }
28
- })
29
- );
22
+ cy.wrap(callback).should('have.been.calledWith', Cypress.sinon.match(buttonText));
30
23
});
31
24
});
32
25
@@ -46,9 +39,9 @@ describe('MessageBox', () => {
46
39
</Button>
47
40
<MessageBox
48
41
open={open}
49
- onClose={(e ) => {
50
- callback(e );
51
- setType(e.type );
42
+ onClose={(action, escPressed ) => {
43
+ callback(action, escPressed );
44
+ setType(escPressed ? 'before-close' : 'click' );
52
45
setOpen(false);
53
46
}}
54
47
>
@@ -64,12 +57,6 @@ describe('MessageBox', () => {
64
57
cy.findByText('Open').click();
65
58
cy.findByText('OK').click();
66
59
cy.get('@close').should('have.been.calledOnce');
67
- cy.wrap(callback).should(
68
- 'have.been.calledWith',
69
- Cypress.sinon.match({
70
- type: 'click'
71
- })
72
- );
73
60
cy.findByTestId('eventType').should('have.text', 'click');
74
61
75
62
cy.findByText('Open').click();
@@ -105,14 +92,7 @@ describe('MessageBox', () => {
105
92
cy.findByText('Custom').click();
106
93
cy.get('@onMessageBoxClose')
107
94
.should('have.been.calledOnce')
108
- .should(
109
- 'have.been.calledWith',
110
- Cypress.sinon.match({
111
- detail: {
112
- action: `1: custom action`
113
- }
114
- })
115
- );
95
+ .should('have.been.calledWith', Cypress.sinon.match('1: custom action'));
116
96
cy.get('@onButtonClick').should('have.been.calledOnce');
117
97
});
118
98
@@ -127,14 +107,7 @@ describe('MessageBox', () => {
127
107
cy.findByText('Cancel').click();
128
108
cy.get('@onMessageBoxClose')
129
109
.should('have.been.calledOnce')
130
- .should(
131
- 'have.been.calledWith',
132
- Cypress.sinon.match({
133
- detail: {
134
- action: MessageBoxAction.Cancel
135
- }
136
- })
137
- );
110
+ .should('have.been.calledWith', Cypress.sinon.match(MessageBoxAction.Cancel));
138
111
});
139
112
140
113
it('Show', () => {
@@ -148,26 +121,12 @@ describe('MessageBox', () => {
148
121
cy.findByText('Yes').click();
149
122
cy.get('@onMessageBoxClose')
150
123
.should('have.been.calledOnce')
151
- .should(
152
- 'have.been.calledWith',
153
- Cypress.sinon.match({
154
- detail: {
155
- action: MessageBoxAction.Yes
156
- }
157
- })
158
- );
124
+ .should('have.been.calledWith', Cypress.sinon.match(MessageBoxAction.Yes));
159
125
160
126
cy.findByText('No').click();
161
127
cy.get('@onMessageBoxClose')
162
128
.should('have.been.calledTwice')
163
- .should(
164
- 'have.been.calledWith',
165
- Cypress.sinon.match({
166
- detail: {
167
- action: MessageBoxAction.No
168
- }
169
- })
170
- );
129
+ .should('have.been.calledWith', Cypress.sinon.match(MessageBoxAction.No));
171
130
});
172
131
173
132
it('Success w/ custom title', () => {
@@ -187,14 +146,7 @@ describe('MessageBox', () => {
187
146
cy.findByText('OK').click();
188
147
cy.get('@onMessageBoxClose')
189
148
.should('have.been.calledOnce')
190
- .should(
191
- 'have.been.calledWith',
192
- Cypress.sinon.match({
193
- detail: {
194
- action: MessageBoxAction.OK
195
- }
196
- })
197
- );
149
+ .should('have.been.calledWith', Cypress.sinon.match(MessageBoxAction.OK));
198
150
});
199
151
200
152
it('No Title', () => {
@@ -224,25 +176,11 @@ describe('MessageBox', () => {
224
176
cy.findByText(MessageBoxAction.OK).should('be.visible').click();
225
177
cy.get('@onMessageBoxClose')
226
178
.should('have.been.calledOnce')
227
- .should(
228
- 'have.been.calledWith',
229
- Cypress.sinon.match({
230
- detail: {
231
- action: MessageBoxAction.OK
232
- }
233
- })
234
- );
179
+ .should('have.been.calledWith', Cypress.sinon.match(MessageBoxAction.OK));
235
180
cy.findByText('My Custom Action').should('be.visible').click();
236
181
cy.get('@onMessageBoxClose')
237
182
.should('have.been.calledTwice')
238
- .should(
239
- 'have.been.calledWith',
240
- Cypress.sinon.match({
241
- detail: {
242
- action: 'My Custom Action'
243
- }
244
- })
245
- );
183
+ .should('have.been.calledWith', Cypress.sinon.match('My Custom Action'));
246
184
});
247
185
248
186
it("Don't crash on unknown type", () => {
0 commit comments