blob: 50c4982d6fe791a5e7c56732714d2e4337ba36a9 [file] [log] [blame]
Akronb43c8c62018-07-04 18:27:28 +02001define(['plugin/server','plugin/widget'], function (pluginServerClass, widgetClass) {
2
3 describe('KorAP.Plugin.Server', function () {
4
5 it('should be initializable', function () {
6 var manager = pluginServerClass.create();
7 expect(manager).toBeTruthy();
8 manager.destroy();
9 });
10
11 it('should add a widget', function () {
12 var manager = pluginServerClass.create();
13 var div = document.createElement("div");
14 var id = manager.addWidget(div, 'about:blank');
15 expect(id).toMatch(/^id-/);
Akron7c6e05f2018-07-12 19:08:13 +020016 expect(div.firstChild.classList.contains('widget')).toBeTruthy();
17 expect(div.firstChild.firstChild.tagName).toEqual("IFRAME");
Akronb43c8c62018-07-04 18:27:28 +020018 manager.destroy();
19 });
Akron10a47962018-07-12 21:17:10 +020020
21 it('should fail on invalid registries', function () {
22 var manager = pluginServerClass.create();
23
24 expect(
25 function() { manager.register({}) }
26 ).toThrow(new Error("Missing name of plugin"));
27
28 expect(
29 function() { manager.register({
30 name : 'Example',
31 embed : ''
32 })}
33 ).toThrow(new Error("Embedding of plugin is no list"));
34
35 expect(
36 function() { manager.register({
37 name : 'Example',
38 embed : [{
39 panel : ''
40 }]
41 })}
42 ).toThrow(new Error("Panel for plugin is invalid"));
43
44 });
Akronb43c8c62018-07-04 18:27:28 +020045 });
46
47 describe('KorAP.Plugin.Widget', function () {
48 it('should be initializable', function () {
49 var widget = widgetClass.create();
50 expect(widget).toBeTruthy();
51 });
52 });
53
54});