@atlassian/atlassian-connect-js 5.3.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.depcheckrc.json +16 -0
- package/.editorconfig +9 -0
- package/.envrc +5 -0
- package/.eslintignore +12 -0
- package/.eslintrc +31 -0
- package/.husky/pre-commit +11 -0
- package/.lintstagedrc.js +6 -0
- package/.netrc +1 -0
- package/.npmrc-public +4 -0
- package/.nvmrc +1 -0
- package/LICENSE +3 -0
- package/README.md +281 -0
- package/bitbucket-pipelines.yml +33 -0
- package/build/bin/bin-helper.js +29 -0
- package/build/bin/npm-postinstall.js +9 -0
- package/build/configs/append-sourcemapping.js +13 -0
- package/build/configs/availabletasks.js +15 -0
- package/build/configs/clean.js +12 -0
- package/build/configs/concat.js +44 -0
- package/build/configs/copy.js +32 -0
- package/build/configs/index.js +19 -0
- package/build/configs/jshint.js +9 -0
- package/build/configs/karma.js +11 -0
- package/build/configs/replace.js +10 -0
- package/build/configs/requirejs.js +187 -0
- package/build/configs/saucelabs-launchers.js +30 -0
- package/build/configs/shell.js +24 -0
- package/build/configs/uglify.js +15 -0
- package/build/configs/watch.js +45 -0
- package/build/end.frag +13 -0
- package/build/start.frag +18 -0
- package/bundlesize.config.json +14 -0
- package/dist/connect-host.css +225 -0
- package/dist/connect-host.js +13908 -0
- package/dist/connect-host.min.css +1 -0
- package/dist/iframe-fedramp.js +13663 -0
- package/dist/iframe.js +13663 -0
- package/dist/legacy-text-colors.css +245 -0
- package/dist/surfaces.css +11 -0
- package/dist/themes/atlaskit-tokens_dark-future.css +6 -0
- package/dist/themes/atlaskit-tokens_dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-light.css +394 -0
- package/dist/themes/atlaskit-tokens_light-future.css +6 -0
- package/dist/themes/atlaskit-tokens_light.css +394 -0
- package/dist/themes/atlaskit-tokens_shape.css +14 -0
- package/dist/themes/atlaskit-tokens_spacing.css +26 -0
- package/dist/themes/atlaskit-tokens_typography-adg3.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-modernized.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-refreshed.css +25 -0
- package/gulpfile.js +204 -0
- package/memleak-check/app.html +10 -0
- package/memleak-check/index.html +31 -0
- package/memleak-check/index.js +33 -0
- package/package.json +102 -0
- package/renovate.json +11 -0
- package/security-assistant.yml +2 -0
- package/spec/.eslintrc +10 -0
- package/spec/config/karma.base.conf.js +200 -0
- package/spec/config/karma.conf.js +20 -0
- package/spec/fixtures/base_dialog_component_tests.js +180 -0
- package/spec/mocks/mock_feature_flag.js +23 -0
- package/spec/tests/amd_spec.js +122 -0
- package/spec/tests/analytics_dispatcher_spec.js +429 -0
- package/spec/tests/analytics_performance_spec.js +41 -0
- package/spec/tests/button_spec.js +143 -0
- package/spec/tests/dialog_extension_spec.js +59 -0
- package/spec/tests/dialog_module_provider_spec.js +499 -0
- package/spec/tests/dialog_module_spec.js +395 -0
- package/spec/tests/dialog_spec.js +296 -0
- package/spec/tests/dialog_webitem_spec.js +183 -0
- package/spec/tests/dropdown_module_spec.js +77 -0
- package/spec/tests/env_module_spec.js +153 -0
- package/spec/tests/events_spec.js +77 -0
- package/spec/tests/extension_configuration_options_store_spec.js +25 -0
- package/spec/tests/flag_module_provider_spec.js +79 -0
- package/spec/tests/flag_module_spec.js +118 -0
- package/spec/tests/flag_spec.js +243 -0
- package/spec/tests/host-api_spec.js +220 -0
- package/spec/tests/iframe-create_spec.js +43 -0
- package/spec/tests/iframe_container_spec.js +19 -0
- package/spec/tests/iframe_spec.js +265 -0
- package/spec/tests/inline_dialog_spec.js +41 -0
- package/spec/tests/inline_dialog_webitem_spec.js +331 -0
- package/spec/tests/loading_indicator_spec.js +48 -0
- package/spec/tests/messages_module_spec.js +108 -0
- package/spec/tests/meta_spec.js +71 -0
- package/spec/tests/module_args_spec.js +52 -0
- package/spec/tests/observe_spec.js +73 -0
- package/spec/tests/public_events.spec.js +102 -0
- package/spec/tests/scroll_position_spec.js +109 -0
- package/spec/tests/theming_spec.js +594 -0
- package/spec/tests/util_spec.js +55 -0
- package/spec/tests/utils/base64_spec.js +20 -0
- package/spec/tests/utils/button_spec.js +11 -0
- package/spec/tests/utils/cookie_spec.js +19 -0
- package/spec/tests/utils/deprecate_spec.js +22 -0
- package/spec/tests/utils/dialog_spec.js +297 -0
- package/spec/tests/utils/host_util_spec.js +45 -0
- package/spec/tests/utils/iframe_spec.js +41 -0
- package/spec/tests/utils/jwt_spec.js +135 -0
- package/spec/tests/utils/url_spec.js +37 -0
- package/spec/tests/utils/waitUntilReadyNextTick.js +5 -0
- package/spec/tests/utils/webitem.js +219 -0
- package/spec/tests/webitem_spec.js +131 -0
- package/src/css/host/dialog.css +144 -0
- package/src/css/host/flags.css +5 -0
- package/src/css/host/host.css +64 -0
- package/src/css/host/messages.css +12 -0
- package/src/css/plugin/legacy-text-colors.less +55 -0
- package/src/css/plugin/surfaces.css +11 -0
- package/src/host/ACJSFrameworkAdaptor.js +44 -0
- package/src/host/actions/analytics_action.js +35 -0
- package/src/host/actions/button_actions.js +21 -0
- package/src/host/actions/dialog_actions.js +27 -0
- package/src/host/actions/dialog_extension_actions.js +25 -0
- package/src/host/actions/dom_event_actions.js +32 -0
- package/src/host/actions/dropdown_actions.js +12 -0
- package/src/host/actions/env_actions.js +57 -0
- package/src/host/actions/event_actions.js +33 -0
- package/src/host/actions/flag_actions.js +22 -0
- package/src/host/actions/iframe_actions.js +27 -0
- package/src/host/actions/inline_dialog_actions.js +26 -0
- package/src/host/actions/inline_dialog_webitem_actions.js +10 -0
- package/src/host/actions/jwt_actions.js +51 -0
- package/src/host/actions/loading_indicator_actions.js +10 -0
- package/src/host/actions/module_actions.js +14 -0
- package/src/host/actions/webitem_actions.js +29 -0
- package/src/host/components/button.js +112 -0
- package/src/host/components/dialog.js +447 -0
- package/src/host/components/dialog_extension.js +106 -0
- package/src/host/components/dialog_webitem.js +69 -0
- package/src/host/components/flag.js +102 -0
- package/src/host/components/iframe.js +130 -0
- package/src/host/components/iframe_container.js +38 -0
- package/src/host/components/inline_dialog.js +108 -0
- package/src/host/components/inline_dialog_webitem.js +157 -0
- package/src/host/components/loading_indicator.js +110 -0
- package/src/host/components/webitem.js +227 -0
- package/src/host/deprecate.js +20 -0
- package/src/host/dispatchers/analytics_dispatcher.js +512 -0
- package/src/host/dispatchers/event_dispatcher.js +46 -0
- package/src/host/dollar.js +8 -0
- package/src/host/host-api.js +325 -0
- package/src/host/iframe-create.js +7 -0
- package/src/host/index.js +108 -0
- package/src/host/module-providers.js +13 -0
- package/src/host/modules/_featureFlag.js +42 -0
- package/src/host/modules/_performance.js +54 -0
- package/src/host/modules/analytics.js +17 -0
- package/src/host/modules/dialog.js +496 -0
- package/src/host/modules/dropdown.js +255 -0
- package/src/host/modules/env.js +156 -0
- package/src/host/modules/events.js +28 -0
- package/src/host/modules/flag.js +170 -0
- package/src/host/modules/host.js +19 -0
- package/src/host/modules/inline-dialog.js +33 -0
- package/src/host/modules/messages.js +309 -0
- package/src/host/modules/page.js +29 -0
- package/src/host/modules/scroll-position.js +102 -0
- package/src/host/modules/theming.js +114 -0
- package/src/host/stores/extension_configuration_options_store.js +24 -0
- package/src/host/util.js +98 -0
- package/src/host/utils/access-narrowing-context.js +18 -0
- package/src/host/utils/base64.js +22 -0
- package/src/host/utils/button.js +10 -0
- package/src/host/utils/cookie.js +14 -0
- package/src/host/utils/dialog.js +239 -0
- package/src/host/utils/feature-flag.js +27 -0
- package/src/host/utils/iframe.js +23 -0
- package/src/host/utils/jwt.js +60 -0
- package/src/host/utils/observe.js +34 -0
- package/src/host/utils/removal-observer.js +30 -0
- package/src/host/utils/simplexdm.js +58 -0
- package/src/host/utils/url.js +23 -0
- package/src/host/utils/webitem.js +214 -0
- package/src/plugin/amd.js +115 -0
- package/src/plugin/analytics.js +84 -0
- package/src/plugin/deprecate.js +16 -0
- package/src/plugin/dialog.js +197 -0
- package/src/plugin/dollar.js +77 -0
- package/src/plugin/events-instance.js +2 -0
- package/src/plugin/events.js +246 -0
- package/src/plugin/extension_configuration_options_store.js +27 -0
- package/src/plugin/featureFlag.js +8 -0
- package/src/plugin/index.js +118 -0
- package/src/plugin/meta.js +14 -0
- package/src/plugin/public-events.js +73 -0
- package/src/plugin/theming.js +211 -0
- package/src/plugin/util.js +104 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import DialogModule from 'src/host/modules/dialog';
|
|
2
|
+
import EventActions from 'src/host/actions/event_actions';
|
|
3
|
+
import { acjsFrameworkAdaptor } from 'src/host/ACJSFrameworkAdaptor';
|
|
4
|
+
|
|
5
|
+
const callback = () => {};
|
|
6
|
+
callback._id = 'some-extension-id';
|
|
7
|
+
callback._context = {
|
|
8
|
+
extension: {
|
|
9
|
+
addon_key: 'some-addon-key',
|
|
10
|
+
key: 'some-module-key',
|
|
11
|
+
options: jasmine.objectContaining({})
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const otherAddonCallback = Object.assign({}, callback, {_context: {extension: {addon_key: 'some-other-addon-key'}}});
|
|
15
|
+
|
|
16
|
+
const providerSpy = {
|
|
17
|
+
create: jasmine.createSpy('create'),
|
|
18
|
+
close: jasmine.createSpy('close'),
|
|
19
|
+
createButton: jasmine.createSpy('createButton'),
|
|
20
|
+
setButtonDisabled: jasmine.createSpy('setButtonDisabled'),
|
|
21
|
+
isButtonDisabled: jasmine.createSpy('isButtonDisabled'),
|
|
22
|
+
toggleButton: jasmine.createSpy('toggleButton'),
|
|
23
|
+
setButtonHidden: jasmine.createSpy('setButtonHidden'),
|
|
24
|
+
isButtonHidden: jasmine.createSpy('isButtonHidden'),
|
|
25
|
+
isActiveDialog: jasmine.createSpy('isActiveDialog').and.callFake(function(addon_key){
|
|
26
|
+
return addon_key === 'some-addon-key'
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
class DialogModuleSpy {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.providerSpy = providerSpy;
|
|
33
|
+
}
|
|
34
|
+
isEnabled() {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
getModuleRegistrationName() {
|
|
38
|
+
return 'dialog';
|
|
39
|
+
}
|
|
40
|
+
getProvider() {
|
|
41
|
+
return this.providerSpy;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
acjsFrameworkAdaptor.registerModule(new DialogModuleSpy(providerSpy));
|
|
46
|
+
|
|
47
|
+
describe('AP.dialog', () => {
|
|
48
|
+
|
|
49
|
+
const minOptions = {
|
|
50
|
+
key: 'some-module-key'
|
|
51
|
+
};
|
|
52
|
+
const maxOptions = {
|
|
53
|
+
key: 'some-module-key',
|
|
54
|
+
size: 'xlarge',
|
|
55
|
+
width: '100%',
|
|
56
|
+
height: '100%',
|
|
57
|
+
chrome: true,
|
|
58
|
+
header: 'some-header-text',
|
|
59
|
+
submitText: 'some-submit-text',
|
|
60
|
+
cancelText: 'some-cancel-text',
|
|
61
|
+
customData: {someCustomKey: 'someCustomData'},
|
|
62
|
+
closeOnEscape: false,
|
|
63
|
+
buttons: [{identifier: 'someButtonIdentifier', text: 'someButtonText'}],
|
|
64
|
+
hint: 'some-hint-text'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
providerSpy.create.calls.reset();
|
|
69
|
+
providerSpy.close.calls.reset();
|
|
70
|
+
providerSpy.createButton.calls.reset();
|
|
71
|
+
providerSpy.setButtonDisabled.calls.reset();
|
|
72
|
+
providerSpy.isButtonDisabled.calls.reset();
|
|
73
|
+
providerSpy.toggleButton.calls.reset();
|
|
74
|
+
providerSpy.setButtonHidden.calls.reset();
|
|
75
|
+
providerSpy.isButtonHidden.calls.reset();
|
|
76
|
+
providerSpy.isActiveDialog.calls.reset();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('.create()', () => {
|
|
80
|
+
|
|
81
|
+
const tests = [
|
|
82
|
+
{
|
|
83
|
+
it: 'provides expected default values',
|
|
84
|
+
javaScriptAPIOptions: {
|
|
85
|
+
key: 'some-module-key',
|
|
86
|
+
chrome: true
|
|
87
|
+
},
|
|
88
|
+
dialogProviderOptions: {
|
|
89
|
+
id: 'some-extension-id',
|
|
90
|
+
width: '50%',
|
|
91
|
+
height: '50%',
|
|
92
|
+
header: '',
|
|
93
|
+
actions: [
|
|
94
|
+
jasmine.objectContaining({
|
|
95
|
+
identifier: 'submit',
|
|
96
|
+
name: 'submit',
|
|
97
|
+
text: 'Submit'
|
|
98
|
+
}),
|
|
99
|
+
jasmine.objectContaining({
|
|
100
|
+
identifier: 'cancel',
|
|
101
|
+
name: 'cancel',
|
|
102
|
+
text: 'Cancel'
|
|
103
|
+
})
|
|
104
|
+
],
|
|
105
|
+
closeOnEscape: true
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
it: 'provides custom height and widths over default',
|
|
110
|
+
javaScriptAPIOptions: Object.assign({}, minOptions, {
|
|
111
|
+
height: '111px',
|
|
112
|
+
width: '222px'
|
|
113
|
+
}),
|
|
114
|
+
dialogProviderOptions: {
|
|
115
|
+
height: '111px',
|
|
116
|
+
width: '222px'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
it: 'provides size over custom height and widths',
|
|
121
|
+
javaScriptAPIOptions: maxOptions,
|
|
122
|
+
dialogProviderOptions: {
|
|
123
|
+
size: 'xlarge',
|
|
124
|
+
height: undefined,
|
|
125
|
+
width: undefined
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
it: 'provides custom header text',
|
|
130
|
+
javaScriptAPIOptions: maxOptions,
|
|
131
|
+
dialogProviderOptions: {
|
|
132
|
+
header: maxOptions.header
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
it: 'provides custom submit button text',
|
|
137
|
+
javaScriptAPIOptions: maxOptions,
|
|
138
|
+
dialogProviderOptions: {
|
|
139
|
+
actions: [
|
|
140
|
+
jasmine.objectContaining({
|
|
141
|
+
identifier: 'submit',
|
|
142
|
+
name: 'submit',
|
|
143
|
+
text: 'some-submit-text'
|
|
144
|
+
}),
|
|
145
|
+
jasmine.anything(),
|
|
146
|
+
jasmine.anything()
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
it: 'provides custom value for close on escape',
|
|
152
|
+
javaScriptAPIOptions: Object.assign({}, maxOptions, {
|
|
153
|
+
closeOnEscape: false
|
|
154
|
+
}),
|
|
155
|
+
dialogProviderOptions: {
|
|
156
|
+
closeOnEscape: false
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
it: 'provides multiple user buttons',
|
|
161
|
+
javaScriptAPIOptions: Object.assign({}, maxOptions, {
|
|
162
|
+
buttons: [
|
|
163
|
+
{
|
|
164
|
+
identifier: 'button1-id',
|
|
165
|
+
text: 'button1-text'
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
identifier: 'button2-id',
|
|
169
|
+
text: 'button2-text'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
identifier: 'button3-id',
|
|
173
|
+
text: 'button3-text'
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
dialogProviderOptions: {
|
|
178
|
+
actions: [
|
|
179
|
+
jasmine.anything(),
|
|
180
|
+
jasmine.anything(),
|
|
181
|
+
jasmine.objectContaining({
|
|
182
|
+
identifier: 'button1-id',
|
|
183
|
+
text: 'button1-text'
|
|
184
|
+
}),
|
|
185
|
+
jasmine.objectContaining({
|
|
186
|
+
identifier: 'button2-id',
|
|
187
|
+
text: 'button2-text'
|
|
188
|
+
}),
|
|
189
|
+
jasmine.objectContaining({
|
|
190
|
+
identifier: 'button3-id',
|
|
191
|
+
text: 'button3-text'
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
it: 'provides hint text',
|
|
198
|
+
javaScriptAPIOptions: maxOptions,
|
|
199
|
+
dialogProviderOptions: {
|
|
200
|
+
hint: 'some-hint-text'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
tests.forEach(test => {
|
|
206
|
+
it(test.it, () => {
|
|
207
|
+
new DialogModule.create.constructor(test.javaScriptAPIOptions, callback);
|
|
208
|
+
expect(providerSpy.create).toHaveBeenCalledWith(
|
|
209
|
+
jasmine.objectContaining(test.dialogProviderOptions),
|
|
210
|
+
jasmine.objectContaining(callback._context.extension)
|
|
211
|
+
);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('.create()', () => {
|
|
217
|
+
|
|
218
|
+
it('triggers correct AP.events when submit is clicked', () => {
|
|
219
|
+
new DialogModule.create.constructor(maxOptions, callback);
|
|
220
|
+
spyOn(EventActions, 'broadcast');
|
|
221
|
+
providerSpy.create.calls.argsFor(0)[0].actions[0].onClick();
|
|
222
|
+
expect(EventActions.broadcast.calls.count()).toEqual(2);
|
|
223
|
+
expect(EventActions.broadcast.calls.first().args).toEqual([
|
|
224
|
+
'dialog.submit',
|
|
225
|
+
jasmine.objectContaining({
|
|
226
|
+
addon_key: callback._context.extension.addon_key,
|
|
227
|
+
key: callback._context.extension.key
|
|
228
|
+
}),
|
|
229
|
+
jasmine.objectContaining({
|
|
230
|
+
button: {
|
|
231
|
+
name: 'submit',
|
|
232
|
+
identifier: 'submit',
|
|
233
|
+
text: 'some-submit-text'
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
]);
|
|
237
|
+
expect(EventActions.broadcast.calls.all()[1].args).toEqual([
|
|
238
|
+
'dialog.button.click',
|
|
239
|
+
jasmine.objectContaining({
|
|
240
|
+
addon_key: callback._context.extension.addon_key,
|
|
241
|
+
key: callback._context.extension.key
|
|
242
|
+
}),
|
|
243
|
+
jasmine.objectContaining({
|
|
244
|
+
button: {
|
|
245
|
+
name: 'submit',
|
|
246
|
+
identifier: 'submit',
|
|
247
|
+
text: 'some-submit-text'
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
it('triggers correct AP.events when cancel is clicked', () => {
|
|
253
|
+
new DialogModule.create.constructor(maxOptions, callback);
|
|
254
|
+
spyOn(EventActions, 'broadcast');
|
|
255
|
+
providerSpy.create.calls.argsFor(0)[0].actions[0].onClick();
|
|
256
|
+
expect(EventActions.broadcast.calls.count()).toEqual(2);
|
|
257
|
+
expect(EventActions.broadcast.calls.first().args).toEqual([
|
|
258
|
+
'dialog.cancel',
|
|
259
|
+
jasmine.objectContaining({
|
|
260
|
+
addon_key: callback._context.extension.addon_key,
|
|
261
|
+
key: callback._context.extension.key
|
|
262
|
+
}),
|
|
263
|
+
jasmine.objectContaining({
|
|
264
|
+
button: {
|
|
265
|
+
name: 'cancel',
|
|
266
|
+
identifier: 'cancel',
|
|
267
|
+
text: 'some-cancel-text'
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
]);
|
|
271
|
+
expect(EventActions.broadcast.calls.all()[1].args).toEqual([
|
|
272
|
+
'dialog.button.click',
|
|
273
|
+
jasmine.objectContaining({
|
|
274
|
+
addon_key: callback._context.extension.addon_key,
|
|
275
|
+
key: callback._context.extension.key
|
|
276
|
+
}),
|
|
277
|
+
jasmine.objectContaining({
|
|
278
|
+
button: {
|
|
279
|
+
name: 'cancel',
|
|
280
|
+
identifier: 'cancel',
|
|
281
|
+
text: 'some-cancel-text'
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
]);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('triggers correct AP.events when user button is clicked', () => {
|
|
288
|
+
new DialogModule.create.constructor(maxOptions, callback);
|
|
289
|
+
spyOn(EventActions, 'broadcast');
|
|
290
|
+
providerSpy.create.calls.argsFor(0)[0].actions[0].onClick();
|
|
291
|
+
expect(EventActions.broadcast.calls.count()).toEqual(1);
|
|
292
|
+
expect(EventActions.broadcast.calls.first().args).toEqual([
|
|
293
|
+
'dialog.button.click',
|
|
294
|
+
jasmine.objectContaining({
|
|
295
|
+
addon_key: callback._context.extension.addon_key,
|
|
296
|
+
key: callback._context.extension.key
|
|
297
|
+
}),
|
|
298
|
+
jasmine.objectContaining({
|
|
299
|
+
button: {
|
|
300
|
+
name: 'someButtonIdentifiersomeButtonIdentifier',
|
|
301
|
+
identifier: 'someButtonIdentifier',
|
|
302
|
+
text: 'someButtonText'
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
]);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
describe('.close()', () => {
|
|
313
|
+
|
|
314
|
+
it('provides close function', () => {
|
|
315
|
+
new DialogModule.create.constructor(minOptions, callback);
|
|
316
|
+
DialogModule.close(callback);
|
|
317
|
+
expect(providerSpy.close).toHaveBeenCalled();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('does not provide close function for other addons', () => {
|
|
321
|
+
new DialogModule.create.constructor(minOptions, callback);
|
|
322
|
+
expect(function(){
|
|
323
|
+
DialogModule.close(otherAddonCallback)
|
|
324
|
+
}).toThrow(new Error('Failed to find an active dialog for: ' + otherAddonCallback._context.extension.addon_key));
|
|
325
|
+
expect(providerSpy.close).not.toHaveBeenCalled();
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('provides dialog.close event and data', () => {
|
|
329
|
+
new DialogModule.create.constructor(minOptions, callback);
|
|
330
|
+
let data = {someKey: 'someValue'};
|
|
331
|
+
spyOn(EventActions, 'broadcast');
|
|
332
|
+
DialogModule.close(data, callback);
|
|
333
|
+
expect(EventActions.broadcast).toHaveBeenCalledWith(
|
|
334
|
+
'dialog.close',
|
|
335
|
+
jasmine.objectContaining({addon_key: callback._context.extension.addon_key}),
|
|
336
|
+
jasmine.objectContaining(data)
|
|
337
|
+
);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
describe('.createButton()', () => {
|
|
344
|
+
|
|
345
|
+
it('provides a new button with expected default values', () => {
|
|
346
|
+
new DialogModule.createButton.constructor({
|
|
347
|
+
identifier: 'some-button-identifier',
|
|
348
|
+
text: 'some-button-text'
|
|
349
|
+
}, callback);
|
|
350
|
+
expect(providerSpy.createButton).toHaveBeenCalledWith(
|
|
351
|
+
jasmine.objectContaining(
|
|
352
|
+
{
|
|
353
|
+
identifier: 'some-button-identifier',
|
|
354
|
+
text: 'some-button-text'
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('does not provide a new button for other addons', () => {
|
|
361
|
+
expect(function(){
|
|
362
|
+
new DialogModule.createButton.constructor(
|
|
363
|
+
{
|
|
364
|
+
identifier: 'some-button-identifier',
|
|
365
|
+
text: 'some-button-text'
|
|
366
|
+
},
|
|
367
|
+
otherAddonCallback
|
|
368
|
+
)
|
|
369
|
+
}).toThrow(new Error('Failed to find an active dialog for: ' + otherAddonCallback._context.extension.addon_key));
|
|
370
|
+
expect(providerSpy.createButton).not.toHaveBeenCalled();
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('provides a new button with custom disabled value', () => {
|
|
374
|
+
new DialogModule.createButton.constructor({
|
|
375
|
+
identifier: 'some-button-identifier',
|
|
376
|
+
text: 'some-button-text',
|
|
377
|
+
disabled: true
|
|
378
|
+
}, callback);
|
|
379
|
+
expect(providerSpy.createButton).toHaveBeenCalledWith(
|
|
380
|
+
jasmine.objectContaining({disabled: true})
|
|
381
|
+
);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe('.getButton()', () => {
|
|
387
|
+
|
|
388
|
+
it('does not provide a button for other addons', () => {
|
|
389
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
390
|
+
expect(function(){
|
|
391
|
+
new DialogModule.getButton.constructor('submit', otherAddonCallback)
|
|
392
|
+
}).toThrow(new Error('Failed to find an active dialog for: ' + otherAddonCallback._context.extension.addon_key));
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('provides setButtonDisabled for the submit button', () => {
|
|
396
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
397
|
+
new DialogModule.getButton.constructor('submit', callback).disable();
|
|
398
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('submit', true);
|
|
399
|
+
new DialogModule.getButton.constructor('submit', callback).enable();
|
|
400
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('submit', false);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('provides toggleButton for the submit button', () => {
|
|
404
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
405
|
+
new DialogModule.getButton.constructor('submit', callback).toggle();
|
|
406
|
+
expect(providerSpy.toggleButton).toHaveBeenCalledWith('submit');
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('provides isButtonDisabled for the submit button', () => {
|
|
410
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
411
|
+
new DialogModule.getButton.constructor('submit', callback).isEnabled(val => {});
|
|
412
|
+
expect(providerSpy.isButtonDisabled).toHaveBeenCalledWith('submit');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it('provides setButtonDisabled for the cancel button', () => {
|
|
416
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
417
|
+
new DialogModule.getButton.constructor('cancel', callback).disable();
|
|
418
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('cancel', true);
|
|
419
|
+
new DialogModule.getButton.constructor('cancel', callback).enable();
|
|
420
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('cancel', false);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('provides toggleButton for the cancel button', () => {
|
|
424
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
425
|
+
new DialogModule.getButton.constructor('cancel', callback).toggle();
|
|
426
|
+
expect(providerSpy.toggleButton).toHaveBeenCalledWith('cancel');
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('provides isButtonDisabled for the cancel button', () => {
|
|
430
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
431
|
+
new DialogModule.getButton.constructor('cancel', callback).isEnabled(val => {});
|
|
432
|
+
expect(providerSpy.isButtonDisabled).toHaveBeenCalledWith('cancel');
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('provides setButtonDisabled for a user button', () => {
|
|
436
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true, buttons: [{identifier: 'user', text: 'user'}]}, callback);
|
|
437
|
+
new DialogModule.getButton.constructor('user', callback).disable();
|
|
438
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('user', true);
|
|
439
|
+
new DialogModule.getButton.constructor('user', callback).enable();
|
|
440
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('user', false);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('provides toggleButton for a user button', () => {
|
|
444
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true, buttons: [{identifier: 'user', text: 'user'}]}, callback);
|
|
445
|
+
new DialogModule.getButton.constructor('user', callback).toggle();
|
|
446
|
+
expect(providerSpy.toggleButton).toHaveBeenCalledWith('user');
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('provides isButtonDisabled for a user button', () => {
|
|
450
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true, buttons: [{identifier: 'user', text: 'user'}]}, callback);
|
|
451
|
+
new DialogModule.getButton.constructor('user', callback).isEnabled(val => {});
|
|
452
|
+
expect(providerSpy.isButtonDisabled).toHaveBeenCalledWith('user');
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('provides setButtonHidden for the submit button', () => {
|
|
456
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
457
|
+
new DialogModule.getButton.constructor('submit', callback).hide();
|
|
458
|
+
expect(providerSpy.setButtonHidden).toHaveBeenCalledWith('submit', true);
|
|
459
|
+
new DialogModule.getButton.constructor('submit', callback).enable();
|
|
460
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('submit', false);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it('provides isButtonHidden for the submit button', () => {
|
|
464
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
465
|
+
new DialogModule.getButton.constructor('submit', callback).isHidden(val => {});
|
|
466
|
+
expect(providerSpy.isButtonHidden).toHaveBeenCalledWith('submit');
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('provides setButtonHidden for the cancel button', () => {
|
|
470
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
471
|
+
new DialogModule.getButton.constructor('cancel', callback).hide();
|
|
472
|
+
expect(providerSpy.setButtonHidden).toHaveBeenCalledWith('cancel', true);
|
|
473
|
+
new DialogModule.getButton.constructor('cancel', callback).enable();
|
|
474
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('cancel', false);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('provides isButtonHidden for the cancel button', () => {
|
|
478
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true}, callback);
|
|
479
|
+
new DialogModule.getButton.constructor('cancel', callback).isHidden(val => {});
|
|
480
|
+
expect(providerSpy.isButtonHidden).toHaveBeenCalledWith('cancel');
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it('provides setButtonHidden for a user button', () => {
|
|
484
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true, buttons: [{identifier: 'user', text: 'user'}]}, callback);
|
|
485
|
+
new DialogModule.getButton.constructor('user', callback).hide();
|
|
486
|
+
expect(providerSpy.setButtonHidden).toHaveBeenCalledWith('user', true);
|
|
487
|
+
new DialogModule.getButton.constructor('user', callback).enable();
|
|
488
|
+
expect(providerSpy.setButtonDisabled).toHaveBeenCalledWith('user', false);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
it('provides isButtonHidden for the user button', () => {
|
|
492
|
+
new DialogModule.create.constructor({key: 'some-module-key', chrome:true, buttons: [{identifier: 'user', text: 'user'}]}, callback);
|
|
493
|
+
new DialogModule.getButton.constructor('user', callback).isHidden(val => {});
|
|
494
|
+
expect(providerSpy.isButtonHidden).toHaveBeenCalledWith('user');
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
});
|