]> git.proxmox.com Git - extjs.git/blame - extjs/modern/modern/test/local/cmd-jasmine.js
add extjs 6.0.1 sources
[extjs.git] / extjs / modern / modern / test / local / cmd-jasmine.js
CommitLineData
6527f429
DM
1(function() {\r
2 if (typeof window.Cmd === 'undefined') {\r
3 return;\r
4 }\r
5 \r
6 if (typeof window.jasmine === 'undefined') {\r
7 throw new Error("Jasmine library does not exist in global namespace!");\r
8 }\r
9\r
10 var exportGlobal = function(instance, name) {\r
11 window[name] = function() {\r
12 instance[name].apply(instance, arguments);\r
13 }\r
14 addGlobal(name);\r
15 }\r
16\r
17 var JasmineReporter = function() {\r
18 var me = this;\r
19 exportGlobal(me, 'waitsForScreenshot');\r
20 exportGlobal(me, 'waitsForClick');\r
21 exportGlobal(me, 'waitsForSendKeys');\r
22 };\r
23\r
24 JasmineReporter.prototype = {\r
25\r
26 waitsForScreenshot: function(name) {\r
27 var done = false\r
28 runs(function() {\r
29 Cmd.native.screenshot(name, function() {\r
30 done = true;\r
31 });\r
32 });\r
33 waitsFor(function() {\r
34 return done;\r
35 });\r
36 },\r
37\r
38 waitsForClick: function(domElement) {\r
39 var done = false\r
40 runs(function() {\r
41 Cmd.native.click(domElement, function() {\r
42 done = true;\r
43 });\r
44 });\r
45 waitsFor(function() {\r
46 return done;\r
47 });\r
48 },\r
49\r
50 waitsForSendKeys: function(domElement, keys) {\r
51 var done = false;\r
52 runs(function() {\r
53 Cmd.native.sendKeys(domElement, keys, function() {\r
54 done = true;\r
55 });\r
56 });\r
57 waitsFor(function() {\r
58 return done;\r
59 });\r
60 },\r
61\r
62 reportRunnerStarting: function(runner) {\r
63 Cmd.status.runStarted();\r
64 },\r
65\r
66 reportRunnerResults: function(runner) {\r
67 Cmd.status.runFinished();\r
68 },\r
69\r
70 reportSpecResults: function(spec) { },\r
71\r
72 reportSpecStarting: function(spec) { },\r
73\r
74 reportSuiteStarting: function(suite) {\r
75 Cmd.status.suiteStarted(suite.description);\r
76 },\r
77\r
78 reportSuiteResults: function(suite) {\r
79 var results = suite.results();\r
80 var eachSpecFn = function(spec) {\r
81 if (spec.description) {\r
82 Cmd.status.testStarted(spec.description);\r
83 var specResultFn = function(result){\r
84 if (!result.passed()) {\r
85 Cmd.status.testFailed(spec.description, result.message, result.trace.stack);\r
86 }\r
87 };\r
88\r
89 for (var j = 0, jlen = spec.items_.length; j < jlen; j++) {\r
90 specResultFn(spec.items_[j]);\r
91 }\r
92 Cmd.status.testFinished(spec.description);\r
93 }\r
94 };\r
95 for (var i = 0, ilen = results.items_.length; i < ilen; i++) {\r
96 eachSpecFn(results.items_[i]);\r
97 }\r
98\r
99 Cmd.status.suiteFinished(suite.description);\r
100 \r
101 if (suite.cleanupResults) {\r
102 suite.cleanupResults();\r
103 }\r
104 }\r
105\r
106 };\r
107\r
108 Cmd.jasmine = {\r
109 Reporter: JasmineReporter\r
110 };\r
111})();\r