69421429eb87c4e391fd7f7265c9250df475818f
[mkws-moved-to-github.git] / test / spec / mkws-config.js
1 /* Copyright (c) 2013-2014 Index Data ApS. http://indexdata.com
2  *
3  * check mkws_config = {} object in browser
4  *
5  */
6
7 describe("Check for external JavaScript libs", function () {
8     it("jQuery", function () {
9         expect(typeof mkws.$).not.toBe('undefined');
10     });
11
12     // jquery.json-2.4.js
13     it("jQuery JSON", function () {
14         expect(typeof mkws.$.toJSON).not.toBe('undefined');
15     });
16
17     it("jQuery UI", function () {
18         // if we have a popup widget, check for the jQuery UI lib
19         if (mkws.$(".mkws-popup").length > 0) {
20             expect(typeof mkws.$.ui).not.toBe('undefined');
21         }
22     });
23
24     it("pazpar2", function () {
25         expect(typeof pz2).not.toBe('undefined');
26     });
27
28     it("JSNlog", function () {
29         expect(typeof JL).not.toBe('undefined');
30     });
31
32     it("Handlebars", function () {
33         expect(typeof Handlebars).not.toBe('undefined');
34     });
35 });
36
37 describe("Check mkws.config object", function () {
38     it("mkws.config exists", function () {
39         expect(mkws.config).not.toBe(undefined);
40     });
41
42     it("mkws.config locale check German", function () {
43         expect(mkws.locale_lang.de.Authors).toMatch(/^Autoren$/);
44         expect(mkws.locale_lang.de.Location).toMatch(/^Ort$/);
45     });
46     it("mkws.config locale check Danish", function () {
47         expect(mkws.locale_lang.da.Authors).toMatch(/^Forfattere$/);
48         expect(mkws.locale_lang.da.Location).toMatch(/^Lokation$/);
49     });
50
51 /*
52      * this is a test if the config value is a boolean JavaScript object: true or false
53      * and nothing else (0, '0', undefined, "false" etc.)
54      */
55     it("mkws.config service proxy enabled/disabled", function () {
56         if (mkws.config.use_service_proxy) {
57             expect(mkws.config.use_service_proxy).toBe(true);
58         } else {
59             expect(mkws.config.use_service_proxy).toBe(false);
60         }
61     });
62
63 });
64
65
66 describe("Check pazpar2 config", function () {
67     it("pazpar2_url is a path or an full URL", function () {
68         expect(mkws.config.pazpar2_url).toMatch(/^(\/|https?:\/\/|undefined$)/)
69     });
70 });
71
72 describe("Check pazpar2 runtime", function () {
73     it("pazpar2 was successfully initialized", function () {
74         expect(mkws.config.error).toBe(undefined);
75     });
76 });