Skip to content

Commit d407e01

Browse files
committed
Cover #25556 with jasmine test
1 parent 902d74d commit d407e01

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/**
17+
* Dummy constructor to use for instantiation
18+
* @constructor
19+
*/
20+
var Constr = function () {};
21+
22+
Constr.prototype = browser;
23+
24+
obj = new Constr();
25+
});
26+
27+
describe('"openDialog" method', function () {
28+
it('Opens dialog with provided targetElementId', function () {
29+
var options = {
30+
'targetElementId': 1
31+
};
32+
33+
spyOn($, 'ajax').and.callFake(
34+
function () {
35+
return {
36+
done: function (data) {
37+
obj.targetElementId = 1;
38+
}
39+
}
40+
});
41+
obj.openDialog('instance/url', 100, 100, 'title', options);
42+
obj.openDialog('instance/url', 100, 100, 'title', options);
43+
expect($.ajax.calls.count()).toBe(1);
44+
45+
});
46+
47+
it('Opens dialog with provided url param', function () {
48+
spyOn($, 'ajax').and.callFake(
49+
function () {
50+
return {
51+
done: function (data) {
52+
obj.targetElementId = 'instance/url';
53+
obj.modalLoaded = true;
54+
}
55+
}
56+
});
57+
obj.openDialog('instance/url', 100, 100, 'title', undefined);
58+
obj.openDialog('instance/url', 100, 100, 'title', undefined);
59+
expect($.ajax.calls.count()).toBe(1);
60+
});
61+
});
62+
});

0 commit comments

Comments
 (0)