Skip to content

Commit 86d7ace

Browse files
committed
refactor: Simplify the test
1 parent 245b23b commit 86d7ace

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

packages/main/cypress/specs/Dialog.cy.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -416,29 +416,27 @@ describe("Dialog general interaction", () => {
416416
dialog.appendChild(content);
417417

418418
// Spy on Object.assign only for this dialog's style
419-
cy.window().then(() => {
420-
const originalAssign = Object.assign;
421-
const topAndLeftStyles: Array<{ top: number; left: number }> = [];
422-
423-
cy.stub(Object, "assign").callsFake(function(target: any, ...sources: any[]) {
424-
// Check if target is the dialog's style object
425-
if (target === dialog.style) {
426-
const styleObj = sources[0];
427-
if (styleObj && styleObj.top !== undefined && styleObj.left !== undefined) {
428-
topAndLeftStyles.push({
429-
top: parseInt(styleObj.top),
430-
left: parseInt(styleObj.left)
431-
});
432-
}
419+
const originalAssign = Object.assign;
420+
const topAndLeftStyles: Array<{ top: number; left: number }> = [];
421+
422+
cy.stub(Object, "assign").callsFake(function(target: any, ...sources: any[]) {
423+
// Check if target is the dialog's style object
424+
if (target === dialog.style) {
425+
const styleObj = sources[0];
426+
if (styleObj && styleObj.top !== undefined && styleObj.left !== undefined) {
427+
topAndLeftStyles.push({
428+
top: parseInt(styleObj.top),
429+
left: parseInt(styleObj.left)
430+
});
433431
}
434-
return originalAssign.call(this, target, ...sources);
435-
}).as("objectAssignStub");
432+
}
433+
return originalAssign.call(this, target, ...sources);
434+
}).as("objectAssignStub");
436435

437-
cy.wrap(topAndLeftStyles).as("topAndLeftStyles");
436+
cy.wrap(topAndLeftStyles).as("topAndLeftStyles");
438437

439-
dialog.setAttribute("open", "true");
440-
document.body.appendChild(dialog);
441-
});
438+
dialog.setAttribute("open", "true");
439+
document.body.appendChild(dialog);
442440

443441
cy.get<Dialog>("#dynamic-dialog").ui5DialogOpened();
444442

0 commit comments

Comments
 (0)