@samitouri / QOS-React-2 / commits / 5da408297f

Remove in-browser unit testing

Rely on jest for now until we get a better and less hacky solution to running tests in the browser, probably a totally different test suite with different behavior/goals.

Paul O’Shannessy committed Jul 15, 2015 at 18:58 UTC 5da408297fd51d43a77f17fd0d2b569af0ab945f
42 files changed +2 -6534
.eslintignore
-5
@@ -2,11 +2,6 @@
2 src/shared/vendor
3 # This should be enabled but that folder has too much in it that doesn't belong
4 src/test
5 -test/the-files-to-test.generated.js
6 -# This is synced with a different file internally, don't want to lint it yet
7 -vendor/fbtransform/syntax.js
8 -vendor/jasmine/
9 -vendor/jasmine-jsreporter/
5 # But not in docs/_js/examples/*
6 docs/_js/*.js
7 docs/js/
.travis.yml
-11
@@ -66,12 +66,10 @@ script:
66 fi
67 env:
68 matrix:
69 - - TEST_TYPE=test
69 - TEST_TYPE=build
70 - TEST_TYPE=jest
71 - TEST_TYPE=lint
72 - TEST_TYPE=build_website
74 - - TEST_TYPE=test:webdriver:saucelabs:modern
73 global:
74 # SERVER
75 - secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
@@ -81,15 +79,6 @@ env:
79 - secure: EHCyCSKMwKlLHNtcj9nmkRzmiiPE3aDGlPcnEyrDJeRI0SeN/iCXHXfFivR0vFq3vr+9naMBczAR2AEidtps5KbJrKqdZnjPFRbmfVtzWr/LlvVCub3u13Pub6TdKIVBTny1PuZ5X8GvdxMNVig89jGjvzhhWuQRaz3VhJnTra4=
80 matrix:
81 fast_finish: true
84 - allow_failures:
85 - - env: TEST_TYPE=test:coverage
86 - - env: TEST_TYPE=test:webdriver:saucelabs:modern
87 - - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
88 - - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
89 - - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
90 - - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
91 - - env: TEST_TYPE=test:webdriver:saucelabs:ios
92 - - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
82 notifications:
83 irc:
84 use_notice: true
Gruntfile.js
+1 -105
@@ -6,9 +6,6 @@ module.exports = function(grunt) {
6 pkg: grunt.file.readJSON('package.json'),
7 jsx: require('./grunt/config/jsx'),
8 browserify: require('./grunt/config/browserify'),
9 - populist: require('./grunt/config/populist')(grunt),
10 - connect: require('./grunt/config/server')(grunt),
11 - 'webdriver-jasmine': require('./grunt/config/webdriver-jasmine'),
9 npm: require('./grunt/config/npm'),
10 clean: [
11 './build',
@@ -39,11 +36,6 @@ module.exports = function(grunt) {
36
37 grunt.registerTask('lint', ['eslint']);
38
42 - grunt.registerTask(
43 - 'download-previous-version',
44 - require('./grunt/tasks/download-previous-version.js')
45 - );
46 -
39 grunt.registerTask('delete-build-modules', function() {
40 if (grunt.file.exists('build/modules')) {
41 grunt.file.delete('build/modules');
@@ -56,12 +48,6 @@ module.exports = function(grunt) {
48 // Our own browserify-based tasks to build a single JS file build.
49 grunt.registerMultiTask('browserify', require('./grunt/tasks/browserify'));
50
59 - grunt.registerMultiTask('populist', require('./grunt/tasks/populist'));
60 -
61 - grunt.registerTask('sauce-tunnel', require('./grunt/tasks/sauce-tunnel'));
62 -
63 - grunt.registerMultiTask('webdriver-jasmine', require('./grunt/tasks/webdriver-jasmine'));
64 -
51 grunt.registerMultiTask('npm', require('./grunt/tasks/npm'));
52
53 var npmReactTasks = require('./grunt/tasks/npm-react');
@@ -107,17 +93,6 @@ module.exports = function(grunt) {
93 'jsx:normal',
94 'browserify:addonsMin',
95 ]);
110 - grunt.registerTask('build:withCodeCoverageLogging', [
111 - 'jsx:normal',
112 - 'version-check',
113 - 'browserify:withCodeCoverageLogging',
114 - ]);
115 - grunt.registerTask('build:test', [
116 - 'delete-build-modules',
117 - 'jsx:test',
118 - 'version-check',
119 - 'populist:test',
120 - ]);
96 grunt.registerTask('build:npm-react', [
97 'version-check',
98 'jsx:normal',
@@ -128,89 +103,10 @@ module.exports = function(grunt) {
103 'gem-react-source:release',
104 ]);
105
131 - grunt.registerTask('webdriver-phantomjs', require('./grunt/tasks/webdriver-phantomjs'));
132 -
133 - grunt.registerTask('coverage:parse', require('./grunt/tasks/coverage-parse'));
134 -
135 - grunt.registerTask('test:webdriver:phantomjs', [
136 - 'connect',
137 - 'webdriver-phantomjs',
138 - 'webdriver-jasmine:local',
139 - ]);
140 -
141 - grunt.registerTask('test:full', [
142 - 'build:test',
143 - 'build:basic',
144 -
145 - 'connect',
146 - 'webdriver-phantomjs',
147 - 'webdriver-jasmine:local',
148 -
149 - 'sauce-tunnel',
150 - 'webdriver-jasmine:saucelabs_android',
151 - 'webdriver-jasmine:saucelabs_firefox',
152 - 'webdriver-jasmine:saucelabs_chrome',
153 - ]);
154 -
155 - grunt.registerTask('test:webdriver:saucelabs', [
156 - 'build:test',
157 - 'build:basic',
158 -
159 - 'connect',
160 - 'sauce-tunnel',
161 - 'webdriver-jasmine:saucelabs_' + (process.env.BROWSER_NAME || 'ie8'),
162 - ]);
163 -
164 - grunt.registerTask('test:webdriver:saucelabs:modern', [
165 - 'build:test',
166 - 'build:basic',
167 -
168 - 'connect',
169 - 'sauce-tunnel',
170 - 'webdriver-jasmine:saucelabs_android',
171 - 'webdriver-jasmine:saucelabs_firefox',
172 - 'webdriver-jasmine:saucelabs_chrome',
173 - 'webdriver-jasmine:saucelabs_ie11',
174 - ]);
175 -
176 - grunt.registerTask('test:webdriver:saucelabs:ie', [
177 - 'build:test',
178 - 'build:basic',
179 -
180 - 'connect',
181 - 'sauce-tunnel',
182 - 'webdriver-jasmine:saucelabs_ie8',
183 - 'webdriver-jasmine:saucelabs_ie9',
184 - 'webdriver-jasmine:saucelabs_ie10',
185 - 'webdriver-jasmine:saucelabs_ie11',
186 - ]);
187 -
188 - grunt.registerTask('test:webdriver:saucelabs:ios', [
189 - 'build:test',
190 - 'build:basic',
191 -
192 - 'connect',
193 - 'sauce-tunnel',
194 - 'webdriver-jasmine:saucelabs_ios6_1',
195 - 'webdriver-jasmine:saucelabs_ios5_1',
196 - 'webdriver-jasmine:saucelabs_ios4',
197 - ]);
198 -
199 - grunt.registerTask('test:coverage', [
200 - 'build:withCodeCoverageLogging',
201 - 'test:webdriver:phantomjs',
202 - 'coverage:parse',
203 - ]);
106 grunt.registerTask('fasttest', function() {
107 grunt.task.run('test');
108 });
207 - grunt.registerTask('test', function() {
208 - if (grunt.option('debug')) {
209 - grunt.task.run('build:test', 'connect:server:keepalive');
210 - } else {
211 - grunt.task.run('build:test', 'test:webdriver:phantomjs');
212 - }
213 - });
109 + grunt.registerTask('test', ['jest']);
110 grunt.registerTask('npm:test', ['build', 'npm:pack']);
111
112 // Optimized build task that does all of our builds. The subtasks will be run
bin/jsx-internal
-17
@@ -43,22 +43,5 @@ require("commoner").version(
43 }).code;
44 }
45
46 - if (context.config.mocking) {
47 - // Make sure there is exactly one newline at the end of the module.
48 - source = source.replace(/\s+$/m, "\n");
49 -
50 - return context.getProvidedP().then(function(idToPath) {
51 - if (id !== "mock-modules" &&
52 - id !== "mocks" &&
53 - id !== "test/all" &&
54 - idToPath.hasOwnProperty("mock-modules")) {
55 - return source + '\nrequire("mock-modules").register(' +
56 - JSON.stringify(id) + ', module);\n';
57 - }
58 -
59 - return source;
60 - });
61 - }
62 -
46 return source;
47 });
grunt/config/browserify.js
-15
@@ -121,25 +121,10 @@ var addonsMin = {
121 after: [/*derequire,*/ minify, bannerify],
122 };
123
124 -var withCodeCoverageLogging = {
125 - entries: [
126 - './build/modules/React.js',
127 - ],
128 - outfile: './build/react.js',
129 - debug: true,
130 - standalone: 'React',
131 - transforms: [
132 - envify({NODE_ENV: process.env.NODE_ENV || 'development'}),
133 - require('coverify'),
134 - ],
135 - plugins: [collapser],
136 -};
137 -
124 module.exports = {
125 basic: basic,
126 min: min,
127 transformer: transformer,
128 addons: addons,
129 addonsMin: addonsMin,
144 - withCodeCoverageLogging: withCodeCoverageLogging,
130 };
grunt/config/jsx.js
-18
@@ -1,6 +1,5 @@
1 'use strict';
2
3 -var assign = require('../../src/shared/stubs/Object.assign');
3 var grunt = require('grunt');
4
5 var rootIDs = [
@@ -21,23 +20,6 @@ var normal = {
20 outputDir: 'build/modules',
21 };
22
24 -
25 -var test = {
26 - rootIDs: rootIDs.concat([
27 - 'test/all.js',
28 - '**/__tests__/*.js',
29 - ]),
30 - getConfig: function() {
31 - return assign({}, normal.getConfig(), {
32 - mocking: true,
33 - });
34 - },
35 - sourceDir: 'src',
36 - outputDir: 'build/modules',
37 -};
38 -
39 -
23 module.exports = {
24 normal: normal,
42 - test: test,
25 };
grunt/config/populist.js deleted
-32
@@ -1,32 +0,0 @@
1 -'use strict';
2 -
3 -module.exports = function(grunt) {
4 - var jasmine = {
5 - rootDirectory: 'build/jasmine',
6 - // This syntax means to require and expose the 'jasmine' module
7 - // (build/jasmine/jasmine.js) as global.jasmine, and to require the
8 - // 'all' module (build/jasmine/all.js) but not expose it globally.
9 - args: ['jasmine:jasmine', 'all:'],
10 - outfile: './build/jasmine.js',
11 - };
12 -
13 - var filterExpr = grunt.option('filter');
14 -
15 - if (filterExpr) {
16 - filterExpr = '**/__tests__/' + filterExpr + '-test.js';
17 - } else {
18 - filterExpr = '**/__tests__/*-test.js';
19 - }
20 -
21 - var test = {
22 - rootDirectory: 'build/modules',
23 - args: ['test/all:harness'],
24 - requires: [filterExpr],
25 - outfile: './build/react-test.js',
26 - };
27 -
28 - return {
29 - jasmine: jasmine,
30 - test: test,
31 - };
32 -};
grunt/config/server.js deleted
-112
@@ -1,112 +0,0 @@
1 -'use strict';
2 -
3 -var fs = require('fs');
4 -var path = require('path');
5 -
6 -module.exports = function(grunt) {
7 - var coverageWriteStream;
8 -
9 - grunt.task.registerTask('finalize-coverage-stream', function() {
10 - if (!coverageWriteStream) {
11 - return;
12 - }
13 - var done = this.async();
14 - coverageWriteStream.once('close', done);
15 - coverageWriteStream.end();
16 - coverageWriteStream = null;
17 - });
18 -
19 - function consoleLoggerMiddleware(req, res, next) {
20 - if (!(req.method === 'POST' && req._parsedUrl.pathname.replace(/\//g, '') === 'console' && Array.isArray(req.body))) {
21 - return next();
22 - }
23 - res.write('<!doctype html><meta charset=utf-8>');
24 - res.end('Got it, thanks!');
25 -
26 - req.body.forEach(function(log) {
27 - if (log.message.indexOf('not ok ') === 0) {
28 - log.type = 'error';
29 - } else if (log.message.indexOf('ok ') === 0) {
30 - log.type = 'ok';
31 - } else if (log.message.indexOf('COVER') === 0) {
32 - log.type = 'coverage';
33 - } else if (log.message.indexOf('DONE\t') === 0) {
34 - log.type = 'coverage done';
35 - }
36 -
37 - if (log.type === 'error') {
38 - grunt.log.error(log.message);
39 - } else if (log.type === 'ok') {
40 - grunt.log.ok(log.message);
41 - } else if (log.type === 'log') {
42 - grunt.log.writeln(log.message);
43 - } else if (log.type === 'coverage') {
44 - if (!coverageWriteStream) {
45 - coverageWriteStream = fs.createWriteStream(path.join(__dirname, '/../../coverage.log'));
46 - }
47 - coverageWriteStream.write(log.message + '\n');
48 - } else if (log.type === 'coverage done') {
49 - grunt.task.run('finalize-coverage-stream');
50 - } else if (log.type === 'perf') {
51 - grunt.event.emit('perf results', log.message);
52 - } else {
53 - grunt.verbose.writeln(log);
54 - }
55 - });
56 - }
57 -
58 - function testResultLoggerMiddleware(req, res, next) {
59 - if (!(req.method === 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) {
60 - return next();
61 - }
62 - res.write('<!doctype html><meta charset=utf-8>');
63 - res.end('Got it, thanks!');
64 -
65 - var logType = 'writeln';
66 - var message = req.body;
67 -
68 - if (req.body.type && req.body.message) {
69 - if (req.body.type === 'error') {
70 - logType = 'error';
71 - } else if (req.body.message.indexOf('ok') === 0) {
72 - logType = 'ok';
73 - } else if (req.body.message.indexOf('not ok') === 0) {
74 - logType = 'error';
75 - }
76 - message = req.body.message;
77 - }
78 - if (typeof message !== 'string') {
79 - message = JSON.stringify(message, null, 2);
80 - }
81 - grunt.log[logType]('[%s][%s]', req.headers['user-agent'], Date.now(), message);
82 - }
83 -
84 - return {
85 - server: {
86 - options: {
87 - base: '.',
88 - hostname: '*',
89 - port: 9999,
90 - middleware: function(connect, options) {
91 -
92 - connect.logger.token('user-agent', function(req, res) {
93 - return req.headers['user-agent'];
94 - });
95 - connect.logger.token('timestamp', function(req, res) {
96 - return Date.now();
97 - });
98 -
99 - return [
100 - connect.json(),
101 - consoleLoggerMiddleware,
102 - testResultLoggerMiddleware,
103 -
104 - connect.logger({format:'[:user-agent][:timestamp] :method :url', stream:grunt.verbose}),
105 - connect.static(options.base),
106 - connect.directory(options.base),
107 - ];
108 - },
109 - },
110 - },
111 - };
112 -};
grunt/config/webdriver-all.js deleted
-115
@@ -1,115 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -
5 -module.exports = function(props) {
6 - if (typeof props.url !== 'string') {
7 - throw TypeError('expected url string');
8 - }
9 - if ('isDoneTimeout' in props && typeof props.isDoneTimeout !== 'number') {
10 - throw TypeError('expected isDoneTimeout to be a number');
11 - }
12 - if ('onStart' in props && typeof props.onStart !== 'function') {
13 - throw TypeError('expected onStart to be a function');
14 - }
15 - if ('onComplete' in props && typeof props.onComplete !== 'function') {
16 - throw TypeError('expected onComplete to be a function');
17 - }
18 - if ('onError' in props && typeof props.onError !== 'function') {
19 - throw TypeError('expected onError to be a function');
20 - }
21 -
22 - var exports = {};
23 -
24 - exports.local = {
25 - webdriver: {
26 - remote: {protocol: 'http:', hostname: '127.0.0.1', port: 9515, path: '/'},
27 - },
28 - url: props.url,
29 - onStart: props.onStart,
30 - onComplete: props.onComplete,
31 - onError: props.onError,
32 - isDoneTimeout: props.isDoneTimeout,
33 - };
34 -
35 - if (grunt.option('debug')) {
36 - exports.local.url += (exports.local.url.indexOf('?') === -1 ? '?' : '&') + 'debug=' + grunt.option('debug');
37 - }
38 -
39 - exports.saucelabs = {
40 - webdriver: {
41 - remote: {
42 - /* https://github.com/admc/wd/blob/master/README.md#named-parameters */
43 - user: process.env.SAUCE_USERNAME || 'React',
44 - pwd: process.env.SAUCE_ACCESS_KEY || '339d32ca-d594-4570-a3c2-94c50a91919b',
45 - protocol: 'http:',
46 - hostname: 'ondemand.saucelabs.com',
47 - port: '80',
48 - path: '/wd/hub',
49 - },
50 - },
51 - desiredCapabilities: {
52 - 'build': process.env.TRAVIS_BUILD_NUMBER || 'dev' + Date.now(),
53 - 'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel',
54 - 'browserName': 'chrome',
55 - },
56 - url: exports.local.url,
57 - onStart: function(browser) {
58 - grunt.log.writeln('Starting WebDriver Test. Watch results here: http://saucelabs.com/tests/' + browser.sessionID);
59 - if (props.onStart) {
60 - return props.onStart(browser);
61 - }
62 - },
63 - onComplete: exports.local.onComplete,
64 - onError: exports.local.onError,
65 - isDoneTimeout: exports.local.isDoneTimeout,
66 - };
67 -
68 - /*eslint-disable camelcase*/
69 - /* https://saucelabs.com/platforms */
70 - exports.saucelabs_ios =
71 - exports.saucelabs_ios7 = sauceItUp({browserName: 'iphone', version: '7', platform:'OS X 10.9'});
72 - exports.saucelabs_ios6_1 = sauceItUp({browserName: 'iphone', version: '6.1', platform:'OS X 10.8'});
73 - exports.saucelabs_ios6 = sauceItUp({browserName: 'iphone', version: '6', platform:'OS X 10.8'});
74 - exports.saucelabs_ios5_1 = sauceItUp({browserName: 'iphone', version: '5.1', platform:'OS X 10.8'});
75 - exports.saucelabs_ios5 = sauceItUp({browserName: 'iphone', version: '5', platform:'OS X 10.6'});
76 - exports.saucelabs_ios4 = sauceItUp({browserName: 'iphone', version: '4', platform:'OS X 10.6'});
77 -
78 - exports.saucelabs_ipad =
79 - exports.saucelabs_ipad7 = sauceItUp({browserName: 'ipad', version: '7', platform:'OS X 10.9'});
80 - exports.saucelabs_ipad6_1 = sauceItUp({browserName: 'ipad', version: '6.1', platform:'OS X 10.8'});
81 - exports.saucelabs_ipad6 = sauceItUp({browserName: 'ipad', version: '6', platform:'OS X 10.8'});
82 - exports.saucelabs_ipad5_1 = sauceItUp({browserName: 'ipad', version: '5.1', platform:'OS X 10.8'});
83 - exports.saucelabs_ipad5 = sauceItUp({browserName: 'ipad', version: '5', platform:'OS X 10.6'});
84 - exports.saucelabs_ipad4 = sauceItUp({browserName: 'ipad', version: '4', platform:'OS X 10.6'});
85 -
86 - exports.saucelabs_android = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux'});
87 - exports.saucelabs_android_tablet = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux', 'device-type':'tablet'});
88 -
89 - exports.saucelabs_safari = sauceItUp({browserName: 'safari'});
90 - exports.saucelabs_chrome = sauceItUp({browserName: 'chrome'});
91 - exports.saucelabs_firefox = sauceItUp({browserName: 'firefox'});
92 -
93 - exports.saucelabs_ie =
94 - exports.saucelabs_ie8 = sauceItUp({browserName: 'internet explorer', version: 8});
95 - exports.saucelabs_ie9 = sauceItUp({browserName: 'internet explorer', version: 9});
96 - exports.saucelabs_ie10 = sauceItUp({browserName: 'internet explorer', version: 10});
97 - exports.saucelabs_ie11 = sauceItUp({browserName: 'internet explorer', version: 11, platform:'Windows 8.1'});
98 - /*eslint-enable camelcase*/
99 -
100 - function sauceItUp(desiredCapabilities) {
101 - desiredCapabilities.build = exports.saucelabs.desiredCapabilities.build;
102 - desiredCapabilities['tunnel-identifier'] = exports.saucelabs.desiredCapabilities['tunnel-identifier'];
103 - return {
104 - webdriver: exports.saucelabs.webdriver,
105 - url: exports.saucelabs.url,
106 - onStart: exports.saucelabs.onStart,
107 - onComplete: exports.saucelabs.onComplete,
108 - onError: exports.saucelabs.onError,
109 - isDoneTimeout: exports.saucelabs.isDoneTimeout,
110 - desiredCapabilities: desiredCapabilities,
111 - };
112 - }
113 -
114 - return exports;
115 -};
grunt/config/webdriver-jasmine.js deleted
-15
@@ -1,15 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -
5 -module.exports = require('./webdriver-all')({
6 - url: 'http://127.0.0.1:9999/test/index.html',
7 - onComplete: function(passed) {
8 - if (!passed) {
9 - grunt.fatal('tests failed');
10 - }
11 - },
12 - onError: function(error) {
13 - grunt.fatal(error);
14 - },
15 -});
grunt/tasks/coverage-parse.js deleted
-54
@@ -1,54 +0,0 @@
1 -'use strict';
2 -var grunt = require('grunt');
3 -var path = require('path');
4 -var fs = require('fs');
5 -
6 -module.exports = function() {
7 - var ROOT = path.join(__dirname, '/../..');
8 - var done = this.async();
9 - var uncoveredExpressionCount = 0;
10 - var uncoveredLineCount = 0;
11 -
12 - fs.createReadStream(ROOT + '/coverage.log')
13 - .pipe(require('coverify/parse')(function(error, results) {
14 - if (error) {
15 - grunt.fatal(error);
16 - }
17 -
18 - Object.keys(results)
19 - .sort(function(a, b) {
20 - return results[a].length - results[b].length;
21 - })
22 - .reverse()
23 - .forEach(function(concretePath) {
24 - if (results[concretePath].length === 0) {
25 - return;
26 - }
27 - var relativePath = concretePath.replace(ROOT, '');
28 - uncoveredExpressionCount += results[concretePath].length;
29 - grunt.log.error(results[concretePath].length + ' expressions not covered ' + relativePath);
30 -
31 - results[concretePath].forEach(function(c) {
32 - uncoveredLineCount += c.code.split('\n').length;
33 - console.log('txmt://open?url=' + encodeURIComponent('file://' + concretePath) + '&line=' + (c.lineNum + 1) + '&column=' + (c.column[0] + 2));
34 - });
35 - console.log('');
36 - });
37 -
38 - Object.keys(results).sort().forEach(function(concretePath) {
39 - if (results[concretePath].length > 0) {
40 - return;
41 - }
42 - var relativePath = concretePath.replace(ROOT, '');
43 - grunt.log.ok('100% coverage ' + relativePath);
44 - });
45 -
46 - if (uncoveredExpressionCount > 0) {
47 - grunt.log.error(uncoveredExpressionCount + ' expressions not covered');
48 - }
49 - if (uncoveredLineCount > 0) {
50 - grunt.log.error(uncoveredLineCount + ' lines not covered');
51 - }
52 - done();
53 - }));
54 -};
grunt/tasks/download-previous-version.js deleted
-47
@@ -1,47 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -var http = require('http');
5 -var fs = require('fs');
6 -var path = require('path');
7 -
8 -function get(url, targetFilePath, completedSuccessfully) {
9 - grunt.verbose.writeln('getting url \'' + url + '\'');
10 - http.get(url, function(response) {
11 - grunt.verbose.writeln('Received status code ' + response.statusCode + ' for \'' + url + '\'');
12 -
13 - if (response.statusCode !== 200) {
14 - if (response.headers.location) {
15 - get(response.headers.location, targetFilePath);
16 - return;
17 - } else {
18 - grunt.fatal('Nothing else to do.');
19 - completedSuccessfully(false);
20 - return;
21 - }
22 - }
23 - grunt.verbose.writeln('Writing url to \'' + targetFilePath + '\'');
24 - response.pipe(fs.createWriteStream(targetFilePath))
25 - .on('close', function() {
26 - completedSuccessfully(true);
27 - });
28 - });
29 -}
30 -
31 -module.exports = function() {
32 - var completedSuccessfully = this.async();
33 - get(
34 - 'http://react.zpao.com/builds/master/latest/react.min.js',
35 - path.join(__dirname, '/../../build/react-previous.min.js'),
36 - function(success) {
37 - if (!success) {
38 - return completedSuccessfully(success);
39 - }
40 - get(
41 - 'http://react.zpao.com/builds/master/latest/JSXTransformer.js',
42 - path.join(__dirname, '/../../build/JSXTransformer-previous.js'),
43 - completedSuccessfully
44 - );
45 - }
46 - );
47 -};
grunt/tasks/populist.js deleted
-40
@@ -1,40 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -var fs = require('fs');
5 -var path = require('path');
6 -
7 -module.exports = function() {
8 - var config = this.data;
9 - var done = this.async();
10 -
11 - var theFilesToTestScript = fs.createWriteStream(path.join(__dirname, '/../../test/the-files-to-test.generated.js'));
12 - theFilesToTestScript.write('// Generated by ');
13 - theFilesToTestScript.write(JSON.stringify(__filename.split(/(?=grunt)/)[1]));
14 - theFilesToTestScript.write(' at ');
15 - theFilesToTestScript.write(JSON.stringify(new Date()));
16 - theFilesToTestScript.write('\n\n');
17 -
18 - // create the bundle we'll work with
19 - var args = config.args;
20 -
21 - // Make sure the things that need to be exposed are.
22 - var requires = config.requires || [];
23 - grunt.file.expand({
24 - nonull: true, // Keep IDs that don't expand to anything.
25 - cwd: config.rootDirectory,
26 - }, requires).forEach(function(name) {
27 - name = name.replace(/\.js$/i, '');
28 - args.push(name);
29 - theFilesToTestScript.write('harness.enableTest(' + JSON.stringify(name) + ');\n');
30 - });
31 -
32 - require('populist').buildP({
33 - rootDirectory: config.rootDirectory,
34 - args: args,
35 - }).then(function(output) {
36 - grunt.file.write(config.outfile, 'process = {env: {}};' + output);
37 - theFilesToTestScript.end();
38 - theFilesToTestScript.once('close', done);
39 - });
40 -};
grunt/tasks/sauce-tunnel.js deleted
-43
@@ -1,43 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -var SauceTunnel = require('sauce-tunnel');
5 -
6 -module.exports = function() {
7 - var task = this;
8 - var shouldStayAliveForever = task.flags.keepalive;
9 -
10 - var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || '339d32ca-d594-4570-a3c2-94c50a91919b';
11 - if (!SAUCE_ACCESS_KEY) {
12 - grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set');
13 - }
14 -
15 - var SAUCE_USERNAME = process.env.SAUCE_USERNAME || 'React';
16 - if (!SAUCE_USERNAME) {
17 - grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set');
18 - }
19 -
20 - var IDENTIFIER = process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel';
21 -
22 - var taskCompletedSuccessfully = task.async();
23 -
24 - var stunnel = new SauceTunnel(SAUCE_USERNAME, SAUCE_ACCESS_KEY, IDENTIFIER, /*tunneled*/true, /*tunnelTimeout*/5);
25 - process.on('exit', stunnel.stop.bind(stunnel, function() {}));
26 -
27 - stunnel.on('log:error', grunt.log.error.bind(grunt.log));
28 - stunnel.on('log:writeln', grunt.log.writeln.bind(grunt.log));
29 -
30 - stunnel.on('verbose:ok', grunt.verbose.ok.bind(grunt.verbose));
31 - stunnel.on('verbose:error', grunt.verbose.error.bind(grunt.verbose));
32 - stunnel.on('verbose:debug', grunt.verbose.debug.bind(grunt.verbose));
33 - stunnel.on('verbose:writeln', grunt.verbose.writeln.bind(grunt.verbose));
34 -
35 - stunnel.openTunnel(function(isOpen) {
36 - if (shouldStayAliveForever && isOpen) {
37 - grunt.verbose.writeln('Keeping the sauce-tunnel open forever because you used the keepalive flag `' + task.nameArgs + '`');
38 - return;
39 - }
40 - grunt.verbose.writeln('To keep the sauce-tunnel open forever, use the grunt task `' + task.nameArgs + ':keepalive`');
41 - taskCompletedSuccessfully(isOpen);
42 - });
43 -};
grunt/tasks/webdriver-all.js deleted
-77
@@ -1,77 +0,0 @@
1 -/*eslint-disable consistent-return*/
2 -'use strict';
3 -
4 -var grunt = require('grunt');
5 -var wd = require('wd');
6 -
7 -module.exports = function task(getJSReport) {
8 - var config = this.data;
9 - var taskSucceeded = this.async();
10 - getJSReport = getJSReport.bind(this, config, wd);
11 -
12 - var desiredCapabilities = {};
13 - if (config.desiredCapabilities) {
14 - Object.keys(config.desiredCapabilities).forEach(function(key) {
15 - if (config.desiredCapabilities[key] === undefined) {
16 - return;
17 - }
18 - desiredCapabilities[key] = config.desiredCapabilities[key];
19 - });
20 - }
21 - grunt.verbose.writeln('desiredCapabilities', JSON.stringify(desiredCapabilities));
22 -
23 - var browser = wd.promiseChainRemote(config.webdriver.remote);
24 -
25 - browser.on('status', function(info) {
26 - grunt.verbose.writeln(info);
27 - });
28 -
29 - browser.on('command', function(meth, path, data) {
30 - grunt.verbose.writeln(' > ' + meth, path, data || '');
31 - });
32 -
33 - var results = null;
34 -
35 - // browser._debugPromise();
36 - browser
37 - .init(desiredCapabilities)
38 - .then(config.onStart && config.onStart.bind(config, browser))
39 - .get(config.url)
40 - .then(function() {
41 - return browser;
42 - })
43 - .then(getJSReport)
44 - .then(function(data) {
45 - results = data;
46 - })
47 - .fail(function(error) {
48 - grunt.log.error(error);
49 - return browser
50 - .eval('document.documentElement.innerText || document.documentElement.textContent')
51 - .then(grunt.verbose.writeln.bind(grunt.verbose))
52 - .then(function() {
53 - throw error;
54 - });
55 - })
56 - .finally(function() {
57 - if (grunt.option('webdriver-keep-open')) {
58 - return;
59 - }
60 - grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
61 - return browser.quit();
62 - })
63 - .done(
64 - function() {
65 - if (config.onComplete) {
66 - config.onComplete(results);
67 - }
68 - taskSucceeded(true);
69 - },
70 - function(error) {
71 - if (config.onError) {
72 - config.onError(error);
73 - }
74 - taskSucceeded(false);
75 - }
76 - );
77 -};
grunt/tasks/webdriver-jasmine.js deleted
-14
@@ -1,14 +0,0 @@
1 -'use strict';
2 -
3 -module.exports = function() {
4 - return require('./webdriver-all').call(this, function(config, wd, browser) {
5 - return browser
6 - .waitFor(wd.asserters.jsCondition('typeof window.jasmine != \'undefined\''), 5e3, 50)
7 - .fail(function(error) {
8 - throw Error('The test page didn\'t load properly. ' + error);
9 - })
10 - .waitFor(wd.asserters.jsCondition('typeof window.jasmine.getJSReport != \'undefined\''), 60e3, 100)
11 - .waitFor(wd.asserters.jsCondition('window.postDataToURL.running <= 0'), 30e3, 500)
12 - .eval('jasmine.getJSReport().passed');
13 - });
14 -};
grunt/tasks/webdriver-phantomjs.js deleted
-41
@@ -1,41 +0,0 @@
1 -'use strict';
2 -
3 -var grunt = require('grunt');
4 -
5 -module.exports = function() {
6 - var onReadyCallback = this.async();
7 -
8 - var phantomjs = require('phantomjs').path;
9 - var childProcess = require('child_process');
10 - var config = this.data || {};
11 -
12 - var args = ['--webdriver=' + (config.port || 9515)];
13 - grunt.verbose.writeln('phantomjs START path:%s args:%s', phantomjs, args);
14 -
15 - var child = childProcess.spawn(phantomjs, args);
16 - process.on('exit', function() {
17 - child.kill();
18 - });
19 -
20 - child.on('error', function(error) {
21 - grunt.verbose.writeln('phantomjs ERROR');
22 - grunt.fatal(error);
23 - });
24 - child.on('exit', function(code) {
25 - grunt.verbose.writeln('phantomjs END');
26 - if (code) {
27 - grunt.fatal('phantomjs FAIL');
28 - }
29 - });
30 -
31 - function verboseWrite(chunk) {
32 - if (onReadyCallback && chunk.toString().indexOf('running on port') !== -1) {
33 - grunt.verbose.writeln('phantomjs STARTED');
34 - onReadyCallback();
35 - onReadyCallback = null;
36 - }
37 - grunt.verbose.write(chunk);
38 - }
39 - child.stdout.on('data', verboseWrite);
40 - child.stderr.on('data', verboseWrite);
41 -};
package.json
+1 -9
@@ -35,10 +35,8 @@
35 "browserify": "^9.0.3",
36 "bundle-collapser": "^1.1.1",
37 "coffee-script": "^1.8.0",
38 - "coverify": "^1.3.3",
38 "derequire": "^2.0.0",
39 "envify": "^3.0.0",
41 - "es5-shim": "^4.0.0",
40 "eslint": "^0.22.1",
41 "eslint-plugin-react": "^2.5.0",
42 "eslint-plugin-react-internal": "file:eslint-rules",
@@ -48,22 +46,16 @@
46 "grunt-compare-size": "^0.4.0",
47 "grunt-contrib-clean": "^0.6.0",
48 "grunt-contrib-compress": "^0.13.0",
51 - "grunt-contrib-connect": "~0.6.0",
49 "grunt-jest": "^0.1.3",
50 "gzip-js": "~0.3.2",
54 - "jasmine-tapreporter": "~0.2.2",
51 "jest-cli": "^0.4.13",
52 "object-assign": "^3.0.0",
53 "optimist": "^0.6.1",
58 - "phantomjs": "^1.9.17",
54 "platform": "^1.1.0",
60 - "populist": "~0.1.6",
61 - "sauce-tunnel": "~1.1.0",
55 "tmp": "~0.0.18",
56 "typescript": "^1.4.0",
57 "uglify-js": "^2.4.23",
65 - "uglifyify": "^3.0.1",
66 - "wd": "~0.2.6"
58 + "uglifyify": "^3.0.1"
59 },
60 "engines": {
61 "node": ">=0.10.0"
src/test/all.js deleted
-31
@@ -1,31 +0,0 @@
1 -// This file exists both to give a single entry point for all the utility
2 -// modules in src/test and to specify an ordering on those modules, since
3 -// some still have implicit dependencies on others.
4 -
5 -require("./phantomjs-shims");
6 -require("ReactTestUtils");
7 -require("reactComponentExpect");
8 -require("mocks");
9 -require("mock-modules");
10 -require("./mock-timers");
11 -
12 -exports.enableTest = function(testID) {
13 - describe(testID, function() {
14 - beforeEach(function() {
15 - require("mock-modules").setMockMap(mockMap);
16 - });
17 -
18 - require("mock-modules").clearMockMap();
19 - require("../" + testID);
20 - var mockMap = require("mock-modules").getMockMap();
21 - });
22 -};
23 -
24 -exports.removeNextSiblings = function(node) {
25 - var parent = node && node.parentNode;
26 - if (parent) {
27 - while (node.nextSibling) {
28 - parent.removeChild(node.nextSibling);
29 - }
30 - }
31 -};
src/test/mock-modules.js deleted
-125
@@ -1,125 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule mock-modules
10 - */
11 -
12 -var mocks = require("mocks");
13 -var exportsRegistry = {};
14 -var hasOwn = exportsRegistry.hasOwnProperty;
15 -var explicitMockMap = {};
16 -
17 -function getMock(exports) {
18 - try {
19 - return mocks.generateFromMetadata(mocks.getMetadata(exports));
20 - } catch (err) {
21 - console.warn(err);
22 - return exports;
23 - }
24 -}
25 -
26 -// This function should be called at the bottom of any module that might
27 -// need to be mocked, after the final value of module.exports is known.
28 -exports.register = function(id, module) {
29 - exportsRegistry[id] = {
30 - module: module,
31 - actual: module.exports,
32 - mocked: null // Filled in lazily later.
33 - };
34 -
35 - // If doMock or doNotMock was called earlier, before the module was
36 - // registered, then the choice should have been recorded in
37 - // explicitMockMap. Now that the module is registered, we can finally
38 - // fulfill the request.
39 - if (hasOwn.call(explicitMockMap, id)) {
40 - if (explicitMockMap[id]) {
41 - doMock(id);
42 - } else {
43 - doNotMock(id);
44 - }
45 - }
46 -
47 - return exports;
48 -};
49 -
50 -function resetEntry(id) {
51 - if (hasOwn.call(exportsRegistry, id)) {
52 - delete exportsRegistry[id].module.exports;
53 - delete exportsRegistry[id];
54 - }
55 -}
56 -
57 -exports.dumpCache = function() {
58 - require("mocks").clear();
59 -
60 - // Deleting module.exports will cause the module to be lazily
61 - // reevaluated the next time it is required.
62 - for (var id in exportsRegistry) {
63 - resetEntry(id);
64 - }
65 -
66 - return exports;
67 -};
68 -
69 -exports.getMockMap = function() {
70 - return explicitMockMap;
71 -};
72 -
73 -exports.clearMockMap = function() {
74 - explicitMockMap = {};
75 -};
76 -
77 -exports.setMockMap = function(mockMap) {
78 - exports.dumpCache();
79 - exports.clearMockMap();
80 - for (var id in mockMap) {
81 - if (mockMap[id]) {
82 - doMock(id);
83 - } else {
84 - doNotMock(id);
85 - }
86 - }
87 -
88 - return exports;
89 -};
90 -
91 -// Call this function to ensure that require(id) returns the actual
92 -// exports object created by the module.
93 -function doNotMock(id) {
94 - explicitMockMap[id] = false;
95 -
96 - var entry = exportsRegistry[id];
97 - if (entry && entry.module && entry.actual) {
98 - entry.module.exports = entry.actual;
99 - }
100 -
101 - return exports;
102 -}
103 -
104 -// Call this function to ensure that require(id) returns a mock exports
105 -// object based on the actual exports object created by the module.
106 -function doMock(id) {
107 - explicitMockMap[id] = true;
108 -
109 - var entry = exportsRegistry[id];
110 - if (entry && entry.module && entry.actual) {
111 - // Because mocking can be expensive, create the mock exports object on
112 - // demand, the first time doMock is called.
113 - entry.mocked || (entry.mocked = getMock(entry.actual));
114 - entry.module.exports = entry.mocked;
115 - }
116 -
117 - return exports;
118 -}
119 -
120 -var global = Function("return this")();
121 -require('test/mock-timers').installMockTimers(global);
122 -
123 -// Exported names are different for backwards compatibility.
124 -exports.dontMock = doNotMock;
125 -exports.mock = doMock;
src/test/mock-timers.js deleted
-219
@@ -1,219 +0,0 @@
1 -var mocks = require('mocks');
2 -
3 -var timers = {};
4 -// Keep a fake timestamp
5 -// move on the time when runTimersToTime() is called
6 -var now = 0;
7 -
8 -// add a timer of type either 'timeout' or 'interval'
9 -function _setTimer(type, callback, delay) {
10 - var token = null;
11 - do {
12 - token = Math.floor(Math.random() * 4294967296) + 1;
13 - } while (timers[token]);
14 - timers[token] = {
15 - type: type,
16 - callback: callback,
17 - // Add some random msecs to the delay to mimic code execution time.
18 - time: now + delay + Math.floor(Math.random() * 5),
19 - interval: (type == 'interval' ? delay : 0)
20 - };
21 - return token;
22 -}
23 -
24 -// clear a timer of type either 'timeout' or 'interval'
25 -function _clearTimer(type, token) {
26 - if (timers[token] && timers[token].type == type) {
27 - delete timers[token];
28 - }
29 -}
30 -
31 -function _setTimeout(callback, delay) {
32 - return _setTimer('timeout', callback, delay);
33 -}
34 -
35 -function _setInterval(callback, delay) {
36 - return _setTimer('interval', callback, delay);
37 -}
38 -
39 -function _clearTimeout(token) {
40 - _clearTimer('timeout', token);
41 -}
42 -
43 -function _clearInterval(token) {
44 - _clearTimer('interval', token);
45 -}
46 -
47 -// Run timer of given token
48 -function _runTimer(token) {
49 - // Skip non-existing token
50 - if (timers[token]) {
51 - if (timers[token].type == 'timeout') {
52 - // for 'timeout', run callback and delete the timer
53 - var callback = timers[token].callback;
54 - delete timers[token];
55 - callback();
56 - } else if (timers[token].type == 'interval') {
57 - // for 'interval', run callback and set the next invoke time
58 - // Add some random msecs to the delay to mimic code execution time.
59 - timers[token].time =
60 - now + timers[token].interval + Math.floor(Math.random() * 5);
61 - timers[token].callback();
62 - }
63 - }
64 -}
65 -
66 -function _runTimersOnce() {
67 - // Invoke all timers once regardsless of the delay
68 - for (var token in timers) {
69 - _runTimer(token);
70 - }
71 -}
72 -
73 -function _runTimersToTime(delay) {
74 - var toRunToken = _getNextTimerToken();
75 - if (!toRunToken) {
76 - return;
77 - }
78 -
79 - var minTime = timers[toRunToken].time;
80 - if (now + delay < minTime) {
81 - // Termination when there's no more timers to invoke
82 - now += delay;
83 - } else {
84 - // Recursively invoke the next to-run timer
85 - delay -= (minTime - now);
86 - now = minTime;
87 - _runTimer(toRunToken);
88 - _runTimersToTime(delay);
89 - }
90 -}
91 -
92 -function _runTimersRepeatedly() {
93 - // Only run a generous 1000 timers and then bail, since we may have entered
94 - // a loop if we have more than that.
95 - var max_timers = 1000;
96 -
97 - var token;
98 - for (var ii = 0; ii < max_timers; ii++) {
99 - token = _getNextTimerToken();
100 -
101 - if (!token) {
102 - break;
103 - }
104 -
105 - _runTimer(token);
106 - }
107 -
108 - if (ii === max_timers) {
109 - throw new Error("More timers still exist after " + max_timers + " timers!");
110 - }
111 -}
112 -
113 -function _clearTimers() {
114 - for (var token in timers) {
115 - delete timers[token];
116 - }
117 -}
118 -
119 -function _getNextTimerToken() {
120 - var nextTimerToken = null;
121 - var minTime = 31536000000; // One year
122 - // Find the next to invoke timer
123 - for (var token in timers) {
124 - if (timers[token].time < minTime) {
125 - nextTimerToken = token;
126 - minTime = timers[token].time;
127 - }
128 - }
129 - return nextTimerToken;
130 -}
131 -
132 -var mockTimers = {
133 - setTimeout: _setTimeout,
134 - clearTimeout: _clearTimeout,
135 - setInterval: _setInterval,
136 - clearInterval: _clearInterval,
137 -
138 - /**
139 - * Copyright 2013-2015, Facebook, Inc.
140 - * All rights reserved.
141 - *
142 - * This source code is licensed under the BSD-style license found in the
143 - * LICENSE file in the root directory of this source tree. An additional grant
144 - * of patent rights can be found in the PATENTS file in the same directory.
145 - *
146 - * Iteratively run callbacks in time order during the time from now to
147 - * now + delay.
148 - * If one callback register another timer which should be run during now to
149 - * now + delay, the new timer will also be run in the right order.
150 - *
151 - * @param delay
152 - */
153 - runTimersToTime: _runTimersToTime,
154 -
155 - /**
156 - * Run all registered timer once. Newly registered timers will not be run.
157 - */
158 - runTimersOnce: _runTimersOnce,
159 -
160 - /**
161 - * Iteratively run callbacks until there are no timers left to call. Will
162 - * stop after a maximum number of iterations to avoid infinite loop.
163 - *
164 - * @param maximum iterations (optional)
165 - */
166 - runTimersRepeatedly: _runTimersRepeatedly,
167 -
168 - /**
169 - * Clear all timers
170 - */
171 - clearTimers: _clearTimers,
172 -
173 - /**
174 - * Get the number of remaining timers
175 - */
176 - getTimersCount: function() {
177 - return Object.keys(timers).length;
178 - }
179 -};
180 -
181 -module.exports.installMockTimers = function(window) {
182 - window._originalTimeouts = {
183 - setTimeout: window.setTimeout,
184 - clearTimeout: window.clearTimeout,
185 - setInterval: window.setInterval,
186 - clearInterval: window.clearInterval
187 - };
188 - window.setTimeout =
189 - mocks.getMockFunction().mockImplementation(mockTimers.setTimeout);
190 - window.clearTimeout =
191 - mocks.getMockFunction().mockImplementation(mockTimers.clearTimeout);
192 - window.setInterval =
193 - mocks.getMockFunction().mockImplementation(mockTimers.setInterval);
194 - window.clearInterval =
195 - mocks.getMockFunction().mockImplementation(mockTimers.clearInterval);
196 - window.mockRunTimersOnce =
197 - mocks.getMockFunction().mockImplementation(mockTimers.runTimersOnce);
198 - window.mockRunTimersToTime =
199 - mocks.getMockFunction().mockImplementation(mockTimers.runTimersToTime);
200 - window.mockRunTimersRepeatedly =
201 - mocks.getMockFunction().mockImplementation(mockTimers.runTimersRepeatedly);
202 - window.mockClearTimers =
203 - mocks.getMockFunction().mockImplementation(mockTimers.clearTimers);
204 - window.mockGetTimersCount =
205 - mocks.getMockFunction().mockImplementation(mockTimers.getTimersCount);
206 -};
207 -
208 -module.exports.uninstallMockTimers = function(window) {
209 - window.setTimeout = window._originalTimeouts.setTimeout;
210 - window.clearTimeout = window._originalTimeouts.clearTimeout;
211 - window.setInterval = window._originalTimeouts.setInterval;
212 - window.clearInterval = window._originalTimeouts.clearInterval;
213 - window._originalTimeouts = undefined;
214 - window.mockRunTimersOnce = undefined;
215 - window.mockRunTimersToTime = undefined;
216 - window.mockRunTimersRepeatedly = undefined;
217 - window.mockClearTimers = undefined;
218 - window.mockGetTimersCount = undefined;
219 -};
src/test/mocks.js deleted
-425
@@ -1,425 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule mocks
10 - */
11 -
12 -function isA(typeName, value) {
13 - return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
14 -}
15 -
16 -function getType(ref) {
17 - if (isA('RegExp', ref)) {
18 - return 'regexp';
19 - }
20 -
21 - if (isA('Array', ref)) {
22 - return 'array';
23 - }
24 -
25 - if (isA('Function', ref)) {
26 - return 'function';
27 - }
28 -
29 - if (isA('Object', ref)) {
30 - return 'object';
31 - }
32 -
33 - // consider number and string fields to be constants that we want to
34 - // pick up as they are
35 - if (isA('Number', ref) || isA('String', ref)) {
36 - return 'constant';
37 - }
38 -
39 - return null;
40 -}
41 -
42 -function makeComponent(metadata) {
43 - switch (metadata.type) {
44 - case 'object':
45 - return {};
46 -
47 - case 'array':
48 - return [];
49 -
50 - case 'regexp':
51 - return new RegExp();
52 -
53 - case 'constant':
54 - return metadata.value;
55 -
56 - case 'function':
57 - var defaultReturnValue;
58 - var specificReturnValues = [];
59 - var mockImpl;
60 - var isReturnValueLastSet = false;
61 - var calls = [];
62 - var instances = [];
63 - var prototype =
64 - (metadata.members && metadata.members.prototype &&
65 - metadata.members.prototype.members) || {};
66 -
67 - var f = function() {
68 - global.dirtyMocks.push(f);
69 -
70 - instances.push(this);
71 - calls.push(Array.prototype.slice.call(arguments));
72 - if (this instanceof f) {
73 - // This is probably being called as a constructor
74 - for (var slot in prototype) {
75 - // Copy prototype methods to the instance to make
76 - // it easier to interact with mock instance call and
77 - // return values
78 - if (prototype[slot].type == 'function') {
79 - var protoImpl = this[slot];
80 - this[slot] = generateFromMetadata(prototype[slot]);
81 - this[slot]._protoImpl = protoImpl;
82 - }
83 - }
84 -
85 - // Run the mock constructor implementation
86 - mockImpl && mockImpl.apply(this, arguments);
87 - return;
88 - }
89 -
90 - var returnValue;
91 - // If return value is last set, either specific or default, i.e.
92 - // mockReturnValueOnce()/mockReturnValue() is called and no
93 - // mockImplementation() is called after that.
94 - // use the set return value.
95 - if (isReturnValueLastSet) {
96 - returnValue = specificReturnValues.shift();
97 - if (returnValue === undefined) {
98 - returnValue = defaultReturnValue;
99 - }
100 - }
101 -
102 - // If mockImplementation() is last set, or specific return values
103 - // are used up, use the mock implementation.
104 - if (mockImpl && returnValue === undefined) {
105 - return mockImpl.apply(this, arguments);
106 - }
107 -
108 - // Otherwise use prototype implementation
109 - if (returnValue === undefined && f._protoImpl) {
110 - return f._protoImpl.apply(this, arguments);
111 - }
112 -
113 - return returnValue;
114 - };
115 -
116 - f._isMockFunction = true;
117 -
118 - f.mock = {
119 - calls: calls,
120 - instances: instances
121 - };
122 -
123 - f.mockClear = function() {
124 - calls.length = 0;
125 - instances.length = 0;
126 - };
127 -
128 - f.mockReturnValueOnce = function(value) {
129 - // next function call will return this value or default return value
130 - isReturnValueLastSet = true;
131 - specificReturnValues.push(value);
132 - return f;
133 - };
134 -
135 - f.mockReturnValue = function(value) {
136 - // next function call will return specified return value or this one
137 - isReturnValueLastSet = true;
138 - defaultReturnValue = value;
139 - return f;
140 - };
141 -
142 - f.mockImplementation = function(fn) {
143 - // next function call will use mock implementation return value
144 - isReturnValueLastSet = false;
145 - mockImpl = fn;
146 - return f;
147 - };
148 -
149 - f.mockReturnThis = function() {
150 - return f.mockImplementation(function() {
151 - return this;
152 - });
153 - };
154 -
155 - f._getMockImplementation = function() {
156 - return mockImpl;
157 - };
158 -
159 - if (metadata.mockImpl) {
160 - f.mockImplementation(metadata.mockImpl);
161 - }
162 -
163 - return f;
164 - }
165 -
166 - throw new Error('Unrecognized type ' + metadata.type);
167 -}
168 -
169 -function generateFromMetadata(_metadata) {
170 - var callbacks = [];
171 - var refs = {};
172 -
173 - function generateMock(metadata) {
174 - var mock = makeComponent(metadata);
175 - if (metadata.ref_id != null) {
176 - refs[metadata.ref_id] = mock;
177 - }
178 -
179 - function getRefCallback(slot, ref) {
180 - return function() {
181 - mock[slot] = refs[ref];
182 - };
183 - }
184 -
185 - for (var slot in metadata.members) {
186 - var slotMetadata = metadata.members[slot];
187 - if (slotMetadata.ref != null) {
188 - callbacks.push(getRefCallback(slot, slotMetadata.ref));
189 - } else {
190 - mock[slot] = generateMock(slotMetadata);
191 - }
192 - }
193 -
194 - return mock;
195 - }
196 -
197 - var mock = generateMock(_metadata);
198 - callbacks.forEach(function(setter) {
199 - setter();
200 - });
201 -
202 - return mock;
203 -}
204 -
205 -
206 -function _getMetadata(component, _refs) {
207 - var refs = _refs || [];
208 -
209 - // This is a potential performance drain, since the whole list is scanned
210 - // for every component
211 - var ref = refs.indexOf(component);
212 - if (ref > -1) {
213 - return {ref: ref};
214 - }
215 -
216 - var type = getType(component);
217 - if (!type) {
218 - return null;
219 - }
220 -
221 - var metadata = {type: type};
222 - if (type == 'constant') {
223 - metadata.value = component;
224 - return metadata;
225 - } else if (type == 'function') {
226 - if (component._isMockFunction) {
227 - metadata.mockImpl = component._getMockImplementation();
228 - }
229 - }
230 -
231 - metadata.ref_id = refs.length;
232 - refs.push(component);
233 -
234 - var members = null;
235 -
236 - function addMember(slot, data) {
237 - if (!data) {
238 - return;
239 - }
240 - if (!members) {
241 - members = {};
242 - }
243 - members[slot] = data;
244 - }
245 -
246 - // Leave arrays alone
247 - if (type != 'array') {
248 - for (var slot in component) {
249 - if (slot.charAt(0) == '_' ||
250 - (type == 'function' && component._isMockFunction &&
251 - slot.match(/^mock/))) {
252 - continue;
253 - }
254 -
255 - if (component.hasOwnProperty(slot) ||
256 - (type == 'object' && component[slot] != Object.prototype[slot])) {
257 - addMember(slot, _getMetadata(component[slot], refs));
258 - }
259 - }
260 -
261 - // If component is native code function, prototype might be undefined
262 - if (type == 'function' && component.prototype) {
263 - var prototype = _getMetadata(component.prototype, refs);
264 - if (prototype && prototype.members) {
265 - addMember('prototype', prototype);
266 - }
267 - }
268 - }
269 -
270 - if (members) {
271 - metadata.members = members;
272 - }
273 -
274 - return metadata;
275 -}
276 -
277 -function removeUnusedRefs(metadata) {
278 - function visit(md, f) {
279 - f(md);
280 - if (md.members) {
281 - for (var slot in md.members) {
282 - visit(md.members[slot], f);
283 - }
284 - }
285 - }
286 -
287 - var usedRefs = {};
288 - visit(metadata, function(md) {
289 - if (md.ref != null) {
290 - usedRefs[md.ref] = true;
291 - }
292 - });
293 -
294 - visit(metadata, function(md) {
295 - if (!usedRefs[md.ref_id]) {
296 - delete md.ref_id;
297 - }
298 - });
299 -}
300 -
301 -var global = Function("return this")();
302 -global.dirtyMocks = global.dirtyMocks || [];
303 -
304 -module.exports = {
305 - /**
306 - * Invokes the .mockClear method of all function mocks that have been
307 - * called since the last time clear was called.
308 - */
309 - clear: function() {
310 - var old = global.dirtyMocks;
311 - global.dirtyMocks = [];
312 - old.forEach(function(mock) {
313 - mock.mockClear();
314 - });
315 - },
316 -
317 - /**
318 - * Generates a mock based on the given metadata. Mocks treat functions
319 - * specially, and all mock functions have additional members, described in the
320 - * documentation for getMockFunction in this module.
321 - *
322 - * One important note: function prototoypes are handled specially by this
323 - * mocking framework. For functions with prototypes, when called as a
324 - * constructor, the mock will install mocked function members on the instance.
325 - * This allows different instances of the same constructor to have different
326 - * values for its mocks member and its return values.
327 - *
328 - * @param metadata Metadata for the mock in the schema returned by the
329 - * getMetadata method of this module.
330 - *
331 - */
332 - generateFromMetadata: generateFromMetadata,
333 -
334 - /**
335 - * Inspects the argument and returns its schema in the following recursive
336 - * format:
337 - * {
338 - * type: ...
339 - * members : {}
340 - * }
341 - *
342 - * Where type is one of 'array', 'object', 'function', or 'ref', and members
343 - * is an optional dictionary where the keys are member names and the values
344 - * are metadata objects. Function prototypes are defined simply by defining
345 - * metadata for the member.prototype of the function. The type of a function
346 - * prototype should always be "object". For instance, a simple class might be
347 - * defined like this:
348 - *
349 - * {
350 - * type: 'function',
351 - * members: {
352 - * staticMethod: {type: 'function'},
353 - * prototype: {
354 - * type: 'object',
355 - * members: {
356 - * instanceMethod: {type: 'function'}
357 - * }
358 - * }
359 - * }
360 - * }
361 - *
362 - * Metadata may also contain references to other objects defined within the
363 - * same metadata object. The metadata for the referent must be marked with
364 - * 'ref_id' key and an arbitrary value. The referer must be marked with a
365 - * 'ref' key that has the same value as object with ref_id that it refers to.
366 - * For instance, this metadata blob:
367 - * {
368 - * type: 'object',
369 - * ref_id: 1,
370 - * members: {
371 - * self: {ref: 1}
372 - * }
373 - * }
374 - *
375 - * defines an object with a slot named 'self' that refers back to the object.
376 - *
377 - * @param {*} component The component for which to retrieve metadata.
378 - */
379 - getMetadata: function(component) {
380 - var metadata = _getMetadata(component);
381 - // to make it easier to work with mock metadata, only preserve references
382 - // that are actually used
383 - removeUnusedRefs(metadata);
384 - return metadata;
385 - },
386 -
387 - /**
388 - * Generates a stand-alone function with members that help drive unit tests or
389 - * confirm expectations. Specifically, functions returned by this method have
390 - * the following members:
391 - *
392 - * .mock:
393 - * An object with two members, "calls", and "instances", which are both
394 - * lists. The items in the "calls" list are the arguments with which the
395 - * function was called. The "instances" list stores the value of 'this' for
396 - * each call to the function. This is useful for retrieving instances from a
397 - * constructor.
398 - *
399 - * .mockReturnValueOnce(value)
400 - * Pushes the given value onto a FIFO queue of return values for the
401 - * function.
402 - *
403 - * .mockReturnValue(value)
404 - * Sets the default return value for the function.
405 - *
406 - * .mockImplementation(function)
407 - * Sets a mock implementation for the function.
408 - *
409 - * .mockReturnThis()
410 - * Syntactic sugar for .mockImplementation(function() {return this;})
411 - *
412 - * In case both mockImplementation() and
413 - * mockReturnValueOnce()/mockReturnValue() are called. The priority of
414 - * which to use is based on what is the last call:
415 - * - if the last call is mockReturnValueOnce() or mockReturnValue(),
416 - * use the specific return specific return value or default return value.
417 - * If specific return values are used up or no default return value is set,
418 - * fall back to try mockImplementation();
419 - * - if the last call is mockImplementation(), run the given implementation
420 - * and return the result.
421 - */
422 - getMockFunction: function() {
423 - return makeComponent({type: 'function'});
424 - }
425 -};
src/test/phantomjs-shims.js deleted
-35
@@ -1,35 +0,0 @@
1 -(function() {
2 -
3 -var Ap = Array.prototype;
4 -var slice = Ap.slice;
5 -var Fp = Function.prototype;
6 -
7 -if (!Fp.bind) {
8 - // PhantomJS doesn't support Function.prototype.bind natively, so
9 - // polyfill it whenever this module is required.
10 - Fp.bind = function(context) {
11 - var func = this;
12 - var args = slice.call(arguments, 1);
13 -
14 - function bound() {
15 - var invokedAsConstructor = func.prototype && (this instanceof func);
16 - return func.apply(
17 - // Ignore the context parameter when invoking the bound function
18 - // as a constructor. Note that this includes not only constructor
19 - // invocations using the new keyword but also calls to base class
20 - // constructors such as BaseClass.call(this, ...) or super(...).
21 - !invokedAsConstructor && context || this,
22 - args.concat(slice.call(arguments))
23 - );
24 - }
25 -
26 - // The bound function must share the .prototype of the unbound
27 - // function so that any object created by one constructor will count
28 - // as an instance of both constructors.
29 - bound.prototype = func.prototype;
30 -
31 - return bound;
32 - };
33 -}
34 -
35 -})();
test/.eslintrc deleted
-8
@@ -1,8 +0,0 @@
1 -globals:
2 - harness: true
3 -
4 -rules:
5 - strict: false
6 - no-undef: false
7 - no-unused-vars: false
8 - block-scoped-var: false
\ No newline at end of file
test/index.html deleted
-38
@@ -1,38 +0,0 @@
1 -<!doctype html>
2 -<meta charset=utf-8>
3 -<body>
4 -<script>
5 -;(function(){
6 -
7 - var urls = [
8 - '../src/shared/vendor/third_party/webcomponents.js',
9 - '../vendor/jasmine/jasmine.js',
10 - '../vendor/jasmine/jasmine-support.js',
11 - '../vendor/jasmine/jasmine-html.js',
12 - '../node_modules/jasmine-tapreporter/src/tapreporter.js',
13 - '../vendor/jasmine-jsreporter/jasmine-jsreporter.js',
14 -
15 - 'lib/postDataToURL.browser.js',
16 - 'lib/reportTestResults.browser.js',
17 - 'lib/jasmine-execute.js',
18 -
19 - '../build/react.js',
20 - '../build/react-test.js',
21 - 'the-files-to-test.generated.js'
22 - ];
23 -
24 - if (typeof Function.prototype.bind == 'undefined') {
25 - urls.unshift('../node_modules/es5-shim/es5-sham.js');
26 - urls.unshift('../node_modules/es5-shim/es5-shim.js');
27 - }
28 -
29 - var cacheBust = '?_=' + (+new Date).toString(36);
30 -
31 - for (var urls_index = -1, urls_length = urls.length; ++urls_index < urls_length;) {
32 - document.write('<script src="' + urls[urls_index] + cacheBust + '"><\/script>');
33 - }
34 -
35 - var base = location.protocol + '//' + location.hostname + ':' + location.port + location.pathname.replace(/^\/?/,'/').split('/').reverse().slice(1).reverse().join('/');
36 -
37 -}());
38 -</script>
test/lib/jasmine-execute.js deleted
-47
@@ -1,47 +0,0 @@
1 -document.write('<style> @import \'../vendor/jasmine/jasmine.css?_=' + (+new Date()).toString(36) + '\'; </style>');
2 -
3 -(function(env) {
4 - var htmlReporter = new jasmine.HtmlReporter();
5 - env.addReporter(htmlReporter);
6 - env.specFilter = function(spec) {
7 - return htmlReporter.specFilter(spec);
8 - };
9 -
10 - // Clean up any nodes the previous test might have added.
11 - env.afterEach(function() {
12 - harness.removeNextSiblings(document.body);
13 - harness.removeNextSiblings(document.getElementById('HTMLReporter'));
14 - });
15 -
16 - window.onload = function() {
17 - env.execute();
18 - };
19 -
20 - var oldError = console.error;
21 - var newError = function() {
22 - oldError.apply(this, arguments);
23 - var spec = env.currentSpec;
24 - if (spec) {
25 - var expectationResult = new jasmine.ExpectationResult({
26 - passed: false,
27 - message:
28 - 'Expected test not to warn. If the warning is expected, mock it ' +
29 - 'out using spyOn(console, \'error\'); and test that the warning ' +
30 - 'occurs.',
31 - });
32 - spec.addMatcherResult(expectationResult);
33 - }
34 - };
35 - console.error = newError;
36 - // Make sure console.error is set back at the end of each test, or else the
37 - // above logic won't work
38 - env.afterEach(function() {
39 - if (console.error !== newError && !console.error.isSpy) {
40 - var expectationResult = new jasmine.ExpectationResult({
41 - passed: false,
42 - message: 'Test did not tear down console.error mock properly.',
43 - });
44 - env.currentSpec.addMatcherResult(expectationResult);
45 - }
46 - });
47 -})(jasmine.getEnv());
test/lib/postDataToURL.browser.js deleted
-48
@@ -1,48 +0,0 @@
1 -/*eslint-disable brace-style*/
2 -function createXMLHttpRequest() {
3 - try {
4 - return new XMLHttpRequest();
5 - }
6 - catch(e) {}
7 - try {
8 - return new ActiveXObject('Msxml2.XMLHTTP');
9 - }
10 - catch (e) {}
11 - try {
12 - return new ActiveXObject('Microsoft.XMLHTTP');
13 - }
14 - catch (e) {}
15 -}
16 -/*eslint-enable brace-style*/
17 -
18 -function getURLSync(url) {
19 - var request = createXMLHttpRequest();
20 - request.open('GET', url, /*asynchronous?*/false);
21 - return request.responseText;
22 -}
23 -
24 -function postDataToURL(data, url, callback) {
25 - if (!callback) {
26 - callback = postDataToURL.defaultCallback;
27 - }
28 - var request = createXMLHttpRequest();
29 - if (!request) {
30 - return callback(Error('XMLHttpRequest is unsupported'));
31 - }
32 - postDataToURL.running = (postDataToURL.running || 0) + 1;
33 - request.onreadystatechange = function() {
34 - if (request.readyState !== 4) {
35 - return;
36 - }
37 - request.onreadystatechange = null;
38 - postDataToURL.running = (postDataToURL.running || 0) - 1;
39 - callback(request.status === 200 ? null : request.status, request.responseText);
40 - };
41 - request.open('POST', url);
42 - request.setRequestHeader('Content-Type', 'application/json');
43 - request.send(JSON.stringify(data));
44 -}
45 -
46 -postDataToURL.defaultCallback = function(error) {
47 - // console.log('postDataToURL.defaultCallback', arguments)
48 -};
test/lib/reportTestResults.browser.js deleted
-60
@@ -1,60 +0,0 @@
1 -var __DEBUG__ = location.search.substring(1).indexOf('debug') !== -1;
2 -
3 -if (typeof console === 'undefined') {
4 - console = {
5 - log: function() {},
6 - warn: function() {},
7 - error: function() {},
8 - };
9 -}
10 -
11 -var __consoleReport__ = [];
12 -
13 -console._log = console.log;
14 -console.log = function(message) {
15 - console._log(message);
16 - if (__DEBUG__) {
17 - postDataToURL({type:'log', message:message}, '/reportTestResults');
18 - } else {
19 - __consoleReport__.push({type:'log', message:message});
20 - }
21 -};
22 -
23 -console._error = console.error;
24 -console.error = function(message) {
25 - console._error(message);
26 - if (__DEBUG__) {
27 - postDataToURL({type:'error', message:message}, '/reportTestResults');
28 - } else {
29 - __consoleReport__.push({type:'error', message:message});
30 - }
31 -};
32 -
33 -console._flush = function() {
34 - postDataToURL(__consoleReport__, '/console');
35 - __consoleReport__.length = 0;
36 -};
37 -
38 -(function(env) {
39 - env.addReporter(new jasmine.JSReporter());
40 - env.addReporter(new TAPReporter(console.log.bind(console)));
41 -
42 - function report() {
43 - if (typeof jasmine.getJSReport !== 'function') {
44 - return setTimeout(report, 100);
45 - }
46 - if (!__DEBUG__) {
47 - console.log('DONE\t' + navigator.userAgent);
48 - console._flush();
49 - }
50 - }
51 -
52 - var oldCallback = env.currentRunner().finishCallback;
53 - env.currentRunner().finishCallback = function() {
54 - if (oldCallback) {
55 - oldCallback.apply(this, arguments);
56 - }
57 - report();
58 - };
59 -
60 -}(window.jasmine.getEnv()));
vendor/jasmine-jsreporter/jasmine-jsreporter.js deleted
-162
@@ -1,162 +0,0 @@
1 -/*
2 - This file is part of the Jasmine JSReporter project from Ivan De Marino.
3 -
4 - Copyright (C) 2011 Ivan De Marino (aka detro, aka detronizator), http://blog.ivandemarino.me, ivan.de.marino@gmail.com
5 -
6 - Redistribution and use in source and binary forms, with or without
7 - modification, are permitted provided that the following conditions are met:
8 -
9 - * Redistributions of source code must retain the above copyright
10 - notice, this list of conditions and the following disclaimer.
11 - * Redistributions in binary form must reproduce the above copyright
12 - notice, this list of conditions and the following disclaimer in the
13 - documentation and/or other materials provided with the distribution.
14 - * Neither the name of the <organization> nor the
15 - names of its contributors may be used to endorse or promote products
16 - derived from this software without specific prior written permission.
17 -
18 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 - ARE DISCLAIMED. IN NO EVENT SHALL IVAN DE MARINO BE LIABLE FOR ANY
22 - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 -*/
29 -
30 -(function () {
31 - // Ensure that Jasmine library is loaded first
32 - if (typeof jasmine === "undefined") {
33 - throw new Error("[Jasmine JSReporter] 'Jasmine' library not found");
34 - }
35 -
36 - /**
37 - * Calculate elapsed time, in Seconds.
38 - * @param startMs Start time in Milliseconds
39 - * @param finishMs Finish time in Milliseconds
40 - * @return Elapsed time in Seconds */
41 - function elapsedSec (startMs, finishMs) {
42 - return (finishMs - startMs) / 1000;
43 - }
44 -
45 - /**
46 - * Round an amount to the given number of Digits.
47 - * If no number of digits is given, than '2' is assumed.
48 - * @param amount Amount to round
49 - * @param numOfDecDigits Number of Digits to round to. Default value is '2'.
50 - * @return Rounded amount */
51 - function round (amount, numOfDecDigits) {
52 - numOfDecDigits = numOfDecDigits || 2;
53 - return Math.round(amount * Math.pow(10, numOfDecDigits)) / Math.pow(10, numOfDecDigits);
54 - }
55 -
56 - /**
57 - * Collect information about a Suite, recursively, and return a JSON result.
58 - * @param suite The Jasmine Suite to get data from
59 - */
60 - function getSuiteData (suite) {
61 - var suiteData = {
62 - description : suite.description,
63 - durationSec : 0,
64 - specs: [],
65 - suites: [],
66 - passed: true
67 - },
68 - specs = suite.specs(),
69 - suites = suite.suites(),
70 - i, ilen;
71 -
72 - // Loop over all the Suite's Specs
73 - for (i = 0, ilen = specs.length; i < ilen; ++i) {
74 - suiteData.specs[i] = {
75 - description : specs[i].description,
76 - durationSec : specs[i].durationSec,
77 - passed : specs[i].results().passedCount === specs[i].results().totalCount,
78 - skipped : specs[i].results().skipped,
79 - passedCount : specs[i].results().passedCount,
80 - failedCount : specs[i].results().failedCount,
81 - totalCount : specs[i].results().totalCount
82 - };
83 - suiteData.passed = !suiteData.specs[i].passed ? false : suiteData.passed;
84 - suiteData.durationSec += suiteData.specs[i].durationSec;
85 - }
86 -
87 - // Loop over all the Suite's sub-Suites
88 - for (i = 0, ilen = suites.length; i < ilen; ++i) {
89 - suiteData.suites[i] = getSuiteData(suites[i]); //< recursive population
90 - suiteData.passed = !suiteData.suites[i].passed ? false : suiteData.passed;
91 - suiteData.durationSec += suiteData.suites[i].durationSec;
92 - }
93 -
94 - // Rounding duration numbers to 3 decimal digits
95 - suiteData.durationSec = round(suiteData.durationSec, 4);
96 -
97 - return suiteData;
98 - }
99 -
100 - var JSReporter = function () {
101 - };
102 -
103 - JSReporter.prototype = {
104 - reportRunnerStarting: function (runner) {
105 - // Nothing to do
106 - },
107 -
108 - reportSpecStarting: function (spec) {
109 - // Start timing this spec
110 - spec.startedAt = new Date();
111 - },
112 -
113 - reportSpecResults: function (spec) {
114 - // Finish timing this spec and calculate duration/delta (in sec)
115 - spec.finishedAt = new Date();
116 - // If the spec was skipped, reportSpecStarting is never called and spec.startedAt is undefined
117 - spec.durationSec = spec.startedAt ? elapsedSec(spec.startedAt.getTime(), spec.finishedAt.getTime()) : 0;
118 - },
119 -
120 - reportSuiteResults: function (suite) {
121 - // Nothing to do
122 - },
123 -
124 - reportRunnerResults: function (runner) {
125 - var suites = runner.suites(),
126 - i, ilen;
127 -
128 - // Attach results to the "jasmine" object to make those results easy to scrap/find
129 - jasmine.runnerResults = {
130 - suites: [],
131 - durationSec : 0,
132 - passed : true
133 - };
134 -
135 - // Loop over all the Suites
136 - for (i = 0, ilen = suites.length; i < ilen; ++i) {
137 - if (suites[i].parentSuite === null) {
138 - jasmine.runnerResults.suites[i] = getSuiteData(suites[i]);
139 - // If 1 suite fails, the whole runner fails
140 - jasmine.runnerResults.passed = !jasmine.runnerResults.suites[i].passed ? false : jasmine.runnerResults.passed;
141 - // Add up all the durations
142 - jasmine.runnerResults.durationSec += jasmine.runnerResults.suites[i].durationSec;
143 - }
144 - }
145 -
146 - // Decorate the 'jasmine' object with getters
147 - jasmine.getJSReport = function () {
148 - if (jasmine.runnerResults) {
149 - return jasmine.runnerResults;
150 - }
151 - return null;
152 - };
153 - jasmine.getJSReportAsString = function () {
154 - return JSON.stringify(jasmine.getJSReport());
155 - };
156 - }
157 - };
158 -
159 - // export public
160 - jasmine.JSReporter = JSReporter;
161 -})();
162 -
vendor/jasmine/HtmlReporter.js deleted
-168
@@ -1,168 +0,0 @@
1 -var jasmine = require("./jasmine");
2 -
3 -exports.HtmlReporter =
4 -jasmine.HtmlReporter = function(_doc) {
5 - var self = this;
6 - var doc = _doc || window.document;
7 -
8 - var reporterView;
9 -
10 - var dom = {};
11 -
12 - // Jasmine Reporter Public Interface
13 - self.logRunningSpecs = false;
14 -
15 - self.reportRunnerStarting = function(runner) {
16 - var specs = runner.specs() || [];
17 -
18 - if (specs.length == 0) {
19 - return;
20 - }
21 -
22 - createReporterDom(runner.env.versionString());
23 - doc.body.appendChild(dom.reporter);
24 - setExceptionHandling();
25 -
26 - reporterView = new jasmine.HtmlReporter.ReporterView(dom);
27 - reporterView.addSpecs(specs, self.specFilter);
28 - };
29 -
30 - self.reportRunnerResults = function(runner) {
31 - reporterView && reporterView.complete();
32 - };
33 -
34 - self.reportSuiteResults = function(suite) {
35 - reporterView.suiteComplete(suite);
36 - };
37 -
38 - self.reportSpecStarting = function(spec) {
39 - if (self.logRunningSpecs) {
40 - self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
41 - }
42 - };
43 -
44 - self.reportSpecResults = function(spec) {
45 - reporterView.specComplete(spec);
46 - };
47 -
48 - self.log = function() {
49 - var console = jasmine.getGlobal().console;
50 - if (console && console.log) {
51 - if (console.log.apply) {
52 - console.log.apply(console, arguments);
53 - } else {
54 - console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
55 - }
56 - }
57 - };
58 -
59 - self.specFilter = function(spec) {
60 - if (!focusedSpecName()) {
61 - return true;
62 - }
63 -
64 - return spec.getFullName().indexOf(focusedSpecName()) === 0;
65 - };
66 -
67 - return self;
68 -
69 - function focusedSpecName() {
70 - var specName;
71 -
72 - (function memoizeFocusedSpec() {
73 - if (specName) {
74 - return;
75 - }
76 -
77 - var paramMap = [];
78 - var params = jasmine.HtmlReporter.parameters(doc);
79 -
80 - for (var i = 0; i < params.length; i++) {
81 - var p = params[i].split('=');
82 - paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
83 - }
84 -
85 - specName = paramMap.spec;
86 - })();
87 -
88 - return specName;
89 - }
90 -
91 - function createReporterDom(version) {
92 - dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
93 - dom.banner = self.createDom('div', { className: 'banner' },
94 - self.createDom('span', { className: 'title' }, "Jasmine "),
95 - self.createDom('span', { className: 'version' }, version)),
96 -
97 - dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
98 - dom.alert = self.createDom('div', {className: 'alert'},
99 - self.createDom('span', { className: 'exceptions' },
100 - self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
101 - self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
102 - dom.results = self.createDom('div', {className: 'results'},
103 - dom.summary = self.createDom('div', { className: 'summary' }),
104 - dom.details = self.createDom('div', { id: 'details' }))
105 - );
106 - }
107 -
108 - function noTryCatch() {
109 - return window.location.search.match(/catch=false/);
110 - }
111 -
112 - function searchWithCatch() {
113 - var params = jasmine.HtmlReporter.parameters(window.document);
114 - var removed = false;
115 - var i = 0;
116 -
117 - while (!removed && i < params.length) {
118 - if (params[i].match(/catch=/)) {
119 - params.splice(i, 1);
120 - removed = true;
121 - }
122 - i++;
123 - }
124 - if (jasmine.CATCH_EXCEPTIONS) {
125 - params.push("catch=false");
126 - }
127 -
128 - return params.join("&");
129 - }
130 -
131 - function setExceptionHandling() {
132 - var chxCatch = document.getElementById('no_try_catch');
133 -
134 - if (noTryCatch()) {
135 - chxCatch.setAttribute('checked', true);
136 - jasmine.CATCH_EXCEPTIONS = false;
137 - }
138 - chxCatch.onclick = function() {
139 - window.location.search = searchWithCatch();
140 - };
141 - }
142 -};
143 -jasmine.HtmlReporter.parameters = function(doc) {
144 - var paramStr = doc.location.search.substring(1);
145 - var params = [];
146 -
147 - if (paramStr.length > 0) {
148 - params = paramStr.split('&');
149 - }
150 - return params;
151 -}
152 -jasmine.HtmlReporter.sectionLink = function(sectionName) {
153 - var link = '?';
154 - var params = [];
155 -
156 - if (sectionName) {
157 - params.push('spec=' + encodeURIComponent(sectionName));
158 - }
159 - if (!jasmine.CATCH_EXCEPTIONS) {
160 - params.push("catch=false");
161 - }
162 - if (params.length > 0) {
163 - link += params.join("&");
164 - }
165 -
166 - return link;
167 -};
168 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
vendor/jasmine/PrintReporter.js deleted
-128
@@ -1,128 +0,0 @@
1 -var jasmine = require("./jasmine");
2 -var diff = require('./diff');
3 -
4 -var red = '\u001b[1;41m';
5 -var reset = '\u001b[0m';
6 -
7 -function highlightDifferences(a, b) {
8 - var changes = diff.diffChars(a, b);
9 -
10 - var ret = {a: '', b: ''};
11 - var change;
12 - for (var i = 0, il = changes.length; i < il; i++) {
13 - change = changes[i];
14 - if (change.added) {
15 - ret.b += red + change.value + reset;
16 - } else if (change.removed) {
17 - ret.a += red + change.value + reset;
18 - } else {
19 - ret.a += change.value;
20 - ret.b += change.value;
21 - }
22 - }
23 - return ret;
24 -}
25 -
26 -function PrintReporter(name, root_directory) {
27 - this.skipCount = 0;
28 - this.failCount = 0;
29 - this.expectCount = 0;
30 - this.specCount = 0;
31 - this.name = name;
32 - this.rootDirectory = root_directory;
33 -}
34 -exports.PrintReporter =
35 -jasmine.PrintReporter = PrintReporter;
36 -
37 -PrintReporter.prototype = new jasmine.Reporter();
38 -// Set verbose=true on the test instance to enable additional logging
39 -PrintReporter.prototype.verbose = false;
40 -PrintReporter.prototype._didSpecName = false;
41 -
42 -PrintReporter.prototype.reportSpecStarting = function(spec) {
43 - this._didSpecName = false;
44 - this._spec = spec;
45 -};
46 -
47 -PrintReporter.prototype.reportRunnerResults = function(runner) {
48 - // Don't print out the spec name at the end
49 - this._didSpecName = true;
50 -
51 - this.log([
52 - this.specCount + " spec",
53 - this.expectCount + " expect",
54 - this.skipCount + " skip",
55 - this.failCount + " fail"
56 - ].join(" "));
57 -
58 - require("./phantom").exit(this.failCount);
59 -};
60 -
61 -
62 -PrintReporter.prototype.reportSuiteResults = function(suite) {
63 - var results = suite.results();
64 - if (this.verbose) {
65 - this.log('Suite "' + suite.description + '": ' +
66 - results.passedCount + '/' + results.totalCount + ' passed.');
67 - }
68 -
69 - // If suite is nested, only count the root suite
70 - if (!suite.parentSuite) {
71 - this.failCount += results.totalCount - results.passedCount;
72 - this.expectCount += results.totalCount;
73 - }
74 -};
75 -
76 -PrintReporter.prototype.reportSpecResults = function(spec) {
77 - if (this.verbose) {
78 - this.log('it... ' +
79 - spec.description + ': ' + (spec.results().passed() ? 'pass' : 'fail'));
80 - }
81 -
82 - var self = this;
83 - var results = spec.results();
84 -
85 - this.specCount += 1;
86 -
87 - if (results.skipped)
88 - this.skipCount += 1;
89 -
90 - results.getItems().forEach(function(result) {
91 - if (result.type == 'log') {
92 - self.log(result.toString());
93 - } else if (result.type == 'expect' && result.passed && !result.passed()) {
94 - var ppActual = jasmine.pp(result.actual);
95 - var ppExpected = jasmine.pp(result.expected);
96 -
97 - var colorDiff = highlightDifferences(ppActual, ppExpected);
98 -
99 - var message = result.message;
100 - message = message.replace(ppActual, colorDiff.a);
101 - message = message.replace(ppExpected, colorDiff.b);
102 -
103 - self.log(message);
104 - if (result.trace.stack) {
105 - self.log();
106 - result.trace.stack.split('\n').forEach(function(stackFrame) {
107 - if (stackFrame.indexOf('/jasmine/lib/jasmine-core') > -1) {
108 - return;
109 - }
110 - if (this.rootDirectory) {
111 - stackFrame = stackFrame.replace(this.rootDirectory + '/', '');
112 - }
113 - self.log(' ' + stackFrame);
114 - }.bind(this));
115 - }
116 - }
117 - });
118 -};
119 -
120 -PrintReporter.prototype.log = function(str) {
121 - if (!this._didSpecName) {
122 - console.log('');
123 - console.log(
124 - this._spec.suite.description + ': it ' + this._spec.description);
125 - this._didSpecName = true;
126 - }
127 - console.log(str || '');
128 -};
vendor/jasmine/ReporterView.js deleted
-166
@@ -1,166 +0,0 @@
1 -var jasmine = require("jasmine");
2 -
3 -jasmine.HtmlReporter.ReporterView = function(dom) {
4 - this.startedAt = new Date();
5 - this.runningSpecCount = 0;
6 - this.completeSpecCount = 0;
7 - this.passedCount = 0;
8 - this.failedCount = 0;
9 - this.skippedCount = 0;
10 -
11 - this.createResultsMenu = function() {
12 - this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
13 - this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
14 - ' | ',
15 - this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
16 -
17 - this.summaryMenuItem.onclick = function() {
18 - dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
19 - };
20 -
21 - this.detailsMenuItem.onclick = function() {
22 - showDetails();
23 - };
24 - };
25 -
26 - this.addSpecs = function(specs, specFilter) {
27 - this.totalSpecCount = specs.length;
28 -
29 - this.views = {
30 - specs: {},
31 - suites: {}
32 - };
33 -
34 - for (var i = 0; i < specs.length; i++) {
35 - var spec = specs[i];
36 - this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
37 - if (specFilter(spec)) {
38 - this.runningSpecCount++;
39 - }
40 - }
41 - };
42 -
43 - this.specComplete = function(spec) {
44 - this.completeSpecCount++;
45 -
46 - if (isUndefined(this.views.specs[spec.id])) {
47 - this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
48 - }
49 -
50 - var specView = this.views.specs[spec.id];
51 -
52 - switch (specView.status()) {
53 - case 'passed':
54 - this.passedCount++;
55 - break;
56 -
57 - case 'failed':
58 - this.failedCount++;
59 - break;
60 -
61 - case 'skipped':
62 - this.skippedCount++;
63 - break;
64 - }
65 -
66 - specView.refresh();
67 - this.refresh();
68 - };
69 -
70 - this.suiteComplete = function(suite) {
71 - var suiteView = this.views.suites[suite.id];
72 - if (isUndefined(suiteView)) {
73 - return;
74 - }
75 - suiteView.refresh();
76 - };
77 -
78 - this.refresh = function() {
79 -
80 - if (isUndefined(this.resultsMenu)) {
81 - this.createResultsMenu();
82 - }
83 -
84 - // currently running UI
85 - if (isUndefined(this.runningAlert)) {
86 - this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
87 - dom.alert.appendChild(this.runningAlert);
88 - }
89 - this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
90 -
91 - // skipped specs UI
92 - if (isUndefined(this.skippedAlert)) {
93 - this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
94 - }
95 -
96 - this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
97 -
98 - if (this.skippedCount === 1 && isDefined(dom.alert)) {
99 - dom.alert.appendChild(this.skippedAlert);
100 - }
101 -
102 - // passing specs UI
103 - if (isUndefined(this.passedAlert)) {
104 - this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
105 - }
106 - this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
107 -
108 - // failing specs UI
109 - if (isUndefined(this.failedAlert)) {
110 - this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
111 - }
112 - this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
113 -
114 - if (this.failedCount === 1 && isDefined(dom.alert)) {
115 - dom.alert.appendChild(this.failedAlert);
116 - dom.alert.appendChild(this.resultsMenu);
117 - }
118 -
119 - // summary info
120 - this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
121 - this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
122 - };
123 -
124 - this.complete = function() {
125 - dom.alert.removeChild(this.runningAlert);
126 -
127 - this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
128 -
129 - if (this.failedCount === 0) {
130 - dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
131 - } else {
132 - showDetails();
133 - }
134 -
135 - dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
136 - };
137 -
138 - return this;
139 -
140 - function showDetails() {
141 - if (dom.reporter.className.search(/showDetails/) === -1) {
142 - dom.reporter.className += " showDetails";
143 - }
144 - }
145 -
146 - function isUndefined(obj) {
147 - return typeof obj === 'undefined';
148 - }
149 -
150 - function isDefined(obj) {
151 - return !isUndefined(obj);
152 - }
153 -
154 - function specPluralizedFor(count) {
155 - var str = count + " spec";
156 - if (count > 1) {
157 - str += "s"
158 - }
159 - return str;
160 - }
161 -
162 -};
163 -
164 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
165 -
166 -
vendor/jasmine/SpecView.js deleted
-81
@@ -1,81 +0,0 @@
1 -var jasmine = require("./jasmine");
2 -
3 -jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
4 - this.spec = spec;
5 - this.dom = dom;
6 - this.views = views;
7 -
8 - this.symbol = this.createDom('li', { className: 'pending' });
9 - this.dom.symbolSummary.appendChild(this.symbol);
10 -
11 - this.summary = this.createDom('div', { className: 'specSummary' },
12 - this.createDom('a', {
13 - className: 'description',
14 - href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
15 - title: this.spec.getFullName()
16 - }, this.spec.description)
17 - );
18 -
19 - this.detail = this.createDom('div', { className: 'specDetail' },
20 - this.createDom('a', {
21 - className: 'description',
22 - href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
23 - title: this.spec.getFullName()
24 - }, this.spec.getFullName())
25 - );
26 -};
27 -
28 -jasmine.HtmlReporter.SpecView.prototype.status = function() {
29 - return this.getSpecStatus(this.spec);
30 -};
31 -
32 -jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
33 - this.symbol.className = this.status();
34 -
35 - switch (this.status()) {
36 - case 'skipped':
37 - break;
38 -
39 - case 'passed':
40 - this.appendSummaryToSuiteDiv();
41 - break;
42 -
43 - case 'failed':
44 - this.appendSummaryToSuiteDiv();
45 - this.appendFailureDetail();
46 - break;
47 - }
48 -};
49 -
50 -jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
51 - this.summary.className += ' ' + this.status();
52 - this.appendToSummary(this.spec, this.summary);
53 -};
54 -
55 -jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
56 - this.detail.className += ' ' + this.status();
57 -
58 - var resultItems = this.spec.results().getItems();
59 - var messagesDiv = this.createDom('div', { className: 'messages' });
60 -
61 - for (var i = 0; i < resultItems.length; i++) {
62 - var result = resultItems[i];
63 -
64 - if (result.type == 'log') {
65 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
66 - } else if (result.type == 'expect' && result.passed && !result.passed()) {
67 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
68 -
69 - if (result.trace.stack) {
70 - messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
71 - }
72 - }
73 - }
74 -
75 - if (messagesDiv.childNodes.length > 0) {
76 - this.detail.appendChild(messagesDiv);
77 - this.dom.details.appendChild(this.detail);
78 - }
79 -};
80 -
81 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
\ No newline at end of file
vendor/jasmine/SuiteView.js deleted
-24
@@ -1,24 +0,0 @@
1 -var jasmine = require("./jasmine");
2 -
3 -jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
4 - this.suite = suite;
5 - this.dom = dom;
6 - this.views = views;
7 -
8 - this.element = this.createDom('div', { className: 'suite' },
9 - this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
10 - );
11 -
12 - this.appendToSummary(this.suite, this.element);
13 -};
14 -
15 -jasmine.HtmlReporter.SuiteView.prototype.status = function() {
16 - return this.getSpecStatus(this.suite);
17 -};
18 -
19 -jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
20 - this.element.className += " " + this.status();
21 -};
22 -
23 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
24 -
vendor/jasmine/all.js deleted
-38
@@ -1,38 +0,0 @@
1 -require("./phantom");
2 -require("./console");
3 -
4 -// TODO Also bundle jasmine.css here.
5 -var jasmine = require("./jasmine");
6 -require("./jasmine-html");
7 -require("./jasmine-support");
8 -
9 -require("./HtmlReporter");
10 -require("./PrintReporter");
11 -require("./ReporterView");
12 -require("./SpecView");
13 -require("./SuiteView");
14 -
15 -var env = jasmine.getEnv();
16 -env.addReporter(new jasmine.HtmlReporter);
17 -env.addReporter(new jasmine.PrintReporter);
18 -
19 -function exposeFrom(obj) {
20 - obj.spyOn = jasmine.spyOn;
21 - obj.it = jasmine.it;
22 - obj.xit = jasmine.xit;
23 - obj.expect = jasmine.expect;
24 - obj.runs = jasmine.runs;
25 - obj.waits = jasmine.waits;
26 - obj.waitsFor = jasmine.waitsFor;
27 - obj.beforeEach = jasmine.beforeEach;
28 - obj.afterEach = jasmine.afterEach;
29 - obj.describe = jasmine.describe;
30 - obj.xdescribe = jasmine.xdescribe;
31 - obj.jasmine = jasmine;
32 - return obj;
33 -}
34 -jasmine.exposeFrom = exposeFrom;
35 -var global = Function("return this")();
36 -exposeFrom(global);
37 -
38 -module.exports = jasmine;
vendor/jasmine/console.js deleted
-85
@@ -1,85 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * This module allows interception of console.* method calls, so that
10 - * listeners other than the native console object can consume logged
11 - * messages.
12 - */
13 -
14 -var global = Function("return this")();
15 -var Ap = Array.prototype;
16 -var slice = Ap.slice;
17 -
18 -var nativeConsole;
19 -if ("console" in global) {
20 - var gc = global.console;
21 - try { delete global.console } catch (ignored) {}
22 - nativeConsole = global.console || gc;
23 - global.console = gc;
24 -}
25 -
26 -// Provide a reliable console interface in all browsers.
27 -global.console = exports;
28 -
29 -function makeLogger(method) {
30 - var logger = exports[method] = function() {
31 - var args = slice.call(arguments);
32 - listeners.forEach(function(listener) {
33 - listener(method, args, logger);
34 - });
35 - };
36 -}
37 -
38 -makeLogger("info");
39 -makeLogger("log");
40 -makeLogger("debug");
41 -makeLogger("warn");
42 -makeLogger("error");
43 -makeLogger("dir");
44 -makeLogger("dirxml");
45 -makeLogger("trace");
46 -makeLogger("assert");
47 -makeLogger("count");
48 -makeLogger("markTimeline");
49 -makeLogger("profile");
50 -makeLogger("profileEnd");
51 -makeLogger("time");
52 -makeLogger("timeEnd");
53 -makeLogger("timeStamp");
54 -makeLogger("group");
55 -makeLogger("groupCollapsed");
56 -makeLogger("groupEnd");
57 -makeLogger("clear");
58 -
59 -var listeners = [];
60 -function addListener(listener) {
61 - listeners.push(listener);
62 -}
63 -exports.addListener = addListener
64 -
65 -function clean(arg) {
66 - if (typeof arg === "string") {
67 - // Remove any xterm-color escape sequences.
68 - // TODO Display colors in console if possible.
69 - arg = arg.replace(/\033\[\d+m/g, "");
70 - }
71 - return arg;
72 -}
73 -
74 -if (nativeConsole) {
75 - // If present, the native console object becomes a listener just like
76 - // any other.
77 - addListener(function(method, args) {
78 - var method = nativeConsole[method];
79 - if (method) {
80 - method.apply(nativeConsole, args.map(clean));
81 - } else {
82 - // Ignore this call.
83 - }
84 - });
85 -}
vendor/jasmine/diff.js deleted
-349
@@ -1,349 +0,0 @@
1 -/* See LICENSE file for terms of use */
2 -
3 -/*
4 - * Text diff implementation.
5 - *
6 - * This library supports the following APIS:
7 - * JsDiff.diffChars: Character by character diff
8 - * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
9 - * JsDiff.diffLines: Line based diff
10 - *
11 - * JsDiff.diffCss: Diff targeted at CSS content
12 - *
13 - * These methods are based on the implementation proposed in
14 - * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
15 - * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
16 - */
17 -var JsDiff = (function() {
18 - function clonePath(path) {
19 - return { newPos: path.newPos, components: path.components.slice(0) };
20 - }
21 - function removeEmpty(array) {
22 - var ret = [];
23 - for (var i = 0; i < array.length; i++) {
24 - if (array[i]) {
25 - ret.push(array[i]);
26 - }
27 - }
28 - return ret;
29 - }
30 - function escapeHTML(s) {
31 - var n = s;
32 - n = n.replace(/&/g, "&amp;");
33 - n = n.replace(/</g, "&lt;");
34 - n = n.replace(/>/g, "&gt;");
35 - n = n.replace(/"/g, "&quot;");
36 -
37 - return n;
38 - }
39 -
40 - var fbDiff = function(ignoreWhitespace) {
41 - this.ignoreWhitespace = ignoreWhitespace;
42 - };
43 - fbDiff.prototype = {
44 - diff: function(oldString, newString) {
45 - // Handle the identity case (this is due to unrolling editLength == 0
46 - if (newString == oldString) {
47 - return [{ value: newString }];
48 - }
49 - if (!newString) {
50 - return [{ value: oldString, removed: true }];
51 - }
52 - if (!oldString) {
53 - return [{ value: newString, added: true }];
54 - }
55 -
56 - newString = this.tokenize(newString);
57 - oldString = this.tokenize(oldString);
58 -
59 - var newLen = newString.length, oldLen = oldString.length;
60 - var maxEditLength = newLen + oldLen;
61 - var bestPath = [{ newPos: -1, components: [] }];
62 -
63 - // Seed editLength = 0
64 - var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
65 - if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) {
66 - return bestPath[0].components;
67 - }
68 -
69 - for (var editLength = 1; editLength <= maxEditLength; editLength++) {
70 - for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) {
71 - var basePath;
72 - var addPath = bestPath[diagonalPath-1],
73 - removePath = bestPath[diagonalPath+1];
74 - oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
75 - if (addPath) {
76 - // No one else is going to attempt to use this value, clear it
77 - bestPath[diagonalPath-1] = undefined;
78 - }
79 -
80 - var canAdd = addPath && addPath.newPos+1 < newLen;
81 - var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
82 - if (!canAdd && !canRemove) {
83 - bestPath[diagonalPath] = undefined;
84 - continue;
85 - }
86 -
87 - // Select the diagonal that we want to branch from. We select the prior
88 - // path whose position in the new string is the farthest from the origin
89 - // and does not pass the bounds of the diff graph
90 - if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
91 - basePath = clonePath(removePath);
92 - this.pushComponent(basePath.components, oldString[oldPos], undefined, true);
93 - } else {
94 - basePath = clonePath(addPath);
95 - basePath.newPos++;
96 - this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);
97 - }
98 -
99 - var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);
100 -
101 - if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) {
102 - return basePath.components;
103 - } else {
104 - bestPath[diagonalPath] = basePath;
105 - }
106 - }
107 - }
108 - },
109 -
110 - pushComponent: function(components, value, added, removed) {
111 - var last = components[components.length-1];
112 - if (last && last.added === added && last.removed === removed) {
113 - // We need to clone here as the component clone operation is just
114 - // as shallow array clone
115 - components[components.length-1] =
116 - {value: this.join(last.value, value), added: added, removed: removed };
117 - } else {
118 - components.push({value: value, added: added, removed: removed });
119 - }
120 - },
121 - extractCommon: function(basePath, newString, oldString, diagonalPath) {
122 - var newLen = newString.length,
123 - oldLen = oldString.length,
124 - newPos = basePath.newPos,
125 - oldPos = newPos - diagonalPath;
126 - while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) {
127 - newPos++;
128 - oldPos++;
129 -
130 - this.pushComponent(basePath.components, newString[newPos], undefined, undefined);
131 - }
132 - basePath.newPos = newPos;
133 - return oldPos;
134 - },
135 -
136 - equals: function(left, right) {
137 - var reWhitespace = /\S/;
138 - if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) {
139 - return true;
140 - } else {
141 - return left == right;
142 - }
143 - },
144 - join: function(left, right) {
145 - return left + right;
146 - },
147 - tokenize: function(value) {
148 - return value;
149 - }
150 - };
151 -
152 - var CharDiff = new fbDiff();
153 -
154 - var WordDiff = new fbDiff(true);
155 - WordDiff.tokenize = function(value) {
156 - return removeEmpty(value.split(/(\s+|\b)/));
157 - };
158 -
159 - var CssDiff = new fbDiff(true);
160 - CssDiff.tokenize = function(value) {
161 - return removeEmpty(value.split(/([{}:;,]|\s+)/));
162 - };
163 -
164 - var LineDiff = new fbDiff();
165 - LineDiff.tokenize = function(value) {
166 - return value.split(/^/m);
167 - };
168 -
169 - return {
170 - diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); },
171 - diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); },
172 - diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); },
173 -
174 - diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); },
175 -
176 - createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
177 - var ret = [];
178 -
179 - ret.push("Index: " + fileName);
180 - ret.push("===================================================================");
181 - ret.push("--- " + fileName + (typeof oldHeader === "undefined" ? "" : "\t" + oldHeader));
182 - ret.push("+++ " + fileName + (typeof newHeader === "undefined" ? "" : "\t" + newHeader));
183 -
184 - var diff = LineDiff.diff(oldStr, newStr);
185 - if (!diff[diff.length-1].value) {
186 - diff.pop(); // Remove trailing newline add
187 - }
188 - diff.push({value: "", lines: []}); // Append an empty value to make cleanup easier
189 -
190 - function contextLines(lines) {
191 - return lines.map(function(entry) { return ' ' + entry; });
192 - }
193 - function eofNL(curRange, i, current) {
194 - var last = diff[diff.length-2],
195 - isLast = i === diff.length-2,
196 - isLastOfType = i === diff.length-3 && (current.added !== last.added || current.removed !== last.removed);
197 -
198 - // Figure out if this is the last line for the given file and missing NL
199 - if (!/\n$/.test(current.value) && (isLast || isLastOfType)) {
200 - curRange.push('\\ No newline at end of file');
201 - }
202 - }
203 -
204 - var oldRangeStart = 0, newRangeStart = 0, curRange = [],
205 - oldLine = 1, newLine = 1;
206 - for (var i = 0; i < diff.length; i++) {
207 - var current = diff[i],
208 - lines = current.lines || current.value.replace(/\n$/, "").split("\n");
209 - current.lines = lines;
210 -
211 - if (current.added || current.removed) {
212 - if (!oldRangeStart) {
213 - var prev = diff[i-1];
214 - oldRangeStart = oldLine;
215 - newRangeStart = newLine;
216 -
217 - if (prev) {
218 - curRange = contextLines(prev.lines.slice(-4));
219 - oldRangeStart -= curRange.length;
220 - newRangeStart -= curRange.length;
221 - }
222 - }
223 - curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?"+":"-") + entry; }));
224 - eofNL(curRange, i, current);
225 -
226 - if (current.added) {
227 - newLine += lines.length;
228 - } else {
229 - oldLine += lines.length;
230 - }
231 - } else {
232 - if (oldRangeStart) {
233 - // Close out any changes that have been output (or join overlapping)
234 - if (lines.length <= 8 && i < diff.length-2) {
235 - // Overlapping
236 - curRange.push.apply(curRange, contextLines(lines));
237 - } else {
238 - // end the range and output
239 - var contextSize = Math.min(lines.length, 4);
240 - ret.push(
241 - "@@ -" + oldRangeStart + "," + (oldLine-oldRangeStart+contextSize)
242 - + " +" + newRangeStart + "," + (newLine-newRangeStart+contextSize)
243 - + " @@");
244 - ret.push.apply(ret, curRange);
245 - ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
246 - if (lines.length <= 4) {
247 - eofNL(ret, i, current);
248 - }
249 -
250 - oldRangeStart = 0; newRangeStart = 0; curRange = [];
251 - }
252 - }
253 - oldLine += lines.length;
254 - newLine += lines.length;
255 - }
256 - }
257 -
258 - return ret.join('\n') + '\n';
259 - },
260 -
261 - applyPatch: function(oldStr, uniDiff) {
262 - var diffstr = uniDiff.split("\n");
263 - var diff = [];
264 - var remEOFNL = false,
265 - addEOFNL = false;
266 -
267 - for (var i = (diffstr[0][0]=="I"?4:0); i < diffstr.length; i++) {
268 - if(diffstr[i][0] == "@") {
269 - var meh = diffstr[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
270 - diff.unshift({
271 - start:meh[3],
272 - oldlength:meh[2],
273 - oldlines:[],
274 - newlength:meh[4],
275 - newlines:[]
276 - });
277 - } else if(diffstr[i][0] == '+') {
278 - diff[0].newlines.push(diffstr[i].substr(1));
279 - } else if(diffstr[i][0] == '-') {
280 - diff[0].oldlines.push(diffstr[i].substr(1));
281 - } else if(diffstr[i][0] == ' ') {
282 - diff[0].newlines.push(diffstr[i].substr(1));
283 - diff[0].oldlines.push(diffstr[i].substr(1));
284 - } else if(diffstr[i][0] == '\\') {
285 - if (diffstr[i-1][0] == '+') {
286 - remEOFNL = true;
287 - } else if(diffstr[i-1][0] == '-') {
288 - addEOFNL = true;
289 - }
290 - }
291 - }
292 -
293 - var str = oldStr.split("\n");
294 - for (var i = diff.length - 1; i >= 0; i--) {
295 - var d = diff[i];
296 - for (var j = 0; j < d.oldlength; j++) {
297 - if(str[d.start-1+j] != d.oldlines[j]) {
298 - return false;
299 - }
300 - }
301 - Array.prototype.splice.apply(str,[d.start-1,+d.oldlength].concat(d.newlines));
302 - }
303 -
304 - if (remEOFNL) {
305 - while (!str[str.length-1]) {
306 - str.pop();
307 - }
308 - } else if (addEOFNL) {
309 - str.push('');
310 - }
311 - return str.join('\n');
312 - },
313 -
314 - convertChangesToXML: function(changes){
315 - var ret = [];
316 - for ( var i = 0; i < changes.length; i++) {
317 - var change = changes[i];
318 - if (change.added) {
319 - ret.push("<ins>");
320 - } else if (change.removed) {
321 - ret.push("<del>");
322 - }
323 -
324 - ret.push(escapeHTML(change.value));
325 -
326 - if (change.added) {
327 - ret.push("</ins>");
328 - } else if (change.removed) {
329 - ret.push("</del>");
330 - }
331 - }
332 - return ret.join("");
333 - },
334 -
335 - // See: http://code.google.com/p/google-diff-match-patch/wiki/API
336 - convertChangesToDMP: function(changes){
337 - var ret = [], change;
338 - for ( var i = 0; i < changes.length; i++) {
339 - change = changes[i];
340 - ret.push([(change.added ? 1 : change.removed ? -1 : 0), change.value]);
341 - }
342 - return ret;
343 - }
344 - };
345 -})();
346 -
347 -if (typeof module !== "undefined") {
348 - module.exports = JsDiff;
349 -}
vendor/jasmine/jasmine-html.js deleted
-681
@@ -1,681 +0,0 @@
1 -jasmine.HtmlReporterHelpers = {};
2 -
3 -jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
4 - var el = document.createElement(type);
5 -
6 - for (var i = 2; i < arguments.length; i++) {
7 - var child = arguments[i];
8 -
9 - if (typeof child === 'string') {
10 - el.appendChild(document.createTextNode(child));
11 - } else {
12 - if (child) {
13 - el.appendChild(child);
14 - }
15 - }
16 - }
17 -
18 - for (var attr in attrs) {
19 - if (attr == "className") {
20 - el[attr] = attrs[attr];
21 - } else {
22 - el.setAttribute(attr, attrs[attr]);
23 - }
24 - }
25 -
26 - return el;
27 -};
28 -
29 -jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
30 - var results = child.results();
31 - var status = results.passed() ? 'passed' : 'failed';
32 - if (results.skipped) {
33 - status = 'skipped';
34 - }
35 -
36 - return status;
37 -};
38 -
39 -jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
40 - var parentDiv = this.dom.summary;
41 - var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
42 - var parent = child[parentSuite];
43 -
44 - if (parent) {
45 - if (typeof this.views.suites[parent.id] == 'undefined') {
46 - this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
47 - }
48 - parentDiv = this.views.suites[parent.id].element;
49 - }
50 -
51 - parentDiv.appendChild(childElement);
52 -};
53 -
54 -
55 -jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
56 - for(var fn in jasmine.HtmlReporterHelpers) {
57 - ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
58 - }
59 -};
60 -
61 -jasmine.HtmlReporter = function(_doc) {
62 - var self = this;
63 - var doc = _doc || window.document;
64 -
65 - var reporterView;
66 -
67 - var dom = {};
68 -
69 - // Jasmine Reporter Public Interface
70 - self.logRunningSpecs = false;
71 -
72 - self.reportRunnerStarting = function(runner) {
73 - var specs = runner.specs() || [];
74 -
75 - if (specs.length == 0) {
76 - return;
77 - }
78 -
79 - createReporterDom(runner.env.versionString());
80 - doc.body.appendChild(dom.reporter);
81 - setExceptionHandling();
82 -
83 - reporterView = new jasmine.HtmlReporter.ReporterView(dom);
84 - reporterView.addSpecs(specs, self.specFilter);
85 - };
86 -
87 - self.reportRunnerResults = function(runner) {
88 - reporterView && reporterView.complete();
89 - };
90 -
91 - self.reportSuiteResults = function(suite) {
92 - reporterView.suiteComplete(suite);
93 - };
94 -
95 - self.reportSpecStarting = function(spec) {
96 - if (self.logRunningSpecs) {
97 - self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
98 - }
99 - };
100 -
101 - self.reportSpecResults = function(spec) {
102 - reporterView.specComplete(spec);
103 - };
104 -
105 - self.log = function() {
106 - var console = jasmine.getGlobal().console;
107 - if (console && console.log) {
108 - if (console.log.apply) {
109 - console.log.apply(console, arguments);
110 - } else {
111 - console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
112 - }
113 - }
114 - };
115 -
116 - self.specFilter = function(spec) {
117 - if (!focusedSpecName()) {
118 - return true;
119 - }
120 -
121 - return spec.getFullName().indexOf(focusedSpecName()) === 0;
122 - };
123 -
124 - return self;
125 -
126 - function focusedSpecName() {
127 - var specName;
128 -
129 - (function memoizeFocusedSpec() {
130 - if (specName) {
131 - return;
132 - }
133 -
134 - var paramMap = [];
135 - var params = jasmine.HtmlReporter.parameters(doc);
136 -
137 - for (var i = 0; i < params.length; i++) {
138 - var p = params[i].split('=');
139 - paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
140 - }
141 -
142 - specName = paramMap.spec;
143 - })();
144 -
145 - return specName;
146 - }
147 -
148 - function createReporterDom(version) {
149 - dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
150 - dom.banner = self.createDom('div', { className: 'banner' },
151 - self.createDom('span', { className: 'title' }, "Jasmine "),
152 - self.createDom('span', { className: 'version' }, version)),
153 -
154 - dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
155 - dom.alert = self.createDom('div', {className: 'alert'},
156 - self.createDom('span', { className: 'exceptions' },
157 - self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
158 - self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
159 - dom.results = self.createDom('div', {className: 'results'},
160 - dom.summary = self.createDom('div', { className: 'summary' }),
161 - dom.details = self.createDom('div', { id: 'details' }))
162 - );
163 - }
164 -
165 - function noTryCatch() {
166 - return window.location.search.match(/catch=false/);
167 - }
168 -
169 - function searchWithCatch() {
170 - var params = jasmine.HtmlReporter.parameters(window.document);
171 - var removed = false;
172 - var i = 0;
173 -
174 - while (!removed && i < params.length) {
175 - if (params[i].match(/catch=/)) {
176 - params.splice(i, 1);
177 - removed = true;
178 - }
179 - i++;
180 - }
181 - if (jasmine.CATCH_EXCEPTIONS) {
182 - params.push("catch=false");
183 - }
184 -
185 - return params.join("&");
186 - }
187 -
188 - function setExceptionHandling() {
189 - var chxCatch = document.getElementById('no_try_catch');
190 -
191 - if (noTryCatch()) {
192 - chxCatch.setAttribute('checked', true);
193 - jasmine.CATCH_EXCEPTIONS = false;
194 - }
195 - chxCatch.onclick = function() {
196 - window.location.search = searchWithCatch();
197 - };
198 - }
199 -};
200 -jasmine.HtmlReporter.parameters = function(doc) {
201 - var paramStr = doc.location.search.substring(1);
202 - var params = [];
203 -
204 - if (paramStr.length > 0) {
205 - params = paramStr.split('&');
206 - }
207 - return params;
208 -}
209 -jasmine.HtmlReporter.sectionLink = function(sectionName) {
210 - var link = '?';
211 - var params = [];
212 -
213 - if (sectionName) {
214 - params.push('spec=' + encodeURIComponent(sectionName));
215 - }
216 - if (!jasmine.CATCH_EXCEPTIONS) {
217 - params.push("catch=false");
218 - }
219 - if (params.length > 0) {
220 - link += params.join("&");
221 - }
222 -
223 - return link;
224 -};
225 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
226 -jasmine.HtmlReporter.ReporterView = function(dom) {
227 - this.startedAt = new Date();
228 - this.runningSpecCount = 0;
229 - this.completeSpecCount = 0;
230 - this.passedCount = 0;
231 - this.failedCount = 0;
232 - this.skippedCount = 0;
233 -
234 - this.createResultsMenu = function() {
235 - this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
236 - this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
237 - ' | ',
238 - this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
239 -
240 - this.summaryMenuItem.onclick = function() {
241 - dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
242 - };
243 -
244 - this.detailsMenuItem.onclick = function() {
245 - showDetails();
246 - };
247 - };
248 -
249 - this.addSpecs = function(specs, specFilter) {
250 - this.totalSpecCount = specs.length;
251 -
252 - this.views = {
253 - specs: {},
254 - suites: {}
255 - };
256 -
257 - for (var i = 0; i < specs.length; i++) {
258 - var spec = specs[i];
259 - this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
260 - if (specFilter(spec)) {
261 - this.runningSpecCount++;
262 - }
263 - }
264 - };
265 -
266 - this.specComplete = function(spec) {
267 - this.completeSpecCount++;
268 -
269 - if (isUndefined(this.views.specs[spec.id])) {
270 - this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
271 - }
272 -
273 - var specView = this.views.specs[spec.id];
274 -
275 - switch (specView.status()) {
276 - case 'passed':
277 - this.passedCount++;
278 - break;
279 -
280 - case 'failed':
281 - this.failedCount++;
282 - break;
283 -
284 - case 'skipped':
285 - this.skippedCount++;
286 - break;
287 - }
288 -
289 - specView.refresh();
290 - this.refresh();
291 - };
292 -
293 - this.suiteComplete = function(suite) {
294 - var suiteView = this.views.suites[suite.id];
295 - if (isUndefined(suiteView)) {
296 - return;
297 - }
298 - suiteView.refresh();
299 - };
300 -
301 - this.refresh = function() {
302 -
303 - if (isUndefined(this.resultsMenu)) {
304 - this.createResultsMenu();
305 - }
306 -
307 - // currently running UI
308 - if (isUndefined(this.runningAlert)) {
309 - this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
310 - dom.alert.appendChild(this.runningAlert);
311 - }
312 - this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
313 -
314 - // skipped specs UI
315 - if (isUndefined(this.skippedAlert)) {
316 - this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
317 - }
318 -
319 - this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
320 -
321 - if (this.skippedCount === 1 && isDefined(dom.alert)) {
322 - dom.alert.appendChild(this.skippedAlert);
323 - }
324 -
325 - // passing specs UI
326 - if (isUndefined(this.passedAlert)) {
327 - this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
328 - }
329 - this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
330 -
331 - // failing specs UI
332 - if (isUndefined(this.failedAlert)) {
333 - this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
334 - }
335 - this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
336 -
337 - if (this.failedCount === 1 && isDefined(dom.alert)) {
338 - dom.alert.appendChild(this.failedAlert);
339 - dom.alert.appendChild(this.resultsMenu);
340 - }
341 -
342 - // summary info
343 - this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
344 - this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
345 - };
346 -
347 - this.complete = function() {
348 - dom.alert.removeChild(this.runningAlert);
349 -
350 - this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
351 -
352 - if (this.failedCount === 0) {
353 - dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
354 - } else {
355 - showDetails();
356 - }
357 -
358 - dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
359 - };
360 -
361 - return this;
362 -
363 - function showDetails() {
364 - if (dom.reporter.className.search(/showDetails/) === -1) {
365 - dom.reporter.className += " showDetails";
366 - }
367 - }
368 -
369 - function isUndefined(obj) {
370 - return typeof obj === 'undefined';
371 - }
372 -
373 - function isDefined(obj) {
374 - return !isUndefined(obj);
375 - }
376 -
377 - function specPluralizedFor(count) {
378 - var str = count + " spec";
379 - if (count > 1) {
380 - str += "s"
381 - }
382 - return str;
383 - }
384 -
385 -};
386 -
387 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
388 -
389 -
390 -jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
391 - this.spec = spec;
392 - this.dom = dom;
393 - this.views = views;
394 -
395 - this.symbol = this.createDom('li', { className: 'pending' });
396 - this.dom.symbolSummary.appendChild(this.symbol);
397 -
398 - this.summary = this.createDom('div', { className: 'specSummary' },
399 - this.createDom('a', {
400 - className: 'description',
401 - href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
402 - title: this.spec.getFullName()
403 - }, this.spec.description)
404 - );
405 -
406 - this.detail = this.createDom('div', { className: 'specDetail' },
407 - this.createDom('a', {
408 - className: 'description',
409 - href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
410 - title: this.spec.getFullName()
411 - }, this.spec.getFullName())
412 - );
413 -};
414 -
415 -jasmine.HtmlReporter.SpecView.prototype.status = function() {
416 - return this.getSpecStatus(this.spec);
417 -};
418 -
419 -jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
420 - this.symbol.className = this.status();
421 -
422 - switch (this.status()) {
423 - case 'skipped':
424 - break;
425 -
426 - case 'passed':
427 - this.appendSummaryToSuiteDiv();
428 - break;
429 -
430 - case 'failed':
431 - this.appendSummaryToSuiteDiv();
432 - this.appendFailureDetail();
433 - break;
434 - }
435 -};
436 -
437 -jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
438 - this.summary.className += ' ' + this.status();
439 - this.appendToSummary(this.spec, this.summary);
440 -};
441 -
442 -jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
443 - this.detail.className += ' ' + this.status();
444 -
445 - var resultItems = this.spec.results().getItems();
446 - var messagesDiv = this.createDom('div', { className: 'messages' });
447 -
448 - for (var i = 0; i < resultItems.length; i++) {
449 - var result = resultItems[i];
450 -
451 - if (result.type == 'log') {
452 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
453 - } else if (result.type == 'expect' && result.passed && !result.passed()) {
454 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
455 -
456 - if (result.trace.stack) {
457 - messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
458 - }
459 - }
460 - }
461 -
462 - if (messagesDiv.childNodes.length > 0) {
463 - this.detail.appendChild(messagesDiv);
464 - this.dom.details.appendChild(this.detail);
465 - }
466 -};
467 -
468 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
469 - this.suite = suite;
470 - this.dom = dom;
471 - this.views = views;
472 -
473 - this.element = this.createDom('div', { className: 'suite' },
474 - this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
475 - );
476 -
477 - this.appendToSummary(this.suite, this.element);
478 -};
479 -
480 -jasmine.HtmlReporter.SuiteView.prototype.status = function() {
481 - return this.getSpecStatus(this.suite);
482 -};
483 -
484 -jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
485 - this.element.className += " " + this.status();
486 -};
487 -
488 -jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
489 -
490 -/* @deprecated Use jasmine.HtmlReporter instead
491 - */
492 -jasmine.TrivialReporter = function(doc) {
493 - this.document = doc || document;
494 - this.suiteDivs = {};
495 - this.logRunningSpecs = false;
496 -};
497 -
498 -jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
499 - var el = document.createElement(type);
500 -
501 - for (var i = 2; i < arguments.length; i++) {
502 - var child = arguments[i];
503 -
504 - if (typeof child === 'string') {
505 - el.appendChild(document.createTextNode(child));
506 - } else {
507 - if (child) { el.appendChild(child); }
508 - }
509 - }
510 -
511 - for (var attr in attrs) {
512 - if (attr == "className") {
513 - el[attr] = attrs[attr];
514 - } else {
515 - el.setAttribute(attr, attrs[attr]);
516 - }
517 - }
518 -
519 - return el;
520 -};
521 -
522 -jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
523 - var showPassed, showSkipped;
524 -
525 - this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
526 - this.createDom('div', { className: 'banner' },
527 - this.createDom('div', { className: 'logo' },
528 - this.createDom('span', { className: 'title' }, "Jasmine"),
529 - this.createDom('span', { className: 'version' }, runner.env.versionString())),
530 - this.createDom('div', { className: 'options' },
531 - "Show ",
532 - showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
533 - this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
534 - showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
535 - this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
536 - )
537 - ),
538 -
539 - this.runnerDiv = this.createDom('div', { className: 'runner running' },
540 - this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
541 - this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
542 - this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
543 - );
544 -
545 - this.document.body.appendChild(this.outerDiv);
546 -
547 - var suites = runner.suites();
548 - for (var i = 0; i < suites.length; i++) {
549 - var suite = suites[i];
550 - var suiteDiv = this.createDom('div', { className: 'suite' },
551 - this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
552 - this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
553 - this.suiteDivs[suite.id] = suiteDiv;
554 - var parentDiv = this.outerDiv;
555 - if (suite.parentSuite) {
556 - parentDiv = this.suiteDivs[suite.parentSuite.id];
557 - }
558 - parentDiv.appendChild(suiteDiv);
559 - }
560 -
561 - this.startedAt = new Date();
562 -
563 - var self = this;
564 - showPassed.onclick = function(evt) {
565 - if (showPassed.checked) {
566 - self.outerDiv.className += ' show-passed';
567 - } else {
568 - self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
569 - }
570 - };
571 -
572 - showSkipped.onclick = function(evt) {
573 - if (showSkipped.checked) {
574 - self.outerDiv.className += ' show-skipped';
575 - } else {
576 - self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
577 - }
578 - };
579 -};
580 -
581 -jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
582 - var results = runner.results();
583 - var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
584 - this.runnerDiv.setAttribute("class", className);
585 - //do it twice for IE
586 - this.runnerDiv.setAttribute("className", className);
587 - var specs = runner.specs();
588 - var specCount = 0;
589 - for (var i = 0; i < specs.length; i++) {
590 - if (this.specFilter(specs[i])) {
591 - specCount++;
592 - }
593 - }
594 - var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
595 - message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
596 - this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
597 -
598 - this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
599 -};
600 -
601 -jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
602 - var results = suite.results();
603 - var status = results.passed() ? 'passed' : 'failed';
604 - if (results.totalCount === 0) { // todo: change this to check results.skipped
605 - status = 'skipped';
606 - }
607 - this.suiteDivs[suite.id].className += " " + status;
608 -};
609 -
610 -jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
611 - if (this.logRunningSpecs) {
612 - this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
613 - }
614 -};
615 -
616 -jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
617 - var results = spec.results();
618 - var status = results.passed() ? 'passed' : 'failed';
619 - if (results.skipped) {
620 - status = 'skipped';
621 - }
622 - var specDiv = this.createDom('div', { className: 'spec ' + status },
623 - this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
624 - this.createDom('a', {
625 - className: 'description',
626 - href: '?spec=' + encodeURIComponent(spec.getFullName()),
627 - title: spec.getFullName()
628 - }, spec.description));
629 -
630 -
631 - var resultItems = results.getItems();
632 - var messagesDiv = this.createDom('div', { className: 'messages' });
633 - for (var i = 0; i < resultItems.length; i++) {
634 - var result = resultItems[i];
635 -
636 - if (result.type == 'log') {
637 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
638 - } else if (result.type == 'expect' && result.passed && !result.passed()) {
639 - messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
640 -
641 - if (result.trace.stack) {
642 - messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
643 - }
644 - }
645 - }
646 -
647 - if (messagesDiv.childNodes.length > 0) {
648 - specDiv.appendChild(messagesDiv);
649 - }
650 -
651 - this.suiteDivs[spec.suite.id].appendChild(specDiv);
652 -};
653 -
654 -jasmine.TrivialReporter.prototype.log = function() {
655 - var console = jasmine.getGlobal().console;
656 - if (console && console.log) {
657 - if (console.log.apply) {
658 - console.log.apply(console, arguments);
659 - } else {
660 - console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
661 - }
662 - }
663 -};
664 -
665 -jasmine.TrivialReporter.prototype.getLocation = function() {
666 - return this.document.location;
667 -};
668 -
669 -jasmine.TrivialReporter.prototype.specFilter = function(spec) {
670 - var paramMap = {};
671 - var params = this.getLocation().search.substring(1).split('&');
672 - for (var i = 0; i < params.length; i++) {
673 - var p = params[i].split('=');
674 - paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
675 - }
676 -
677 - if (!paramMap.spec) {
678 - return true;
679 - }
680 - return spec.getFullName().indexOf(paramMap.spec) === 0;
681 -};
vendor/jasmine/jasmine-support.js deleted
-127
@@ -1,127 +0,0 @@
1 -if (typeof jasmine == 'undefined') jasmine = require("./jasmine");
2 -var spec = false; // TODO
3 -
4 -// Add some matcher for mock functions
5 -jasmine.getEnv().beforeEach(function() {
6 - this.addMatchers({
7 - toBeCalled: function() {
8 - if (this.actual.mock === undefined) {
9 - throw Error('toBeCalled() should be used on a mock function');
10 - }
11 - return this.actual.mock.calls.length !== 0;
12 - },
13 -
14 - lastCalledWith: function() {
15 - if (this.actual.mock === undefined) {
16 - throw Error('lastCalledWith() should be used on a mock function');
17 - }
18 - var calls = this.actual.mock.calls;
19 - var args = Array.prototype.slice.call(arguments);
20 - return this.env.equals_(calls[calls.length - 1], args);
21 - },
22 -
23 - toBeCalledWith: function() {
24 - if (this.actual.mock === undefined) {
25 - throw Error('toBeCalledWith() should be used on a mock function');
26 - }
27 - var args = Array.prototype.slice.call(arguments);
28 - return this.actual.mock.calls.some(function(call) {
29 - return this.env.equals_(call, args);
30 - }.bind(this));
31 - }
32 - });
33 -});
34 -
35 -var _it = jasmine.Env.prototype.it;
36 -var _xit = jasmine.Env.prototype.xit;
37 -jasmine.Env.prototype.it = function(desc, func) {
38 - // If spec is provided, only run matching specs
39 - if (!spec || desc.match(new RegExp(spec, 'i'))) {
40 - return _it.call(this, desc, func);
41 - } else {
42 - return this.xit(desc, func);
43 - }
44 -};
45 -jasmine.Env.prototype.xit = function(desc, func) {
46 - if (typeof func == 'function') {
47 - var matches = func.toString().match(/.*\W?expect\(/g);
48 - if (matches) {
49 - this.reporter.subReporters_[0].skipCount += matches.length;
50 - this.reporter.subReporters_[0].totalCount += matches.length;
51 - }
52 - }
53 - return _xit.call(this, desc, func);
54 -}
55 -
56 -// Mainline Jasmine sets __Jasmine_been_here_before__ on each object to detect
57 -// cycles, but that doesn't work on frozen objects so we use a WeakMap instead.
58 -// We can only do this if if WeakMap is available, but if WeakMap is
59 -// unavailable, then objects probably can't be frozen anyway.
60 -
61 -if (typeof WeakMap !== "undefined") {
62 - var _comparedObjects = new WeakMap;
63 -
64 - jasmine.Env.prototype.compareObjects_ =
65 - function(a, b, mismatchKeys, mismatchValues) {
66 - if (_comparedObjects.get(a) === b && _comparedObjects.get(b) === a) {
67 - return true;
68 - }
69 - var areArrays = jasmine.isArray_(a) && jasmine.isArray_(b);
70 -
71 - _comparedObjects.set(a, b);
72 - _comparedObjects.set(b, a);
73 -
74 - var hasKey = function(obj, keyName) {
75 - return obj != null && obj[keyName] !== jasmine.undefined;
76 - };
77 -
78 - for (var property in b) {
79 - if (areArrays && typeof b[property] == 'function') {
80 - continue;
81 - }
82 - if (!hasKey(a, property) && hasKey(b, property)) {
83 - mismatchKeys.push(
84 - "expected has key '" + property + "', but missing from actual."
85 - );
86 - }
87 - }
88 - for (property in a) {
89 - if (areArrays && typeof a[property] == 'function') {
90 - continue;
91 - }
92 - if (!hasKey(b, property) && hasKey(a, property)) {
93 - mismatchKeys.push(
94 - "expected missing key '" + property + "', but present in actual."
95 - );
96 - }
97 - }
98 - for (property in b) {
99 - // The only different implementation from the original jasmine
100 - if (areArrays &&
101 - (typeof a[property] == 'function' ||
102 - typeof b[property] == 'function')) {
103 - continue;
104 - }
105 - if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues))
106 - {
107 - mismatchValues.push(
108 - "'" + property + "' was '" + (b[property] ?
109 - jasmine.util.htmlEscape(b[property].toString()) :
110 - b[property]) +
111 - "' in expected, but was '" + (a[property] ?
112 - jasmine.util.htmlEscape(a[property].toString()) :
113 - a[property]) + "' in actual."
114 - );
115 - }
116 - }
117 -
118 - if (areArrays &&
119 - a.length != b.length) {
120 - mismatchValues.push("arrays were not the same length");
121 - }
122 -
123 - _comparedObjects["delete"](a);
124 - _comparedObjects["delete"](b);
125 - return (mismatchKeys.length == 0 && mismatchValues.length == 0);
126 - };
127 -}
vendor/jasmine/jasmine.css deleted
-82
@@ -1,82 +0,0 @@
1 -body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
2 -
3 -#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
4 -#HTMLReporter a { text-decoration: none; }
5 -#HTMLReporter a:hover { text-decoration: underline; }
6 -#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
7 -#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
8 -#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
9 -#HTMLReporter .version { color: #aaaaaa; }
10 -#HTMLReporter .banner { margin-top: 14px; }
11 -#HTMLReporter .duration { color: #aaaaaa; float: right; }
12 -#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
13 -#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
14 -#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
15 -#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
16 -#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
17 -#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
18 -#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
19 -#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
20 -#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
21 -#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
22 -#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
23 -#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
24 -#HTMLReporter .runningAlert { background-color: #666666; }
25 -#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
26 -#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
27 -#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
28 -#HTMLReporter .passingAlert { background-color: #a6b779; }
29 -#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
30 -#HTMLReporter .failingAlert { background-color: #cf867e; }
31 -#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
32 -#HTMLReporter .results { margin-top: 14px; }
33 -#HTMLReporter #details { display: none; }
34 -#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
35 -#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
36 -#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
37 -#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
38 -#HTMLReporter.showDetails .summary { display: none; }
39 -#HTMLReporter.showDetails #details { display: block; }
40 -#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
41 -#HTMLReporter .summary { margin-top: 14px; }
42 -#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
43 -#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
44 -#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
45 -#HTMLReporter .description + .suite { margin-top: 0; }
46 -#HTMLReporter .suite { margin-top: 14px; }
47 -#HTMLReporter .suite a { color: #333333; }
48 -#HTMLReporter #details .specDetail { margin-bottom: 28px; }
49 -#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
50 -#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
51 -#HTMLReporter .resultMessage span.result { display: block; }
52 -#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
53 -
54 -#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
55 -#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
56 -#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
57 -#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
58 -#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
59 -#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
60 -#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
61 -#TrivialReporter .runner.running { background-color: yellow; }
62 -#TrivialReporter .options { text-align: right; font-size: .8em; }
63 -#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
64 -#TrivialReporter .suite .suite { margin: 5px; }
65 -#TrivialReporter .suite.passed { background-color: #dfd; }
66 -#TrivialReporter .suite.failed { background-color: #fdd; }
67 -#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
68 -#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
69 -#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
70 -#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
71 -#TrivialReporter .spec.skipped { background-color: #bbb; }
72 -#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
73 -#TrivialReporter .passed { background-color: #cfc; display: none; }
74 -#TrivialReporter .failed { background-color: #fbb; }
75 -#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
76 -#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
77 -#TrivialReporter .resultMessage .mismatch { color: black; }
78 -#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
79 -#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
80 -#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
81 -#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
82 -#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
vendor/jasmine/jasmine.js deleted
-2600
@@ -1,2600 +0,0 @@
1 -var isCommonJS = typeof window == "undefined" && typeof exports == "object";
2 -
3 -/**
4 - * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
5 - *
6 - * @namespace
7 - */
8 -var jasmine = {};
9 -if (isCommonJS) exports.jasmine = jasmine;
10 -/**
11 - * @private
12 - */
13 -jasmine.unimplementedMethod_ = function() {
14 - throw new Error("unimplemented method");
15 -};
16 -
17 -/**
18 - * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just
19 - * a plain old variable and may be redefined by somebody else.
20 - *
21 - * @private
22 - */
23 -jasmine.undefined = jasmine.___undefined___;
24 -
25 -/**
26 - * Show diagnostic messages in the console if set to true
27 - *
28 - */
29 -jasmine.VERBOSE = false;
30 -
31 -/**
32 - * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
33 - *
34 - */
35 -jasmine.DEFAULT_UPDATE_INTERVAL = 250;
36 -
37 -/**
38 - * Maximum levels of nesting that will be included when an object is pretty-printed
39 - */
40 -jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
41 -
42 -/**
43 - * Default timeout interval in milliseconds for waitsFor() blocks.
44 - */
45 -jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
46 -
47 -/**
48 - * By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
49 - * Set to false to let the exception bubble up in the browser.
50 - *
51 - */
52 -jasmine.CATCH_EXCEPTIONS = true;
53 -
54 -jasmine.getGlobal = function() {
55 - function getGlobal() {
56 - return this;
57 - }
58 -
59 - return getGlobal();
60 -};
61 -
62 -/**
63 - * Allows for bound functions to be compared. Internal use only.
64 - *
65 - * @ignore
66 - * @private
67 - * @param base {Object} bound 'this' for the function
68 - * @param name {Function} function to find
69 - */
70 -jasmine.bindOriginal_ = function(base, name) {
71 - var original = base[name];
72 - if (original.apply) {
73 - return function() {
74 - return original.apply(base, arguments);
75 - };
76 - } else {
77 - // IE support
78 - return jasmine.getGlobal()[name];
79 - }
80 -};
81 -
82 -jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
83 -jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
84 -jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
85 -jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
86 -
87 -jasmine.MessageResult = function(values) {
88 - this.type = 'log';
89 - this.values = values;
90 - this.trace = new Error(); // todo: test better
91 -};
92 -
93 -jasmine.MessageResult.prototype.toString = function() {
94 - var text = "";
95 - for (var i = 0; i < this.values.length; i++) {
96 - if (i > 0) text += " ";
97 - if (jasmine.isString_(this.values[i])) {
98 - text += this.values[i];
99 - } else {
100 - text += jasmine.pp(this.values[i]);
101 - }
102 - }
103 - return text;
104 -};
105 -
106 -jasmine.ExpectationResult = function(params) {
107 - this.type = 'expect';
108 - this.matcherName = params.matcherName;
109 - this.passed_ = params.passed;
110 - this.expected = params.expected;
111 - this.actual = params.actual;
112 - this.message = this.passed_ ? 'Passed.' : params.message;
113 -
114 - var trace = (params.trace || new Error(this.message));
115 - this.trace = this.passed_ ? '' : trace;
116 -};
117 -
118 -jasmine.ExpectationResult.prototype.toString = function () {
119 - return this.message;
120 -};
121 -
122 -jasmine.ExpectationResult.prototype.passed = function () {
123 - return this.passed_;
124 -};
125 -
126 -/**
127 - * Getter for the Jasmine environment. Ensures one gets created
128 - */
129 -jasmine.getEnv = function() {
130 - var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
131 - return env;
132 -};
133 -
134 -/**
135 - * @ignore
136 - * @private
137 - * @param value
138 - * @returns {Boolean}
139 - */
140 -jasmine.isArray_ = function(value) {
141 - return jasmine.isA_("Array", value);
142 -};
143 -
144 -/**
145 - * @ignore
146 - * @private
147 - * @param value
148 - * @returns {Boolean}
149 - */
150 -jasmine.isString_ = function(value) {
151 - return jasmine.isA_("String", value);
152 -};
153 -
154 -/**
155 - * @ignore
156 - * @private
157 - * @param value
158 - * @returns {Boolean}
159 - */
160 -jasmine.isNumber_ = function(value) {
161 - return jasmine.isA_("Number", value);
162 -};
163 -
164 -/**
165 - * @ignore
166 - * @private
167 - * @param {String} typeName
168 - * @param value
169 - * @returns {Boolean}
170 - */
171 -jasmine.isA_ = function(typeName, value) {
172 - return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
173 -};
174 -
175 -/**
176 - * Pretty printer for expecations. Takes any object and turns it into a human-readable string.
177 - *
178 - * @param value {Object} an object to be outputted
179 - * @returns {String}
180 - */
181 -jasmine.pp = function(value) {
182 - var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
183 - stringPrettyPrinter.format(value);
184 - return stringPrettyPrinter.string;
185 -};
186 -
187 -/**
188 - * Returns true if the object is a DOM Node.
189 - *
190 - * @param {Object} obj object to check
191 - * @returns {Boolean}
192 - */
193 -jasmine.isDomNode = function(obj) {
194 - return obj.nodeType > 0;
195 -};
196 -
197 -/**
198 - * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.
199 - *
200 - * @example
201 - * // don't care about which function is passed in, as long as it's a function
202 - * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
203 - *
204 - * @param {Class} clazz
205 - * @returns matchable object of the type clazz
206 - */
207 -jasmine.any = function(clazz) {
208 - return new jasmine.Matchers.Any(clazz);
209 -};
210 -
211 -/**
212 - * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
213 - * attributes on the object.
214 - *
215 - * @example
216 - * // don't care about any other attributes than foo.
217 - * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
218 - *
219 - * @param sample {Object} sample
220 - * @returns matchable object for the sample
221 - */
222 -jasmine.objectContaining = function (sample) {
223 - return new jasmine.Matchers.ObjectContaining(sample);
224 -};
225 -
226 -/**
227 - * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
228 - *
229 - * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
230 - * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
231 - *
232 - * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
233 - *
234 - * Spies are torn down at the end of every spec.
235 - *
236 - * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
237 - *
238 - * @example
239 - * // a stub
240 - * var myStub = jasmine.createSpy('myStub'); // can be used anywhere
241 - *
242 - * // spy example
243 - * var foo = {
244 - * not: function(bool) { return !bool; }
245 - * }
246 - *
247 - * // actual foo.not will not be called, execution stops
248 - * spyOn(foo, 'not');
249 -
250 - // foo.not spied upon, execution will continue to implementation
251 - * spyOn(foo, 'not').andCallThrough();
252 - *
253 - * // fake example
254 - * var foo = {
255 - * not: function(bool) { return !bool; }
256 - * }
257 - *
258 - * // foo.not(val) will return val
259 - * spyOn(foo, 'not').andCallFake(function(value) {return value;});
260 - *
261 - * // mock example
262 - * foo.not(7 == 7);
263 - * expect(foo.not).toHaveBeenCalled();
264 - * expect(foo.not).toHaveBeenCalledWith(true);
265 - *
266 - * @constructor
267 - * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
268 - * @param {String} name
269 - */
270 -jasmine.Spy = function(name) {
271 - /**
272 - * The name of the spy, if provided.
273 - */
274 - this.identity = name || 'unknown';
275 - /**
276 - * Is this Object a spy?
277 - */
278 - this.isSpy = true;
279 - /**
280 - * The actual function this spy stubs.
281 - */
282 - this.plan = function() {
283 - };
284 - /**
285 - * Tracking of the most recent call to the spy.
286 - * @example
287 - * var mySpy = jasmine.createSpy('foo');
288 - * mySpy(1, 2);
289 - * mySpy.mostRecentCall.args = [1, 2];
290 - */
291 - this.mostRecentCall = {};
292 -
293 - /**
294 - * Holds arguments for each call to the spy, indexed by call count
295 - * @example
296 - * var mySpy = jasmine.createSpy('foo');
297 - * mySpy(1, 2);
298 - * mySpy(7, 8);
299 - * mySpy.mostRecentCall.args = [7, 8];
300 - * mySpy.argsForCall[0] = [1, 2];
301 - * mySpy.argsForCall[1] = [7, 8];
302 - */
303 - this.argsForCall = [];
304 - this.calls = [];
305 -};
306 -
307 -/**
308 - * Tells a spy to call through to the actual implemenatation.
309 - *
310 - * @example
311 - * var foo = {
312 - * bar: function() { // do some stuff }
313 - * }
314 - *
315 - * // defining a spy on an existing property: foo.bar
316 - * spyOn(foo, 'bar').andCallThrough();
317 - */
318 -jasmine.Spy.prototype.andCallThrough = function() {
319 - this.plan = this.originalValue;
320 - return this;
321 -};
322 -
323 -/**
324 - * For setting the return value of a spy.
325 - *
326 - * @example
327 - * // defining a spy from scratch: foo() returns 'baz'
328 - * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
329 - *
330 - * // defining a spy on an existing property: foo.bar() returns 'baz'
331 - * spyOn(foo, 'bar').andReturn('baz');
332 - *
333 - * @param {Object} value
334 - */
335 -jasmine.Spy.prototype.andReturn = function(value) {
336 - this.plan = function() {
337 - return value;
338 - };
339 - return this;
340 -};
341 -
342 -/**
343 - * For throwing an exception when a spy is called.
344 - *
345 - * @example
346 - * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
347 - * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
348 - *
349 - * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
350 - * spyOn(foo, 'bar').andThrow('baz');
351 - *
352 - * @param {String} exceptionMsg
353 - */
354 -jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
355 - this.plan = function() {
356 - throw exceptionMsg;
357 - };
358 - return this;
359 -};
360 -
361 -/**
362 - * Calls an alternate implementation when a spy is called.
363 - *
364 - * @example
365 - * var baz = function() {
366 - * // do some stuff, return something
367 - * }
368 - * // defining a spy from scratch: foo() calls the function baz
369 - * var foo = jasmine.createSpy('spy on foo').andCall(baz);
370 - *
371 - * // defining a spy on an existing property: foo.bar() calls an anonymnous function
372 - * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
373 - *
374 - * @param {Function} fakeFunc
375 - */
376 -jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
377 - this.plan = fakeFunc;
378 - return this;
379 -};
380 -
381 -/**
382 - * Resets all of a spy's the tracking variables so that it can be used again.
383 - *
384 - * @example
385 - * spyOn(foo, 'bar');
386 - *
387 - * foo.bar();
388 - *
389 - * expect(foo.bar.callCount).toEqual(1);
390 - *
391 - * foo.bar.reset();
392 - *
393 - * expect(foo.bar.callCount).toEqual(0);
394 - */
395 -jasmine.Spy.prototype.reset = function() {
396 - this.wasCalled = false;
397 - this.callCount = 0;
398 - this.argsForCall = [];
399 - this.calls = [];
400 - this.mostRecentCall = {};
401 -};
402 -
403 -jasmine.createSpy = function(name) {
404 -
405 - var spyObj = function() {
406 - spyObj.wasCalled = true;
407 - spyObj.callCount++;
408 - var args = jasmine.util.argsToArray(arguments);
409 - spyObj.mostRecentCall.object = this;
410 - spyObj.mostRecentCall.args = args;
411 - spyObj.argsForCall.push(args);
412 - spyObj.calls.push({object: this, args: args});
413 - return spyObj.plan.apply(this, arguments);
414 - };
415 -
416 - var spy = new jasmine.Spy(name);
417 -
418 - for (var prop in spy) {
419 - spyObj[prop] = spy[prop];
420 - }
421 -
422 - spyObj.reset();
423 -
424 - return spyObj;
425 -};
426 -
427 -/**
428 - * Determines whether an object is a spy.
429 - *
430 - * @param {jasmine.Spy|Object} putativeSpy
431 - * @returns {Boolean}
432 - */
433 -jasmine.isSpy = function(putativeSpy) {
434 - return putativeSpy && putativeSpy.isSpy;
435 -};
436 -
437 -/**
438 - * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
439 - * large in one call.
440 - *
441 - * @param {String} baseName name of spy class
442 - * @param {Array} methodNames array of names of methods to make spies
443 - */
444 -jasmine.createSpyObj = function(baseName, methodNames) {
445 - if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
446 - throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
447 - }
448 - var obj = {};
449 - for (var i = 0; i < methodNames.length; i++) {
450 - obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
451 - }
452 - return obj;
453 -};
454 -
455 -/**
456 - * All parameters are pretty-printed and concatenated together, then written to the current spec's output.
457 - *
458 - * Be careful not to leave calls to <code>jasmine.log</code> in production code.
459 - */
460 -jasmine.log = function() {
461 - var spec = jasmine.getEnv().currentSpec;
462 - spec.log.apply(spec, arguments);
463 -};
464 -
465 -/**
466 - * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
467 - *
468 - * @example
469 - * // spy example
470 - * var foo = {
471 - * not: function(bool) { return !bool; }
472 - * }
473 - * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
474 - *
475 - * @see jasmine.createSpy
476 - * @param obj
477 - * @param methodName
478 - * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
479 - */
480 -var spyOn = function(obj, methodName) {
481 - return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
482 -};
483 -if (isCommonJS) exports.spyOn = spyOn;
484 -
485 -/**
486 - * Creates a Jasmine spec that will be added to the current suite.
487 - *
488 - * // TODO: pending tests
489 - *
490 - * @example
491 - * it('should be true', function() {
492 - * expect(true).toEqual(true);
493 - * });
494 - *
495 - * @param {String} desc description of this specification
496 - * @param {Function} func defines the preconditions and expectations of the spec
497 - */
498 -var it = function(desc, func) {
499 - return jasmine.getEnv().it(desc, func);
500 -};
501 -if (isCommonJS) exports.it = it;
502 -
503 -/**
504 - * Creates a <em>disabled</em> Jasmine spec.
505 - *
506 - * A convenience method that allows existing specs to be disabled temporarily during development.
507 - *
508 - * @param {String} desc description of this specification
509 - * @param {Function} func defines the preconditions and expectations of the spec
510 - */
511 -var xit = function(desc, func) {
512 - return jasmine.getEnv().xit(desc, func);
513 -};
514 -if (isCommonJS) exports.xit = xit;
515 -
516 -/**
517 - * Starts a chain for a Jasmine expectation.
518 - *
519 - * It is passed an Object that is the actual value and should chain to one of the many
520 - * jasmine.Matchers functions.
521 - *
522 - * @param {Object} actual Actual value to test against and expected value
523 - * @return {jasmine.Matchers}
524 - */
525 -var expect = function(actual) {
526 - return jasmine.getEnv().currentSpec.expect(actual);
527 -};
528 -if (isCommonJS) exports.expect = expect;
529 -
530 -/**
531 - * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
532 - *
533 - * @param {Function} func Function that defines part of a jasmine spec.
534 - */
535 -var runs = function(func) {
536 - jasmine.getEnv().currentSpec.runs(func);
537 -};
538 -if (isCommonJS) exports.runs = runs;
539 -
540 -/**
541 - * Waits a fixed time period before moving to the next block.
542 - *
543 - * @deprecated Use waitsFor() instead
544 - * @param {Number} timeout milliseconds to wait
545 - */
546 -var waits = function(timeout) {
547 - jasmine.getEnv().currentSpec.waits(timeout);
548 -};
549 -if (isCommonJS) exports.waits = waits;
550 -
551 -/**
552 - * Waits for the latchFunction to return true before proceeding to the next block.
553 - *
554 - * @param {Function} latchFunction
555 - * @param {String} optional_timeoutMessage
556 - * @param {Number} optional_timeout
557 - */
558 -var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
559 - jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
560 -};
561 -if (isCommonJS) exports.waitsFor = waitsFor;
562 -
563 -/**
564 - * A function that is called before each spec in a suite.
565 - *
566 - * Used for spec setup, including validating assumptions.
567 - *
568 - * @param {Function} beforeEachFunction
569 - */
570 -var beforeEach = function(beforeEachFunction) {
571 - jasmine.getEnv().beforeEach(beforeEachFunction);
572 -};
573 -if (isCommonJS) exports.beforeEach = beforeEach;
574 -
575 -/**
576 - * A function that is called after each spec in a suite.
577 - *
578 - * Used for restoring any state that is hijacked during spec execution.
579 - *
580 - * @param {Function} afterEachFunction
581 - */
582 -var afterEach = function(afterEachFunction) {
583 - jasmine.getEnv().afterEach(afterEachFunction);
584 -};
585 -if (isCommonJS) exports.afterEach = afterEach;
586 -
587 -/**
588 - * Defines a suite of specifications.
589 - *
590 - * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
591 - * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
592 - * of setup in some tests.
593 - *
594 - * @example
595 - * // TODO: a simple suite
596 - *
597 - * // TODO: a simple suite with a nested describe block
598 - *
599 - * @param {String} description A string, usually the class under test.
600 - * @param {Function} specDefinitions function that defines several specs.
601 - */
602 -var describe = function(description, specDefinitions) {
603 - return jasmine.getEnv().describe(description, specDefinitions);
604 -};
605 -if (isCommonJS) exports.describe = describe;
606 -
607 -/**
608 - * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
609 - *
610 - * @param {String} description A string, usually the class under test.
611 - * @param {Function} specDefinitions function that defines several specs.
612 - */
613 -var xdescribe = function(description, specDefinitions) {
614 - return jasmine.getEnv().xdescribe(description, specDefinitions);
615 -};
616 -if (isCommonJS) exports.xdescribe = xdescribe;
617 -
618 -
619 -// Provide the XMLHttpRequest class for IE 5.x-6.x:
620 -jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
621 - function tryIt(f) {
622 - try {
623 - return f();
624 - } catch(e) {
625 - }
626 - return null;
627 - }
628 -
629 - var xhr = tryIt(function() {
630 - return new ActiveXObject("Msxml2.XMLHTTP.6.0");
631 - }) ||
632 - tryIt(function() {
633 - return new ActiveXObject("Msxml2.XMLHTTP.3.0");
634 - }) ||
635 - tryIt(function() {
636 - return new ActiveXObject("Msxml2.XMLHTTP");
637 - }) ||
638 - tryIt(function() {
639 - return new ActiveXObject("Microsoft.XMLHTTP");
640 - });
641 -
642 - if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
643 -
644 - return xhr;
645 -} : XMLHttpRequest;
646 -/**
647 - * @namespace
648 - */
649 -jasmine.util = {};
650 -
651 -/**
652 - * Declare that a child class inherit it's prototype from the parent class.
653 - *
654 - * @private
655 - * @param {Function} childClass
656 - * @param {Function} parentClass
657 - */
658 -jasmine.util.inherit = function(childClass, parentClass) {
659 - /**
660 - * @private
661 - */
662 - var subclass = function() {
663 - };
664 - subclass.prototype = parentClass.prototype;
665 - childClass.prototype = new subclass();
666 -};
667 -
668 -jasmine.util.formatException = function(e) {
669 - var lineNumber;
670 - if (e.line) {
671 - lineNumber = e.line;
672 - }
673 - else if (e.lineNumber) {
674 - lineNumber = e.lineNumber;
675 - }
676 -
677 - var file;
678 -
679 - if (e.sourceURL) {
680 - file = e.sourceURL;
681 - }
682 - else if (e.fileName) {
683 - file = e.fileName;
684 - }
685 -
686 - var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
687 -
688 - if (file && lineNumber) {
689 - message += ' in ' + file + ' (line ' + lineNumber + ')';
690 - }
691 -
692 - return message;
693 -};
694 -
695 -jasmine.util.htmlEscape = function(str) {
696 - if (!str) return str;
697 - return str.replace(/&/g, '&amp;')
698 - .replace(/</g, '&lt;')
699 - .replace(/>/g, '&gt;');
700 -};
701 -
702 -jasmine.util.argsToArray = function(args) {
703 - var arrayOfArgs = [];
704 - for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
705 - return arrayOfArgs;
706 -};
707 -
708 -jasmine.util.extend = function(destination, source) {
709 - for (var property in source) destination[property] = source[property];
710 - return destination;
711 -};
712 -
713 -/**
714 - * Environment for Jasmine
715 - *
716 - * @constructor
717 - */
718 -jasmine.Env = function() {
719 - this.currentSpec = null;
720 - this.currentSuite = null;
721 - this.currentRunner_ = new jasmine.Runner(this);
722 -
723 - this.reporter = new jasmine.MultiReporter();
724 -
725 - this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
726 - this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
727 - this.lastUpdate = 0;
728 - this.specFilter = function() {
729 - return true;
730 - };
731 -
732 - this.nextSpecId_ = 0;
733 - this.nextSuiteId_ = 0;
734 - this.equalityTesters_ = [];
735 -
736 - // wrap matchers
737 - this.matchersClass = function() {
738 - jasmine.Matchers.apply(this, arguments);
739 - };
740 - jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
741 -
742 - jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
743 -};
744 -
745 -
746 -jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
747 -jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
748 -jasmine.Env.prototype.setInterval = jasmine.setInterval;
749 -jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
750 -
751 -/**
752 - * @returns an object containing jasmine version build info, if set.
753 - */
754 -jasmine.Env.prototype.version = function () {
755 - if (jasmine.version_) {
756 - return jasmine.version_;
757 - } else {
758 - throw new Error('Version not set');
759 - }
760 -};
761 -
762 -/**
763 - * @returns string containing jasmine version build info, if set.
764 - */
765 -jasmine.Env.prototype.versionString = function() {
766 - if (!jasmine.version_) {
767 - return "version unknown";
768 - }
769 -
770 - var version = this.version();
771 - var versionString = version.major + "." + version.minor + "." + version.build;
772 - if (version.release_candidate) {
773 - versionString += ".rc" + version.release_candidate;
774 - }
775 - versionString += " revision " + version.revision;
776 - return versionString;
777 -};
778 -
779 -/**
780 - * @returns a sequential integer starting at 0
781 - */
782 -jasmine.Env.prototype.nextSpecId = function () {
783 - return this.nextSpecId_++;
784 -};
785 -
786 -/**
787 - * @returns a sequential integer starting at 0
788 - */
789 -jasmine.Env.prototype.nextSuiteId = function () {
790 - return this.nextSuiteId_++;
791 -};
792 -
793 -/**
794 - * Register a reporter to receive status updates from Jasmine.
795 - * @param {jasmine.Reporter} reporter An object which will receive status updates.
796 - */
797 -jasmine.Env.prototype.addReporter = function(reporter) {
798 - this.reporter.addReporter(reporter);
799 -};
800 -
801 -jasmine.Env.prototype.execute = function() {
802 - this.currentRunner_.execute();
803 -};
804 -
805 -jasmine.Env.prototype.describe = function(description, specDefinitions) {
806 - var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
807 -
808 - var parentSuite = this.currentSuite;
809 - if (parentSuite) {
810 - parentSuite.add(suite);
811 - } else {
812 - this.currentRunner_.add(suite);
813 - }
814 -
815 - this.currentSuite = suite;
816 -
817 - var declarationError = null;
818 - try {
819 - specDefinitions.call(suite);
820 - } catch(e) {
821 - declarationError = e;
822 - }
823 -
824 - if (declarationError) {
825 - this.it("encountered a declaration exception", function() {
826 - throw declarationError;
827 - });
828 - }
829 -
830 - this.currentSuite = parentSuite;
831 -
832 - return suite;
833 -};
834 -
835 -jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
836 - if (this.currentSuite) {
837 - this.currentSuite.beforeEach(beforeEachFunction);
838 - } else {
839 - this.currentRunner_.beforeEach(beforeEachFunction);
840 - }
841 -};
842 -
843 -jasmine.Env.prototype.currentRunner = function () {
844 - return this.currentRunner_;
845 -};
846 -
847 -jasmine.Env.prototype.afterEach = function(afterEachFunction) {
848 - if (this.currentSuite) {
849 - this.currentSuite.afterEach(afterEachFunction);
850 - } else {
851 - this.currentRunner_.afterEach(afterEachFunction);
852 - }
853 -
854 -};
855 -
856 -jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
857 - return {
858 - execute: function() {
859 - }
860 - };
861 -};
862 -
863 -jasmine.Env.prototype.it = function(description, func) {
864 - var spec = new jasmine.Spec(this, this.currentSuite, description);
865 - this.currentSuite.add(spec);
866 - this.currentSpec = spec;
867 -
868 - if (func) {
869 - spec.runs(func);
870 - }
871 -
872 - return spec;
873 -};
874 -
875 -jasmine.Env.prototype.xit = function(desc, func) {
876 - return {
877 - id: this.nextSpecId(),
878 - runs: function() {
879 - }
880 - };
881 -};
882 -
883 -jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
884 - if (a.source != b.source)
885 - mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
886 -
887 - if (a.ignoreCase != b.ignoreCase)
888 - mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
889 -
890 - if (a.global != b.global)
891 - mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
892 -
893 - if (a.multiline != b.multiline)
894 - mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
895 -
896 - if (a.sticky != b.sticky)
897 - mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
898 -
899 - return (mismatchValues.length === 0);
900 -};
901 -
902 -jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
903 - if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
904 - return true;
905 - }
906 -
907 - a.__Jasmine_been_here_before__ = b;
908 - b.__Jasmine_been_here_before__ = a;
909 -
910 - var hasKey = function(obj, keyName) {
911 - return obj !== null && obj[keyName] !== jasmine.undefined;
912 - };
913 -
914 - for (var property in b) {
915 - if (!hasKey(a, property) && hasKey(b, property)) {
916 - mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
917 - }
918 - }
919 - for (property in a) {
920 - if (!hasKey(b, property) && hasKey(a, property)) {
921 - mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
922 - }
923 - }
924 - for (property in b) {
925 - if (property == '__Jasmine_been_here_before__') continue;
926 - if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
927 - mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
928 - }
929 - }
930 -
931 - if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
932 - mismatchValues.push("arrays were not the same length");
933 - }
934 -
935 - delete a.__Jasmine_been_here_before__;
936 - delete b.__Jasmine_been_here_before__;
937 - return (mismatchKeys.length === 0 && mismatchValues.length === 0);
938 -};
939 -
940 -jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
941 - mismatchKeys = mismatchKeys || [];
942 - mismatchValues = mismatchValues || [];
943 -
944 - for (var i = 0; i < this.equalityTesters_.length; i++) {
945 - var equalityTester = this.equalityTesters_[i];
946 - var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
947 - if (result !== jasmine.undefined) return result;
948 - }
949 -
950 - if (a === b) return true;
951 -
952 - if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
953 - return (a == jasmine.undefined && b == jasmine.undefined);
954 - }
955 -
956 - if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
957 - return a === b;
958 - }
959 -
960 - if (a instanceof Date && b instanceof Date) {
961 - return a.getTime() == b.getTime();
962 - }
963 -
964 - if (a.jasmineMatches) {
965 - return a.jasmineMatches(b);
966 - }
967 -
968 - if (b.jasmineMatches) {
969 - return b.jasmineMatches(a);
970 - }
971 -
972 - if (a instanceof jasmine.Matchers.ObjectContaining) {
973 - return a.matches(b);
974 - }
975 -
976 - if (b instanceof jasmine.Matchers.ObjectContaining) {
977 - return b.matches(a);
978 - }
979 -
980 - if (jasmine.isString_(a) && jasmine.isString_(b)) {
981 - return (a == b);
982 - }
983 -
984 - if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
985 - return (a == b);
986 - }
987 -
988 - if (a instanceof RegExp && b instanceof RegExp) {
989 - return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
990 - }
991 -
992 - if (typeof a === "object" && typeof b === "object") {
993 - return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
994 - }
995 -
996 - //Straight check
997 - return (a === b);
998 -};
999 -
1000 -jasmine.Env.prototype.contains_ = function(haystack, needle) {
1001 - if (jasmine.isArray_(haystack)) {
1002 - for (var i = 0; i < haystack.length; i++) {
1003 - if (this.equals_(haystack[i], needle)) return true;
1004 - }
1005 - return false;
1006 - }
1007 - return haystack.indexOf(needle) >= 0;
1008 -};
1009 -
1010 -jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
1011 - this.equalityTesters_.push(equalityTester);
1012 -};
1013 -/** No-op base class for Jasmine reporters.
1014 - *
1015 - * @constructor
1016 - */
1017 -jasmine.Reporter = function() {
1018 -};
1019 -
1020 -//noinspection JSUnusedLocalSymbols
1021 -jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
1022 -};
1023 -
1024 -//noinspection JSUnusedLocalSymbols
1025 -jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
1026 -};
1027 -
1028 -//noinspection JSUnusedLocalSymbols
1029 -jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
1030 -};
1031 -
1032 -//noinspection JSUnusedLocalSymbols
1033 -jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
1034 -};
1035 -
1036 -//noinspection JSUnusedLocalSymbols
1037 -jasmine.Reporter.prototype.reportSpecResults = function(spec) {
1038 -};
1039 -
1040 -//noinspection JSUnusedLocalSymbols
1041 -jasmine.Reporter.prototype.log = function(str) {
1042 -};
1043 -
1044 -/**
1045 - * Blocks are functions with executable code that make up a spec.
1046 - *
1047 - * @constructor
1048 - * @param {jasmine.Env} env
1049 - * @param {Function} func
1050 - * @param {jasmine.Spec} spec
1051 - */
1052 -jasmine.Block = function(env, func, spec) {
1053 - this.env = env;
1054 - this.func = func;
1055 - this.spec = spec;
1056 -};
1057 -
1058 -jasmine.Block.prototype.execute = function(onComplete) {
1059 - if (!jasmine.CATCH_EXCEPTIONS) {
1060 - this.func.apply(this.spec);
1061 - }
1062 - else {
1063 - try {
1064 - this.func.apply(this.spec);
1065 - } catch (e) {
1066 - this.spec.fail(e);
1067 - }
1068 - }
1069 - onComplete();
1070 -};
1071 -/** JavaScript API reporter.
1072 - *
1073 - * @constructor
1074 - */
1075 -jasmine.JsApiReporter = function() {
1076 - this.started = false;
1077 - this.finished = false;
1078 - this.suites_ = [];
1079 - this.results_ = {};
1080 -};
1081 -
1082 -jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
1083 - this.started = true;
1084 - var suites = runner.topLevelSuites();
1085 - for (var i = 0; i < suites.length; i++) {
1086 - var suite = suites[i];
1087 - this.suites_.push(this.summarize_(suite));
1088 - }
1089 -};
1090 -
1091 -jasmine.JsApiReporter.prototype.suites = function() {
1092 - return this.suites_;
1093 -};
1094 -
1095 -jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
1096 - var isSuite = suiteOrSpec instanceof jasmine.Suite;
1097 - var summary = {
1098 - id: suiteOrSpec.id,
1099 - name: suiteOrSpec.description,
1100 - type: isSuite ? 'suite' : 'spec',
1101 - children: []
1102 - };
1103 -
1104 - if (isSuite) {
1105 - var children = suiteOrSpec.children();
1106 - for (var i = 0; i < children.length; i++) {
1107 - summary.children.push(this.summarize_(children[i]));
1108 - }
1109 - }
1110 - return summary;
1111 -};
1112 -
1113 -jasmine.JsApiReporter.prototype.results = function() {
1114 - return this.results_;
1115 -};
1116 -
1117 -jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
1118 - return this.results_[specId];
1119 -};
1120 -
1121 -//noinspection JSUnusedLocalSymbols
1122 -jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
1123 - this.finished = true;
1124 -};
1125 -
1126 -//noinspection JSUnusedLocalSymbols
1127 -jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
1128 -};
1129 -
1130 -//noinspection JSUnusedLocalSymbols
1131 -jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
1132 - this.results_[spec.id] = {
1133 - messages: spec.results().getItems(),
1134 - result: spec.results().failedCount > 0 ? "failed" : "passed"
1135 - };
1136 -};
1137 -
1138 -//noinspection JSUnusedLocalSymbols
1139 -jasmine.JsApiReporter.prototype.log = function(str) {
1140 -};
1141 -
1142 -jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
1143 - var results = {};
1144 - for (var i = 0; i < specIds.length; i++) {
1145 - var specId = specIds[i];
1146 - results[specId] = this.summarizeResult_(this.results_[specId]);
1147 - }
1148 - return results;
1149 -};
1150 -
1151 -jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
1152 - var summaryMessages = [];
1153 - var messagesLength = result.messages.length;
1154 - for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
1155 - var resultMessage = result.messages[messageIndex];
1156 - summaryMessages.push({
1157 - text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
1158 - passed: resultMessage.passed ? resultMessage.passed() : true,
1159 - type: resultMessage.type,
1160 - message: resultMessage.message,
1161 - trace: {
1162 - stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
1163 - }
1164 - });
1165 - }
1166 -
1167 - return {
1168 - result : result.result,
1169 - messages : summaryMessages
1170 - };
1171 -};
1172 -
1173 -/**
1174 - * @constructor
1175 - * @param {jasmine.Env} env
1176 - * @param actual
1177 - * @param {jasmine.Spec} spec
1178 - */
1179 -jasmine.Matchers = function(env, actual, spec, opt_isNot) {
1180 - this.env = env;
1181 - this.actual = actual;
1182 - this.spec = spec;
1183 - this.isNot = opt_isNot || false;
1184 - this.reportWasCalled_ = false;
1185 -};
1186 -
1187 -// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
1188 -jasmine.Matchers.pp = function(str) {
1189 - throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
1190 -};
1191 -
1192 -// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
1193 -jasmine.Matchers.prototype.report = function(result, failing_message, details) {
1194 - throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
1195 -};
1196 -
1197 -jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
1198 - for (var methodName in prototype) {
1199 - if (methodName == 'report') continue;
1200 - var orig = prototype[methodName];
1201 - matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
1202 - }
1203 -};
1204 -
1205 -jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
1206 - return function() {
1207 - var matcherArgs = jasmine.util.argsToArray(arguments);
1208 - var result = matcherFunction.apply(this, arguments);
1209 -
1210 - if (this.isNot) {
1211 - result = !result;
1212 - }
1213 -
1214 - if (this.reportWasCalled_) return result;
1215 -
1216 - var message;
1217 - if (!result) {
1218 - if (this.message) {
1219 - message = this.message.apply(this, arguments);
1220 - if (jasmine.isArray_(message)) {
1221 - message = message[this.isNot ? 1 : 0];
1222 - }
1223 - } else {
1224 - var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
1225 - message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
1226 - if (matcherArgs.length > 0) {
1227 - for (var i = 0; i < matcherArgs.length; i++) {
1228 - if (i > 0) message += ",";
1229 - message += " " + jasmine.pp(matcherArgs[i]);
1230 - }
1231 - }
1232 - message += ".";
1233 - }
1234 - }
1235 - var expectationResult = new jasmine.ExpectationResult({
1236 - matcherName: matcherName,
1237 - passed: result,
1238 - expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
1239 - actual: this.actual,
1240 - message: message
1241 - });
1242 - this.spec.addMatcherResult(expectationResult);
1243 - return jasmine.undefined;
1244 - };
1245 -};
1246 -
1247 -
1248 -
1249 -
1250 -/**
1251 - * toBe: compares the actual to the expected using ===
1252 - * @param expected
1253 - */
1254 -jasmine.Matchers.prototype.toBe = function(expected) {
1255 - return this.actual === expected;
1256 -};
1257 -
1258 -/**
1259 - * toNotBe: compares the actual to the expected using !==
1260 - * @param expected
1261 - * @deprecated as of 1.0. Use not.toBe() instead.
1262 - */
1263 -jasmine.Matchers.prototype.toNotBe = function(expected) {
1264 - return this.actual !== expected;
1265 -};
1266 -
1267 -/**
1268 - * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
1269 - *
1270 - * @param expected
1271 - */
1272 -jasmine.Matchers.prototype.toEqual = function(expected) {
1273 - return this.env.equals_(this.actual, expected);
1274 -};
1275 -
1276 -/**
1277 - * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
1278 - * @param expected
1279 - * @deprecated as of 1.0. Use not.toEqual() instead.
1280 - */
1281 -jasmine.Matchers.prototype.toNotEqual = function(expected) {
1282 - return !this.env.equals_(this.actual, expected);
1283 -};
1284 -
1285 -/**
1286 - * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
1287 - * a pattern or a String.
1288 - *
1289 - * @param expected
1290 - */
1291 -jasmine.Matchers.prototype.toMatch = function(expected) {
1292 - return new RegExp(expected).test(this.actual);
1293 -};
1294 -
1295 -/**
1296 - * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
1297 - * @param expected
1298 - * @deprecated as of 1.0. Use not.toMatch() instead.
1299 - */
1300 -jasmine.Matchers.prototype.toNotMatch = function(expected) {
1301 - return !(new RegExp(expected).test(this.actual));
1302 -};
1303 -
1304 -/**
1305 - * Matcher that compares the actual to jasmine.undefined.
1306 - */
1307 -jasmine.Matchers.prototype.toBeDefined = function() {
1308 - return (this.actual !== jasmine.undefined);
1309 -};
1310 -
1311 -/**
1312 - * Matcher that compares the actual to jasmine.undefined.
1313 - */
1314 -jasmine.Matchers.prototype.toBeUndefined = function() {
1315 - return (this.actual === jasmine.undefined);
1316 -};
1317 -
1318 -/**
1319 - * Matcher that compares the actual to null.
1320 - */
1321 -jasmine.Matchers.prototype.toBeNull = function() {
1322 - return (this.actual === null);
1323 -};
1324 -
1325 -/**
1326 - * Matcher that compares the actual to NaN.
1327 - */
1328 -jasmine.Matchers.prototype.toBeNaN = function() {
1329 - this.message = function() {
1330 - return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
1331 - };
1332 -
1333 - return (this.actual !== this.actual);
1334 -};
1335 -
1336 -/**
1337 - * Matcher that boolean not-nots the actual.
1338 - */
1339 -jasmine.Matchers.prototype.toBeTruthy = function() {
1340 - return !!this.actual;
1341 -};
1342 -
1343 -
1344 -/**
1345 - * Matcher that boolean nots the actual.
1346 - */
1347 -jasmine.Matchers.prototype.toBeFalsy = function() {
1348 - return !this.actual;
1349 -};
1350 -
1351 -
1352 -/**
1353 - * Matcher that checks to see if the actual, a Jasmine spy, was called.
1354 - */
1355 -jasmine.Matchers.prototype.toHaveBeenCalled = function() {
1356 - if (arguments.length > 0) {
1357 - throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
1358 - }
1359 -
1360 - if (!jasmine.isSpy(this.actual)) {
1361 - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
1362 - }
1363 -
1364 - this.message = function() {
1365 - return [
1366 - "Expected spy " + this.actual.identity + " to have been called.",
1367 - "Expected spy " + this.actual.identity + " not to have been called."
1368 - ];
1369 - };
1370 -
1371 - return this.actual.wasCalled;
1372 -};
1373 -
1374 -/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
1375 -jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled;
1376 -
1377 -/**
1378 - * Matcher that checks to see if the actual, a Jasmine spy, was not called.
1379 - *
1380 - * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
1381 - */
1382 -jasmine.Matchers.prototype.wasNotCalled = function() {
1383 - if (arguments.length > 0) {
1384 - throw new Error('wasNotCalled does not take arguments');
1385 - }
1386 -
1387 - if (!jasmine.isSpy(this.actual)) {
1388 - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
1389 - }
1390 -
1391 - this.message = function() {
1392 - return [
1393 - "Expected spy " + this.actual.identity + " to not have been called.",
1394 - "Expected spy " + this.actual.identity + " to have been called."
1395 - ];
1396 - };
1397 -
1398 - return !this.actual.wasCalled;
1399 -};
1400 -
1401 -/**
1402 - * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
1403 - *
1404 - * @example
1405 - *
1406 - */
1407 -jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
1408 - var expectedArgs = jasmine.util.argsToArray(arguments);
1409 - if (!jasmine.isSpy(this.actual)) {
1410 - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
1411 - }
1412 - this.message = function() {
1413 - var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
1414 - var positiveMessage = "";
1415 - if (this.actual.callCount === 0) {
1416 - positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
1417 - } else {
1418 - positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
1419 - }
1420 - return [positiveMessage, invertedMessage];
1421 - };
1422 -
1423 - return this.env.contains_(this.actual.argsForCall, expectedArgs);
1424 -};
1425 -
1426 -/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
1427 -jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith;
1428 -
1429 -/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
1430 -jasmine.Matchers.prototype.wasNotCalledWith = function() {
1431 - var expectedArgs = jasmine.util.argsToArray(arguments);
1432 - if (!jasmine.isSpy(this.actual)) {
1433 - throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
1434 - }
1435 -
1436 - this.message = function() {
1437 - return [
1438 - "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
1439 - "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
1440 - ];
1441 - };
1442 -
1443 - return !this.env.contains_(this.actual.argsForCall, expectedArgs);
1444 -};
1445 -
1446 -/**
1447 - * Matcher that checks that the expected item is an element in the actual Array.
1448 - *
1449 - * @param {Object} expected
1450 - */
1451 -jasmine.Matchers.prototype.toContain = function(expected) {
1452 - return this.env.contains_(this.actual, expected);
1453 -};
1454 -
1455 -/**
1456 - * Matcher that checks that the expected item is NOT an element in the actual Array.
1457 - *
1458 - * @param {Object} expected
1459 - * @deprecated as of 1.0. Use not.toContain() instead.
1460 - */
1461 -jasmine.Matchers.prototype.toNotContain = function(expected) {
1462 - return !this.env.contains_(this.actual, expected);
1463 -};
1464 -
1465 -jasmine.Matchers.prototype.toBeLessThan = function(expected) {
1466 - return this.actual < expected;
1467 -};
1468 -
1469 -jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
1470 - return this.actual > expected;
1471 -};
1472 -
1473 -/**
1474 - * Matcher that checks that the expected item is equal to the actual item
1475 - * up to a given level of decimal precision (default 2).
1476 - *
1477 - * @param {Number} expected
1478 - * @param {Number} precision, as number of decimal places
1479 - */
1480 -jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
1481 - if (!(precision === 0)) {
1482 - precision = precision || 2;
1483 - }
1484 - return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
1485 -};
1486 -
1487 -/**
1488 - * Matcher that checks that the expected exception was thrown by the actual.
1489 - *
1490 - * @param {String} [expected]
1491 - */
1492 -jasmine.Matchers.prototype.toThrow = function(expected) {
1493 - var result = false;
1494 - var exception;
1495 - if (typeof this.actual != 'function') {
1496 - throw new Error('Actual is not a function');
1497 - }
1498 - try {
1499 - this.actual();
1500 - } catch (e) {
1501 - exception = e;
1502 - }
1503 - if (exception) {
1504 - result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
1505 - }
1506 -
1507 - var not = this.isNot ? "not " : "";
1508 -
1509 - this.message = function() {
1510 - if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
1511 - return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
1512 - } else {
1513 - return "Expected function to throw an exception.";
1514 - }
1515 - };
1516 -
1517 - return result;
1518 -};
1519 -
1520 -jasmine.Matchers.Any = function(expectedClass) {
1521 - this.expectedClass = expectedClass;
1522 -};
1523 -
1524 -jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
1525 - if (this.expectedClass == String) {
1526 - return typeof other == 'string' || other instanceof String;
1527 - }
1528 -
1529 - if (this.expectedClass == Number) {
1530 - return typeof other == 'number' || other instanceof Number;
1531 - }
1532 -
1533 - if (this.expectedClass == Function) {
1534 - return typeof other == 'function' || other instanceof Function;
1535 - }
1536 -
1537 - if (this.expectedClass == Object) {
1538 - return typeof other == 'object';
1539 - }
1540 -
1541 - return other instanceof this.expectedClass;
1542 -};
1543 -
1544 -jasmine.Matchers.Any.prototype.jasmineToString = function() {
1545 - return '<jasmine.any(' + this.expectedClass + ')>';
1546 -};
1547 -
1548 -jasmine.Matchers.ObjectContaining = function (sample) {
1549 - this.sample = sample;
1550 -};
1551 -
1552 -jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
1553 - mismatchKeys = mismatchKeys || [];
1554 - mismatchValues = mismatchValues || [];
1555 -
1556 - var env = jasmine.getEnv();
1557 -
1558 - var hasKey = function(obj, keyName) {
1559 - return obj != null && obj[keyName] !== jasmine.undefined;
1560 - };
1561 -
1562 - for (var property in this.sample) {
1563 - if (!hasKey(other, property) && hasKey(this.sample, property)) {
1564 - mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
1565 - }
1566 - else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
1567 - mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
1568 - }
1569 - }
1570 -
1571 - return (mismatchKeys.length === 0 && mismatchValues.length === 0);
1572 -};
1573 -
1574 -jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
1575 - return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
1576 -};
1577 -// Mock setTimeout, clearTimeout
1578 -// Contributed by Pivotal Computer Systems, www.pivotalsf.com
1579 -
1580 -jasmine.FakeTimer = function() {
1581 - this.reset();
1582 -
1583 - var self = this;
1584 - self.setTimeout = function(funcToCall, millis) {
1585 - self.timeoutsMade++;
1586 - self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
1587 - return self.timeoutsMade;
1588 - };
1589 -
1590 - self.setInterval = function(funcToCall, millis) {
1591 - self.timeoutsMade++;
1592 - self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
1593 - return self.timeoutsMade;
1594 - };
1595 -
1596 - self.clearTimeout = function(timeoutKey) {
1597 - self.scheduledFunctions[timeoutKey] = jasmine.undefined;
1598 - };
1599 -
1600 - self.clearInterval = function(timeoutKey) {
1601 - self.scheduledFunctions[timeoutKey] = jasmine.undefined;
1602 - };
1603 -
1604 -};
1605 -
1606 -jasmine.FakeTimer.prototype.reset = function() {
1607 - this.timeoutsMade = 0;
1608 - this.scheduledFunctions = {};
1609 - this.nowMillis = 0;
1610 -};
1611 -
1612 -jasmine.FakeTimer.prototype.tick = function(millis) {
1613 - var oldMillis = this.nowMillis;
1614 - var newMillis = oldMillis + millis;
1615 - this.runFunctionsWithinRange(oldMillis, newMillis);
1616 - this.nowMillis = newMillis;
1617 -};
1618 -
1619 -jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
1620 - var scheduledFunc;
1621 - var funcsToRun = [];
1622 - for (var timeoutKey in this.scheduledFunctions) {
1623 - scheduledFunc = this.scheduledFunctions[timeoutKey];
1624 - if (scheduledFunc != jasmine.undefined &&
1625 - scheduledFunc.runAtMillis >= oldMillis &&
1626 - scheduledFunc.runAtMillis <= nowMillis) {
1627 - funcsToRun.push(scheduledFunc);
1628 - this.scheduledFunctions[timeoutKey] = jasmine.undefined;
1629 - }
1630 - }
1631 -
1632 - if (funcsToRun.length > 0) {
1633 - funcsToRun.sort(function(a, b) {
1634 - return a.runAtMillis - b.runAtMillis;
1635 - });
1636 - for (var i = 0; i < funcsToRun.length; ++i) {
1637 - try {
1638 - var funcToRun = funcsToRun[i];
1639 - this.nowMillis = funcToRun.runAtMillis;
1640 - funcToRun.funcToCall();
1641 - if (funcToRun.recurring) {
1642 - this.scheduleFunction(funcToRun.timeoutKey,
1643 - funcToRun.funcToCall,
1644 - funcToRun.millis,
1645 - true);
1646 - }
1647 - } catch(e) {
1648 - }
1649 - }
1650 - this.runFunctionsWithinRange(oldMillis, nowMillis);
1651 - }
1652 -};
1653 -
1654 -jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
1655 - this.scheduledFunctions[timeoutKey] = {
1656 - runAtMillis: this.nowMillis + millis,
1657 - funcToCall: funcToCall,
1658 - recurring: recurring,
1659 - timeoutKey: timeoutKey,
1660 - millis: millis
1661 - };
1662 -};
1663 -
1664 -/**
1665 - * @namespace
1666 - */
1667 -jasmine.Clock = {
1668 - defaultFakeTimer: new jasmine.FakeTimer(),
1669 -
1670 - reset: function() {
1671 - jasmine.Clock.assertInstalled();
1672 - jasmine.Clock.defaultFakeTimer.reset();
1673 - },
1674 -
1675 - tick: function(millis) {
1676 - jasmine.Clock.assertInstalled();
1677 - jasmine.Clock.defaultFakeTimer.tick(millis);
1678 - },
1679 -
1680 - runFunctionsWithinRange: function(oldMillis, nowMillis) {
1681 - jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
1682 - },
1683 -
1684 - scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
1685 - jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
1686 - },
1687 -
1688 - useMock: function() {
1689 - if (!jasmine.Clock.isInstalled()) {
1690 - var spec = jasmine.getEnv().currentSpec;
1691 - spec.after(jasmine.Clock.uninstallMock);
1692 -
1693 - jasmine.Clock.installMock();
1694 - }
1695 - },
1696 -
1697 - installMock: function() {
1698 - jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
1699 - },
1700 -
1701 - uninstallMock: function() {
1702 - jasmine.Clock.assertInstalled();
1703 - jasmine.Clock.installed = jasmine.Clock.real;
1704 - },
1705 -
1706 - real: {
1707 - setTimeout: jasmine.getGlobal().setTimeout,
1708 - clearTimeout: jasmine.getGlobal().clearTimeout,
1709 - setInterval: jasmine.getGlobal().setInterval,
1710 - clearInterval: jasmine.getGlobal().clearInterval
1711 - },
1712 -
1713 - assertInstalled: function() {
1714 - if (!jasmine.Clock.isInstalled()) {
1715 - throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
1716 - }
1717 - },
1718 -
1719 - isInstalled: function() {
1720 - return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
1721 - },
1722 -
1723 - installed: null
1724 -};
1725 -jasmine.Clock.installed = jasmine.Clock.real;
1726 -
1727 -//else for IE support
1728 -jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
1729 - if (jasmine.Clock.installed.setTimeout.apply) {
1730 - return jasmine.Clock.installed.setTimeout.apply(this, arguments);
1731 - } else {
1732 - return jasmine.Clock.installed.setTimeout(funcToCall, millis);
1733 - }
1734 -};
1735 -
1736 -jasmine.getGlobal().setInterval = function(funcToCall, millis) {
1737 - if (jasmine.Clock.installed.setInterval.apply) {
1738 - return jasmine.Clock.installed.setInterval.apply(this, arguments);
1739 - } else {
1740 - return jasmine.Clock.installed.setInterval(funcToCall, millis);
1741 - }
1742 -};
1743 -
1744 -jasmine.getGlobal().clearTimeout = function(timeoutKey) {
1745 - if (jasmine.Clock.installed.clearTimeout.apply) {
1746 - return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
1747 - } else {
1748 - return jasmine.Clock.installed.clearTimeout(timeoutKey);
1749 - }
1750 -};
1751 -
1752 -jasmine.getGlobal().clearInterval = function(timeoutKey) {
1753 - if (jasmine.Clock.installed.clearTimeout.apply) {
1754 - return jasmine.Clock.installed.clearInterval.apply(this, arguments);
1755 - } else {
1756 - return jasmine.Clock.installed.clearInterval(timeoutKey);
1757 - }
1758 -};
1759 -
1760 -/**
1761 - * @constructor
1762 - */
1763 -jasmine.MultiReporter = function() {
1764 - this.subReporters_ = [];
1765 -};
1766 -jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
1767 -
1768 -jasmine.MultiReporter.prototype.addReporter = function(reporter) {
1769 - this.subReporters_.push(reporter);
1770 -};
1771 -
1772 -(function() {
1773 - var functionNames = [
1774 - "reportRunnerStarting",
1775 - "reportRunnerResults",
1776 - "reportSuiteResults",
1777 - "reportSpecStarting",
1778 - "reportSpecResults",
1779 - "log"
1780 - ];
1781 - for (var i = 0; i < functionNames.length; i++) {
1782 - var functionName = functionNames[i];
1783 - jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
1784 - return function() {
1785 - for (var j = 0; j < this.subReporters_.length; j++) {
1786 - var subReporter = this.subReporters_[j];
1787 - if (subReporter[functionName]) {
1788 - subReporter[functionName].apply(subReporter, arguments);
1789 - }
1790 - }
1791 - };
1792 - })(functionName);
1793 - }
1794 -})();
1795 -/**
1796 - * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
1797 - *
1798 - * @constructor
1799 - */
1800 -jasmine.NestedResults = function() {
1801 - /**
1802 - * The total count of results
1803 - */
1804 - this.totalCount = 0;
1805 - /**
1806 - * Number of passed results
1807 - */
1808 - this.passedCount = 0;
1809 - /**
1810 - * Number of failed results
1811 - */
1812 - this.failedCount = 0;
1813 - /**
1814 - * Was this suite/spec skipped?
1815 - */
1816 - this.skipped = false;
1817 - /**
1818 - * @ignore
1819 - */
1820 - this.items_ = [];
1821 -};
1822 -
1823 -/**
1824 - * Roll up the result counts.
1825 - *
1826 - * @param result
1827 - */
1828 -jasmine.NestedResults.prototype.rollupCounts = function(result) {
1829 - this.totalCount += result.totalCount;
1830 - this.passedCount += result.passedCount;
1831 - this.failedCount += result.failedCount;
1832 -};
1833 -
1834 -/**
1835 - * Adds a log message.
1836 - * @param values Array of message parts which will be concatenated later.
1837 - */
1838 -jasmine.NestedResults.prototype.log = function(values) {
1839 - this.items_.push(new jasmine.MessageResult(values));
1840 -};
1841 -
1842 -/**
1843 - * Getter for the results: message & results.
1844 - */
1845 -jasmine.NestedResults.prototype.getItems = function() {
1846 - return this.items_;
1847 -};
1848 -
1849 -/**
1850 - * Adds a result, tracking counts (total, passed, & failed)
1851 - * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
1852 - */
1853 -jasmine.NestedResults.prototype.addResult = function(result) {
1854 - if (result.type != 'log') {
1855 - if (result.items_) {
1856 - this.rollupCounts(result);
1857 - } else {
1858 - this.totalCount++;
1859 - if (result.passed()) {
1860 - this.passedCount++;
1861 - } else {
1862 - this.failedCount++;
1863 - }
1864 - }
1865 - }
1866 - this.items_.push(result);
1867 -};
1868 -
1869 -/**
1870 - * @returns {Boolean} True if <b>everything</b> below passed
1871 - */
1872 -jasmine.NestedResults.prototype.passed = function() {
1873 - return this.passedCount === this.totalCount;
1874 -};
1875 -/**
1876 - * Base class for pretty printing for expectation results.
1877 - */
1878 -jasmine.PrettyPrinter = function() {
1879 - this.ppNestLevel_ = 0;
1880 -};
1881 -
1882 -/**
1883 - * Formats a value in a nice, human-readable string.
1884 - *
1885 - * @param value
1886 - */
1887 -jasmine.PrettyPrinter.prototype.format = function(value) {
1888 - this.ppNestLevel_++;
1889 - try {
1890 - if (value === jasmine.undefined) {
1891 - this.emitScalar('undefined');
1892 - } else if (value === null) {
1893 - this.emitScalar('null');
1894 - } else if (value === jasmine.getGlobal()) {
1895 - this.emitScalar('<global>');
1896 - } else if (value.jasmineToString) {
1897 - this.emitScalar(value.jasmineToString());
1898 - } else if (typeof value === 'string') {
1899 - this.emitString(value);
1900 - } else if (jasmine.isSpy(value)) {
1901 - this.emitScalar("spy on " + value.identity);
1902 - } else if (value instanceof RegExp) {
1903 - this.emitScalar(value.toString());
1904 - } else if (typeof value === 'function') {
1905 - this.emitScalar('Function');
1906 - } else if (typeof value.nodeType === 'number') {
1907 - this.emitScalar('HTMLNode');
1908 - } else if (value instanceof Date) {
1909 - this.emitScalar('Date(' + value + ')');
1910 - } else if (value.__Jasmine_been_here_before__) {
1911 - this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
1912 - } else if (jasmine.isArray_(value) || typeof value == 'object') {
1913 - value.__Jasmine_been_here_before__ = true;
1914 - if (jasmine.isArray_(value)) {
1915 - this.emitArray(value);
1916 - } else {
1917 - this.emitObject(value);
1918 - }
1919 - delete value.__Jasmine_been_here_before__;
1920 - } else {
1921 - this.emitScalar(value.toString());
1922 - }
1923 - } finally {
1924 - this.ppNestLevel_--;
1925 - }
1926 -};
1927 -
1928 -jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1929 - for (var property in obj) {
1930 - if (!obj.hasOwnProperty(property)) continue;
1931 - if (property == '__Jasmine_been_here_before__') continue;
1932 - fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
1933 - obj.__lookupGetter__(property) !== null) : false);
1934 - }
1935 -};
1936 -
1937 -jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
1938 -jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
1939 -jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
1940 -jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
1941 -
1942 -jasmine.StringPrettyPrinter = function() {
1943 - jasmine.PrettyPrinter.call(this);
1944 -
1945 - this.string = '';
1946 -};
1947 -jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
1948 -
1949 -jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
1950 - this.append(value);
1951 -};
1952 -
1953 -jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
1954 - this.append("'" + value + "'");
1955 -};
1956 -
1957 -jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
1958 - if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
1959 - this.append("Array");
1960 - return;
1961 - }
1962 -
1963 - this.append('[ ');
1964 - for (var i = 0; i < array.length; i++) {
1965 - if (i > 0) {
1966 - this.append(', ');
1967 - }
1968 - this.format(array[i]);
1969 - }
1970 - this.append(' ]');
1971 -};
1972 -
1973 -jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
1974 - if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
1975 - this.append("Object");
1976 - return;
1977 - }
1978 -
1979 - var self = this;
1980 - this.append('{ ');
1981 - var first = true;
1982 -
1983 - this.iterateObject(obj, function(property, isGetter) {
1984 - if (first) {
1985 - first = false;
1986 - } else {
1987 - self.append(', ');
1988 - }
1989 -
1990 - self.append(property);
1991 - self.append(' : ');
1992 - if (isGetter) {
1993 - self.append('<getter>');
1994 - } else {
1995 - self.format(obj[property]);
1996 - }
1997 - });
1998 -
1999 - this.append(' }');
2000 -};
2001 -
2002 -jasmine.StringPrettyPrinter.prototype.append = function(value) {
2003 - this.string += value;
2004 -};
2005 -jasmine.Queue = function(env) {
2006 - this.env = env;
2007 -
2008 - // parallel to blocks. each true value in this array means the block will
2009 - // get executed even if we abort
2010 - this.ensured = [];
2011 - this.blocks = [];
2012 - this.running = false;
2013 - this.index = 0;
2014 - this.offset = 0;
2015 - this.abort = false;
2016 -};
2017 -
2018 -jasmine.Queue.prototype.addBefore = function(block, ensure) {
2019 - if (ensure === jasmine.undefined) {
2020 - ensure = false;
2021 - }
2022 -
2023 - this.blocks.unshift(block);
2024 - this.ensured.unshift(ensure);
2025 -};
2026 -
2027 -jasmine.Queue.prototype.add = function(block, ensure) {
2028 - if (ensure === jasmine.undefined) {
2029 - ensure = false;
2030 - }
2031 -
2032 - this.blocks.push(block);
2033 - this.ensured.push(ensure);
2034 -};
2035 -
2036 -jasmine.Queue.prototype.insertNext = function(block, ensure) {
2037 - if (ensure === jasmine.undefined) {
2038 - ensure = false;
2039 - }
2040 -
2041 - this.ensured.splice((this.index + this.offset + 1), 0, ensure);
2042 - this.blocks.splice((this.index + this.offset + 1), 0, block);
2043 - this.offset++;
2044 -};
2045 -
2046 -jasmine.Queue.prototype.start = function(onComplete) {
2047 - this.running = true;
2048 - this.onComplete = onComplete;
2049 - this.next_();
2050 -};
2051 -
2052 -jasmine.Queue.prototype.isRunning = function() {
2053 - return this.running;
2054 -};
2055 -
2056 -jasmine.Queue.LOOP_DONT_RECURSE = true;
2057 -
2058 -jasmine.Queue.prototype.next_ = function() {
2059 - var self = this;
2060 - var goAgain = true;
2061 -
2062 - while (goAgain) {
2063 - goAgain = false;
2064 -
2065 - if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
2066 - var calledSynchronously = true;
2067 - var completedSynchronously = false;
2068 -
2069 - var onComplete = function () {
2070 - if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
2071 - completedSynchronously = true;
2072 - return;
2073 - }
2074 -
2075 - if (self.blocks[self.index].abort) {
2076 - self.abort = true;
2077 - }
2078 -
2079 - self.offset = 0;
2080 - self.index++;
2081 -
2082 - var now = new Date().getTime();
2083 - if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
2084 - self.env.lastUpdate = now;
2085 - self.env.setTimeout(function() {
2086 - self.next_();
2087 - }, 0);
2088 - } else {
2089 - if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
2090 - goAgain = true;
2091 - } else {
2092 - self.next_();
2093 - }
2094 - }
2095 - };
2096 - self.blocks[self.index].execute(onComplete);
2097 -
2098 - calledSynchronously = false;
2099 - if (completedSynchronously) {
2100 - onComplete();
2101 - }
2102 -
2103 - } else {
2104 - self.running = false;
2105 - if (self.onComplete) {
2106 - self.onComplete();
2107 - }
2108 - }
2109 - }
2110 -};
2111 -
2112 -jasmine.Queue.prototype.results = function() {
2113 - var results = new jasmine.NestedResults();
2114 - for (var i = 0; i < this.blocks.length; i++) {
2115 - if (this.blocks[i].results) {
2116 - results.addResult(this.blocks[i].results());
2117 - }
2118 - }
2119 - return results;
2120 -};
2121 -
2122 -
2123 -/**
2124 - * Runner
2125 - *
2126 - * @constructor
2127 - * @param {jasmine.Env} env
2128 - */
2129 -jasmine.Runner = function(env) {
2130 - var self = this;
2131 - self.env = env;
2132 - self.queue = new jasmine.Queue(env);
2133 - self.before_ = [];
2134 - self.after_ = [];
2135 - self.suites_ = [];
2136 -};
2137 -
2138 -jasmine.Runner.prototype.execute = function() {
2139 - var self = this;
2140 - if (self.env.reporter.reportRunnerStarting) {
2141 - self.env.reporter.reportRunnerStarting(this);
2142 - }
2143 - self.queue.start(function () {
2144 - self.finishCallback();
2145 - });
2146 -};
2147 -
2148 -jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
2149 - beforeEachFunction.typeName = 'beforeEach';
2150 - this.before_.splice(0,0,beforeEachFunction);
2151 -};
2152 -
2153 -jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
2154 - afterEachFunction.typeName = 'afterEach';
2155 - this.after_.splice(0,0,afterEachFunction);
2156 -};
2157 -
2158 -
2159 -jasmine.Runner.prototype.finishCallback = function() {
2160 - this.env.reporter.reportRunnerResults(this);
2161 -};
2162 -
2163 -jasmine.Runner.prototype.addSuite = function(suite) {
2164 - this.suites_.push(suite);
2165 -};
2166 -
2167 -jasmine.Runner.prototype.add = function(block) {
2168 - if (block instanceof jasmine.Suite) {
2169 - this.addSuite(block);
2170 - }
2171 - this.queue.add(block);
2172 -};
2173 -
2174 -jasmine.Runner.prototype.specs = function () {
2175 - var suites = this.suites();
2176 - var specs = [];
2177 - for (var i = 0; i < suites.length; i++) {
2178 - specs = specs.concat(suites[i].specs());
2179 - }
2180 - return specs;
2181 -};
2182 -
2183 -jasmine.Runner.prototype.suites = function() {
2184 - return this.suites_;
2185 -};
2186 -
2187 -jasmine.Runner.prototype.topLevelSuites = function() {
2188 - var topLevelSuites = [];
2189 - for (var i = 0; i < this.suites_.length; i++) {
2190 - if (!this.suites_[i].parentSuite) {
2191 - topLevelSuites.push(this.suites_[i]);
2192 - }
2193 - }
2194 - return topLevelSuites;
2195 -};
2196 -
2197 -jasmine.Runner.prototype.results = function() {
2198 - return this.queue.results();
2199 -};
2200 -/**
2201 - * Internal representation of a Jasmine specification, or test.
2202 - *
2203 - * @constructor
2204 - * @param {jasmine.Env} env
2205 - * @param {jasmine.Suite} suite
2206 - * @param {String} description
2207 - */
2208 -jasmine.Spec = function(env, suite, description) {
2209 - if (!env) {
2210 - throw new Error('jasmine.Env() required');
2211 - }
2212 - if (!suite) {
2213 - throw new Error('jasmine.Suite() required');
2214 - }
2215 - var spec = this;
2216 - spec.id = env.nextSpecId ? env.nextSpecId() : null;
2217 - spec.env = env;
2218 - spec.suite = suite;
2219 - spec.description = description;
2220 - spec.queue = new jasmine.Queue(env);
2221 -
2222 - spec.afterCallbacks = [];
2223 - spec.spies_ = [];
2224 -
2225 - spec.results_ = new jasmine.NestedResults();
2226 - spec.results_.description = description;
2227 - spec.matchersClass = null;
2228 -};
2229 -
2230 -jasmine.Spec.prototype.getFullName = function() {
2231 - return this.suite.getFullName() + ' ' + this.description + '.';
2232 -};
2233 -
2234 -
2235 -jasmine.Spec.prototype.results = function() {
2236 - return this.results_;
2237 -};
2238 -
2239 -/**
2240 - * All parameters are pretty-printed and concatenated together, then written to the spec's output.
2241 - *
2242 - * Be careful not to leave calls to <code>jasmine.log</code> in production code.
2243 - */
2244 -jasmine.Spec.prototype.log = function() {
2245 - return this.results_.log(arguments);
2246 -};
2247 -
2248 -jasmine.Spec.prototype.runs = function (func) {
2249 - var block = new jasmine.Block(this.env, func, this);
2250 - this.addToQueue(block);
2251 - return this;
2252 -};
2253 -
2254 -jasmine.Spec.prototype.addToQueue = function (block) {
2255 - if (this.queue.isRunning()) {
2256 - this.queue.insertNext(block);
2257 - } else {
2258 - this.queue.add(block);
2259 - }
2260 -};
2261 -
2262 -/**
2263 - * @param {jasmine.ExpectationResult} result
2264 - */
2265 -jasmine.Spec.prototype.addMatcherResult = function(result) {
2266 - this.results_.addResult(result);
2267 -};
2268 -
2269 -jasmine.Spec.prototype.expect = function(actual) {
2270 - var positive = new (this.getMatchersClass_())(this.env, actual, this);
2271 - positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
2272 - return positive;
2273 -};
2274 -
2275 -/**
2276 - * Waits a fixed time period before moving to the next block.
2277 - *
2278 - * @deprecated Use waitsFor() instead
2279 - * @param {Number} timeout milliseconds to wait
2280 - */
2281 -jasmine.Spec.prototype.waits = function(timeout) {
2282 - var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
2283 - this.addToQueue(waitsFunc);
2284 - return this;
2285 -};
2286 -
2287 -/**
2288 - * Waits for the latchFunction to return true before proceeding to the next block.
2289 - *
2290 - * @param {Function} latchFunction
2291 - * @param {String} optional_timeoutMessage
2292 - * @param {Number} optional_timeout
2293 - */
2294 -jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
2295 - var latchFunction_ = null;
2296 - var optional_timeoutMessage_ = null;
2297 - var optional_timeout_ = null;
2298 -
2299 - for (var i = 0; i < arguments.length; i++) {
2300 - var arg = arguments[i];
2301 - switch (typeof arg) {
2302 - case 'function':
2303 - latchFunction_ = arg;
2304 - break;
2305 - case 'string':
2306 - optional_timeoutMessage_ = arg;
2307 - break;
2308 - case 'number':
2309 - optional_timeout_ = arg;
2310 - break;
2311 - }
2312 - }
2313 -
2314 - var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);
2315 - this.addToQueue(waitsForFunc);
2316 - return this;
2317 -};
2318 -
2319 -jasmine.Spec.prototype.fail = function (e) {
2320 - var expectationResult = new jasmine.ExpectationResult({
2321 - passed: false,
2322 - message: e ? jasmine.util.formatException(e) : 'Exception',
2323 - trace: { stack: e.stack }
2324 - });
2325 - this.results_.addResult(expectationResult);
2326 -};
2327 -
2328 -jasmine.Spec.prototype.getMatchersClass_ = function() {
2329 - return this.matchersClass || this.env.matchersClass;
2330 -};
2331 -
2332 -jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
2333 - var parent = this.getMatchersClass_();
2334 - var newMatchersClass = function() {
2335 - parent.apply(this, arguments);
2336 - };
2337 - jasmine.util.inherit(newMatchersClass, parent);
2338 - jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
2339 - this.matchersClass = newMatchersClass;
2340 -};
2341 -
2342 -jasmine.Spec.prototype.finishCallback = function() {
2343 - this.env.reporter.reportSpecResults(this);
2344 -};
2345 -
2346 -jasmine.Spec.prototype.finish = function(onComplete) {
2347 - this.removeAllSpies();
2348 - this.finishCallback();
2349 - if (onComplete) {
2350 - onComplete();
2351 - }
2352 -};
2353 -
2354 -jasmine.Spec.prototype.after = function(doAfter) {
2355 - if (this.queue.isRunning()) {
2356 - this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
2357 - } else {
2358 - this.afterCallbacks.unshift(doAfter);
2359 - }
2360 -};
2361 -
2362 -jasmine.Spec.prototype.execute = function(onComplete) {
2363 - var spec = this;
2364 - if (!spec.env.specFilter(spec)) {
2365 - spec.results_.skipped = true;
2366 - spec.finish(onComplete);
2367 - return;
2368 - }
2369 -
2370 - this.env.reporter.reportSpecStarting(this);
2371 -
2372 - spec.env.currentSpec = spec;
2373 -
2374 - spec.addBeforesAndAftersToQueue();
2375 -
2376 - spec.queue.start(function () {
2377 - spec.finish(onComplete);
2378 - });
2379 -};
2380 -
2381 -jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
2382 - var runner = this.env.currentRunner();
2383 - var i;
2384 -
2385 - for (var suite = this.suite; suite; suite = suite.parentSuite) {
2386 - for (i = 0; i < suite.before_.length; i++) {
2387 - this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
2388 - }
2389 - }
2390 - for (i = 0; i < runner.before_.length; i++) {
2391 - this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
2392 - }
2393 - for (i = 0; i < this.afterCallbacks.length; i++) {
2394 - this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
2395 - }
2396 - for (suite = this.suite; suite; suite = suite.parentSuite) {
2397 - for (i = 0; i < suite.after_.length; i++) {
2398 - this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
2399 - }
2400 - }
2401 - for (i = 0; i < runner.after_.length; i++) {
2402 - this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
2403 - }
2404 -};
2405 -
2406 -jasmine.Spec.prototype.explodes = function() {
2407 - throw 'explodes function should not have been called';
2408 -};
2409 -
2410 -jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
2411 - if (obj == jasmine.undefined) {
2412 - throw "spyOn could not find an object to spy upon for " + methodName + "()";
2413 - }
2414 -
2415 - if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
2416 - throw methodName + '() method does not exist';
2417 - }
2418 -
2419 - if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
2420 - throw new Error(methodName + ' has already been spied upon');
2421 - }
2422 -
2423 - var spyObj = jasmine.createSpy(methodName);
2424 -
2425 - this.spies_.push(spyObj);
2426 - spyObj.baseObj = obj;
2427 - spyObj.methodName = methodName;
2428 - spyObj.originalValue = obj[methodName];
2429 -
2430 - obj[methodName] = spyObj;
2431 -
2432 - return spyObj;
2433 -};
2434 -
2435 -jasmine.Spec.prototype.removeAllSpies = function() {
2436 - for (var i = 0; i < this.spies_.length; i++) {
2437 - var spy = this.spies_[i];
2438 - spy.baseObj[spy.methodName] = spy.originalValue;
2439 - }
2440 - this.spies_ = [];
2441 -};
2442 -
2443 -/**
2444 - * Internal representation of a Jasmine suite.
2445 - *
2446 - * @constructor
2447 - * @param {jasmine.Env} env
2448 - * @param {String} description
2449 - * @param {Function} specDefinitions
2450 - * @param {jasmine.Suite} parentSuite
2451 - */
2452 -jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
2453 - var self = this;
2454 - self.id = env.nextSuiteId ? env.nextSuiteId() : null;
2455 - self.description = description;
2456 - self.queue = new jasmine.Queue(env);
2457 - self.parentSuite = parentSuite;
2458 - self.env = env;
2459 - self.before_ = [];
2460 - self.after_ = [];
2461 - self.children_ = [];
2462 - self.suites_ = [];
2463 - self.specs_ = [];
2464 -};
2465 -
2466 -jasmine.Suite.prototype.getFullName = function() {
2467 - var fullName = this.description;
2468 - for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
2469 - fullName = parentSuite.description + ' ' + fullName;
2470 - }
2471 - return fullName;
2472 -};
2473 -
2474 -jasmine.Suite.prototype.finish = function(onComplete) {
2475 - this.env.reporter.reportSuiteResults(this);
2476 - this.finished = true;
2477 - if (typeof(onComplete) == 'function') {
2478 - onComplete();
2479 - }
2480 -};
2481 -
2482 -jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
2483 - beforeEachFunction.typeName = 'beforeEach';
2484 - this.before_.unshift(beforeEachFunction);
2485 -};
2486 -
2487 -jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
2488 - afterEachFunction.typeName = 'afterEach';
2489 - this.after_.unshift(afterEachFunction);
2490 -};
2491 -
2492 -jasmine.Suite.prototype.results = function() {
2493 - return this.queue.results();
2494 -};
2495 -
2496 -jasmine.Suite.prototype.add = function(suiteOrSpec) {
2497 - this.children_.push(suiteOrSpec);
2498 - if (suiteOrSpec instanceof jasmine.Suite) {
2499 - this.suites_.push(suiteOrSpec);
2500 - this.env.currentRunner().addSuite(suiteOrSpec);
2501 - } else {
2502 - this.specs_.push(suiteOrSpec);
2503 - }
2504 - this.queue.add(suiteOrSpec);
2505 -};
2506 -
2507 -jasmine.Suite.prototype.specs = function() {
2508 - return this.specs_;
2509 -};
2510 -
2511 -jasmine.Suite.prototype.suites = function() {
2512 - return this.suites_;
2513 -};
2514 -
2515 -jasmine.Suite.prototype.children = function() {
2516 - return this.children_;
2517 -};
2518 -
2519 -jasmine.Suite.prototype.execute = function(onComplete) {
2520 - var self = this;
2521 - this.queue.start(function () {
2522 - self.finish(onComplete);
2523 - });
2524 -};
2525 -jasmine.WaitsBlock = function(env, timeout, spec) {
2526 - this.timeout = timeout;
2527 - jasmine.Block.call(this, env, null, spec);
2528 -};
2529 -
2530 -jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
2531 -
2532 -jasmine.WaitsBlock.prototype.execute = function (onComplete) {
2533 - if (jasmine.VERBOSE) {
2534 - this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
2535 - }
2536 - this.env.setTimeout(function () {
2537 - onComplete();
2538 - }, this.timeout);
2539 -};
2540 -/**
2541 - * A block which waits for some condition to become true, with timeout.
2542 - *
2543 - * @constructor
2544 - * @extends jasmine.Block
2545 - * @param {jasmine.Env} env The Jasmine environment.
2546 - * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true.
2547 - * @param {Function} latchFunction A function which returns true when the desired condition has been met.
2548 - * @param {String} message The message to display if the desired condition hasn't been met within the given time period.
2549 - * @param {jasmine.Spec} spec The Jasmine spec.
2550 - */
2551 -jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
2552 - this.timeout = timeout || env.defaultTimeoutInterval;
2553 - this.latchFunction = latchFunction;
2554 - this.message = message;
2555 - this.totalTimeSpentWaitingForLatch = 0;
2556 - jasmine.Block.call(this, env, null, spec);
2557 -};
2558 -jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
2559 -
2560 -jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
2561 -
2562 -jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
2563 - if (jasmine.VERBOSE) {
2564 - this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
2565 - }
2566 - var latchFunctionResult;
2567 - try {
2568 - latchFunctionResult = this.latchFunction.apply(this.spec);
2569 - } catch (e) {
2570 - this.spec.fail(e);
2571 - onComplete();
2572 - return;
2573 - }
2574 -
2575 - if (latchFunctionResult) {
2576 - onComplete();
2577 - } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {
2578 - var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen');
2579 - this.spec.fail({
2580 - name: 'timeout',
2581 - message: message
2582 - });
2583 -
2584 - this.abort = true;
2585 - onComplete();
2586 - } else {
2587 - this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
2588 - var self = this;
2589 - this.env.setTimeout(function() {
2590 - self.execute(onComplete);
2591 - }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
2592 - }
2593 -};
2594 -
2595 -jasmine.version_= {
2596 - "major": 1,
2597 - "minor": 3,
2598 - "build": 0,
2599 - "revision": 1354052693
2600 -};
vendor/jasmine/phantom.js deleted
-37
@@ -1,37 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * This module provides a bridge from content-land to phantom-land via the
10 - * window.callPhantom interface.
11 - */
12 -
13 -var console = require("./console");
14 -var global = Function("return this")();
15 -
16 -if (global.callPhantom) {
17 - // Phantom's onConsoleMessage support is lacking (only one argument
18 - // supported, and it must be a string), so we use callPhantom to
19 - // forward console messages instead.
20 - console.addListener(function(method, args) {
21 - global.callPhantom({
22 - type: "console",
23 - method: method,
24 - args: args
25 - });
26 - });
27 -
28 - exports.exit = function(code) {
29 - global.callPhantom({
30 - type: "exit",
31 - code: code
32 - });
33 - };
34 -
35 -} else {
36 - exports.exit = function() {};
37 -}