Debian Codegraph @

test/index-globals.html

raw
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>tv4</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <link rel="stylesheet" href="./deps/mocha.css"/>
7 <script src="./deps/jquery.js"></script>
8 <script src="./deps/mocha.js"></script>
9 <script src="./deps/proclaim.js"></script>
10 <script src="../tv4.js"></script>
11 <script src="../lang/de.js"></script>
12 <script>
13 mocha.setup('bdd');
14 window.onload = function () {
15 if (navigator.userAgent.indexOf('PhantomJS') < 0) {
16 mocha.run();
17 }
18 };
19
20 describe("tv4 globals", function () {
21 it("should have global tv4", function () {
22 proclaim.isDefined(tv4);
23 var schema = {
24 properties: {
25 intKey: {"type": "integer"},
26 stringKey: {"type": "string"}
27 }
28 };
29 proclaim.isTrue(tv4.validate({intKey: 1, stringKey: "one"}, schema));
30 proclaim.isFalse(tv4.validate({intKey: false, stringKey: "one"}, schema));
31 });
32 it("should have german language added to global", function () {
33 proclaim.isDefined(tv4);
34
35 tv4 = tv4.freshApi();
36
37 tv4.language('de');
38
39 var schema = {
40 properties: {
41 intKey: {"type": "integer"}
42 }
43 };
44 var res = tv4.validateResult({intKey: 'bad'}, schema);
45 proclaim.isFalse(res.valid);
46 proclaim.equal(res.error.message, 'Ungültiger Typ: string (erwartet wurde: integer)');
47 });
48 });
49 </script>
50 </head>
51 <body>
52 <div id="mocha"></div>
53 </body>
54 </html>