some files were executable, now they are not
[friendica-addons.git/.git] / js_upload / file-uploader / tests / qunit / test / test.js
1 test("module without setup/teardown (default)", function() {
2         expect(1);
3         ok(true);
4 });
5
6 test("expect in test", 3, function() {
7         ok(true);
8         ok(true);
9         ok(true);
10 });
11
12 test("expect in test", 1, function() {
13         ok(true);
14 });
15
16 module("setup test", {
17         setup: function() {
18                 ok(true);
19         }
20 });
21
22 test("module with setup", function() {
23         expect(2);
24         ok(true);
25 });
26
27 var state;
28
29 module("setup/teardown test", {
30         setup: function() {
31                 state = true;
32                 ok(true);
33         },
34         teardown: function() {
35                 ok(true);
36         }
37 });
38
39 test("module with setup/teardown", function() {
40         expect(3);
41         ok(true);
42 });
43
44 module("setup/teardown test 2");
45
46 test("module without setup/teardown", function() {
47         expect(1);
48         ok(true);
49 });
50
51 if (typeof setTimeout !== 'undefined') {
52 state = 'fail';
53
54 module("teardown and stop", {
55         teardown: function() {
56                 equals(state, "done", "Test teardown.");
57         }
58 });
59
60 test("teardown must be called after test ended", function() {
61         expect(1);
62         stop();
63         setTimeout(function() {
64                 state = "done";
65                 start();
66         }, 13);
67 });
68 } // end setTimeout tests
69
70 if (typeof asyncTest !== 'undefined') {
71 module("asyncTest");
72
73 asyncTest("asyncTest", function() {
74         expect(2);
75         ok(true);
76         setTimeout(function() {
77                 state = "done";
78                 ok(true);
79                 start();
80         }, 13);
81 });
82
83 asyncTest("asyncTest", 2, function() {
84         ok(true);
85         setTimeout(function() {
86                 state = "done";
87                 ok(true);
88                 start();
89         }, 13);
90 });
91 } // end asyncTest tests
92
93 module("save scope", {
94         setup: function() {
95                 this.foo = "bar";
96         },
97         teardown: function() {
98                 same(this.foo, "bar");
99         }
100 });
101 test("scope check", function() {
102         expect(2);
103         same(this.foo, "bar");
104 });
105
106 module("simple testEnvironment setup", {
107         foo: "bar",
108         bugid: "#5311" // example of meta-data
109 });
110 test("scope check", function() {
111         same(this.foo, "bar");
112 });
113 test("modify testEnvironment",function() {
114         this.foo="hamster";
115 });
116 test("testEnvironment reset for next test",function() {
117         same(this.foo, "bar");
118 });
119
120 module("testEnvironment with object", {
121         options:{
122                 recipe:"soup",
123                 ingredients:["hamster","onions"]
124         }
125 });
126 test("scope check", function() {
127         same(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
128 });
129 test("modify testEnvironment",function() {
130         // since we do a shallow copy, the testEnvironment can be modified
131         this.options.ingredients.push("carrots");
132 });
133 test("testEnvironment reset for next test",function() {
134         same(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
135 });
136
137
138 module("testEnvironment tests");
139
140 function makeurl() {
141   var testEnv = QUnit.current_testEnvironment;
142   var url = testEnv.url || 'http://example.com/search';
143   var q   = testEnv.q   || 'a search test';
144   return url + '?q='+encodeURIComponent(q);
145 }
146
147 test("makeurl working",function() {
148         equals( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
149   equals( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
150 });
151
152 module("testEnvironment with makeurl settings",{
153   url:'http://google.com/',
154   q:'another_search_test'
155 });
156 test("makeurl working with settings from testEnvironment",function() {
157   equals( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to form the url');
158 });
159 test("each test can extend the module testEnvironment", {
160         q:'hamstersoup'
161 }, function() {
162         equals( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test'); 
163 });
164
165 module("jsDump");
166 test("jsDump output", function() {
167         equals( QUnit.jsDump.parse([1, 2]), "[ 1, 2 ]" );
168         equals( QUnit.jsDump.parse({top: 5, left: 0}), "{ \"top\": 5, \"left\": 0 }" );
169         equals( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" );
170         equals( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[ <h1 id=\"qunit-header\"></h1> ]" );
171 })