e2953967f055936f5f53bbec57d78814a478912c
[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("JSNlog", function () {
9         expect(typeof JL).not.toBe('undefined');
10     });
11
12     it("Handlebars", function () {
13         expect(typeof Handlebars).not.toBe('undefined');
14     });
15
16     it("jQuery", function () {
17         expect(typeof mkws.$).not.toBe('undefined');
18     });
19
20     it("jQuery UI", function () {
21         // if we have a popup widget, check for the jQuery UI lib
22         if (mkws.$(".mkws-popup").length > 0) {
23             expect(typeof mkws.$.ui).not.toBe('undefined');
24         }
25     });
26 });
27
28 describe("Check mkws.config object", function () {
29     it("mkws.config exists", function () {
30         expect(mkws.config).not.toBe(undefined);
31     });
32
33     it("mkws.config locale check German", function () {
34         expect(mkws.locale_lang.de.Authors).toMatch(/^Autoren$/);
35         expect(mkws.locale_lang.de.Location).toMatch(/^Ort$/);
36     });
37     it("mkws.config locale check Danish", function () {
38         expect(mkws.locale_lang.da.Authors).toMatch(/^Forfattere$/);
39         expect(mkws.locale_lang.da.Location).toMatch(/^Lokation$/);
40     });
41
42     /*
43      * this is a test if the config value is a boolean JavaScript object: true or false
44      * and nothing else (0, '0', undefined, "false" etc.)
45      */
46     it("mkws.config service proxy enabled/disabled", function () {
47         if (mkws.config.use_service_proxy) {
48             expect(mkws.config.use_service_proxy).toBe(true);
49         } else {
50             expect(mkws.config.use_service_proxy).toBe(false);
51         }
52     });
53
54 });
55
56
57 describe("Check pazpar2 config", function () {
58     it("pazpar2_url is a path or an full URL", function () {
59         expect(mkws.config.pazpar2_url).toMatch(/^(\/|https?:\/\/|undefined$)/)
60     });
61 });
62
63 describe("Check pazpar2 runtime", function () {
64     it("pazpar2 was successfully initialized", function () {
65         expect(mkws.config.error).toBe(undefined);
66     });
67 });