Skip to content

Commit ff52bbe

Browse files
ENGCOM-6452: Cover #25556 with jasmine test #25992
2 parents fd58fcb + a201e22 commit ff52bbe

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'mage/adminhtml/browser',
8+
'jquery'
9+
], function (browser, $) {
10+
'use strict';
11+
12+
var obj;
13+
14+
beforeEach(function () {
15+
/**
16+
* Dummy constructor to use for instantiation
17+
* @constructor
18+
*/
19+
var Constr = function () {};
20+
21+
Constr.prototype = browser;
22+
23+
obj = new Constr();
24+
});
25+
26+
describe('"openDialog" method', function () {
27+
it('Opens dialog with provided targetElementId', function () {
28+
var options = {
29+
'targetElementId': 1
30+
};
31+
32+
spyOn($, 'ajax').and.callFake(
33+
function () {
34+
return {
35+
/**
36+
* Success result of ajax request
37+
*/
38+
done: function () {
39+
obj.targetElementId = 1;
40+
}
41+
};
42+
});
43+
obj.openDialog('instance/url', 100, 100, 'title', options);
44+
obj.openDialog('instance/url', 100, 100, 'title', options);
45+
expect($.ajax.calls.count()).toBe(1);
46+
});
47+
48+
it('Opens dialog with provided url param', function () {
49+
spyOn($, 'ajax').and.callFake(
50+
function () {
51+
return {
52+
/**
53+
* Success result of ajax request
54+
*/
55+
done: function () {
56+
obj.targetElementId = 'instance/url';
57+
obj.modalLoaded = true;
58+
}
59+
};
60+
});
61+
obj.openDialog('instance/url', 100, 100, 'title', undefined);
62+
obj.openDialog('instance/url', 100, 100, 'title', undefined);
63+
expect($.ajax.calls.count()).toBe(1);
64+
});
65+
});
66+
});

0 commit comments

Comments
 (0)