1 test("module without setup/teardown (default)", function() {
6 test("expect in test", 3, function() {
12 test("expect in test", 1, function() {
16 module("setup test", {
22 test("module with setup", function() {
29 module("setup/teardown test", {
34 teardown: function() {
39 test("module with setup/teardown", function() {
44 module("setup/teardown test 2");
46 test("module without setup/teardown", function() {
51 if (typeof setTimeout !== 'undefined') {
54 module("teardown and stop", {
55 teardown: function() {
56 equals(state, "done", "Test teardown.");
60 test("teardown must be called after test ended", function() {
63 setTimeout(function() {
68 } // end setTimeout tests
70 if (typeof asyncTest !== 'undefined') {
73 asyncTest("asyncTest", function() {
76 setTimeout(function() {
83 asyncTest("asyncTest", 2, function() {
85 setTimeout(function() {
91 } // end asyncTest tests
93 module("save scope", {
97 teardown: function() {
98 same(this.foo, "bar");
101 test("scope check", function() {
103 same(this.foo, "bar");
106 module("simple testEnvironment setup", {
108 bugid: "#5311" // example of meta-data
110 test("scope check", function() {
111 same(this.foo, "bar");
113 test("modify testEnvironment",function() {
116 test("testEnvironment reset for next test",function() {
117 same(this.foo, "bar");
120 module("testEnvironment with object", {
123 ingredients:["hamster","onions"]
126 test("scope check", function() {
127 same(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
129 test("modify testEnvironment",function() {
130 // since we do a shallow copy, the testEnvironment can be modified
131 this.options.ingredients.push("carrots");
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") ;
138 module("testEnvironment tests");
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);
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');
152 module("testEnvironment with makeurl settings",{
153 url:'http://google.com/',
154 q:'another_search_test'
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');
159 test("each test can extend the module testEnvironment", {
162 equals( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test');
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> ]" );