Debian Codegraph @

test/index-amd.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="../node_modules/requirejs/require.js"></script>
11 <script>
12 mocha.setup('bdd');
13 window.onload = function () {
14 if (navigator.userAgent.indexOf('PhantomJS') < 0) {
15 mocha.run();
16 }
17 };
18
19 describe("tv4 amd loading", function () {
20 it("should load tv4 using require", function (done) {
21 require(['../tv4'], function (tv4) {
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 done();
32 });
33 });
34 it("should load german language as AMD module", function (done) {
35 require(['../lang/de'], function (tv4) {
36 proclaim.isDefined(tv4);
37
38 tv4.language('de');
39
40 var schema = {
41 properties: {
42 intKey: {"type": "integer"}
43 }
44 };
45 var res = tv4.validateResult({intKey: 'bad'}, schema);
46 proclaim.isFalse(res.valid);
47 proclaim.equal(res.error.message, 'Ungültiger Typ: string (erwartet wurde: integer)');
48 done();
49 });
50 });
51 });
52 </script>
53 </head>
54 <body>
55 <div id="mocha"></div>
56 </body>
57 </html>