├── .gitignore
├── LICENSE
├── README.md
├── jasmine-lib
├── console
│ └── console.js
├── jasmine-core.js
├── jasmine-core.rb
└── jasmine-core
│ ├── __init__.py
│ ├── boot.js
│ ├── boot
│ ├── boot.js
│ └── node_boot.js
│ ├── core.py
│ ├── example
│ ├── node_example
│ │ ├── lib
│ │ │ └── jasmine_examples
│ │ │ │ ├── Player.js
│ │ │ │ └── Song.js
│ │ └── spec
│ │ │ ├── helpers
│ │ │ └── jasmine_examples
│ │ │ │ └── SpecHelper.js
│ │ │ └── jasmine_examples
│ │ │ └── PlayerSpec.js
│ ├── spec
│ │ ├── PlayerSpec.js
│ │ └── SpecHelper.js
│ └── src
│ │ ├── Player.js
│ │ └── Song.js
│ ├── jasmine-html.js
│ ├── jasmine.css
│ ├── jasmine.js
│ ├── json2.js
│ ├── node_boot.js
│ ├── spec
│ └── version.rb
├── night-mode.js
├── night-mode.js.map
├── night-mode.min.js
├── night-mode.ts
├── test-runner.html
└── unit-tests.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # night-mode-js
2 |
3 | A small javascript tool to automatically add or remove night css class from the `
` element. It's lightweight, straightforward and easy to set up.
4 |
5 | ## Why?
6 | This project was designed with conviction that all software should have an optimized dark theme to reduce eye strain during night-time use.
7 |
8 | ## Quickstart
9 | Simply include the script in the ``.
10 | ```html
11 |
12 | ```
13 |
14 | Or download and place night-mode.min.js in your project.
15 | ```html
16 |
17 | ```
18 |
19 |
20 | The simplest way to use NightMode (See the table below describing default options):
21 | ```html
22 |
25 | ```
26 |
27 | Or with custom options:
28 | ```html
29 |
37 | ```
38 | ### Options
39 |
40 | | property | default | description |
41 | |--------------------------|--------------------|-------------------------------------------------------------------------------|
42 | | evening | new DayTime(21, 0) | The time when the night starts. Seconds aren't supported. |
43 | | morning | new DayTime(6, 0) | The time when the night ends. Seconds aren't supported. |
44 | | refreshIntervalInSeconds | 20 | How often the NightMode object checks the time. |
45 | | cssNightClassName | 'night' | Name of the css class that is added to `` element at night |
46 | | autoSwitch | true | Whether the NightMode object should automatically switch the night css class. |
47 |
48 | And you can also disable or enable the nightMode auto-switch if necessary (note that disabling auto-switch doesn't remove the night class from the body if it's currently present):
49 | ```js
50 | nightMode.disableAutoSwitch();
51 | nightMode.enableAutoSwitch();
52 | ```
53 |
54 | You're almost done! You just need to add some css rules:
55 | ```css
56 | body {
57 | background-color: white;
58 | color: #212121;
59 | }
60 |
61 | body.night {
62 | background-color: #181818;
63 | color: white;
64 | }
65 | ...
66 | ```
67 |
68 | ## Compatibility
69 | This script is written entirely in Typescript and compiled into javascript language level ES5. If you need a different language level, feel free to compile the source yourself.
70 |
71 | ## Dependencies
72 | No dependencies!
73 |
74 | ## License & credits
75 |
76 | Created by [Marek Kadlčík](http://marekkadlcik.com).
77 |
78 | Licensed under [MIT licence](https://github.com/cuddlecheek/night-mode-js/blob/master/LICENSE).
79 |
--------------------------------------------------------------------------------
/jasmine-lib/console/console.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2016 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | function getJasmineRequireObj() {
24 | if (typeof module !== 'undefined' && module.exports) {
25 | return exports;
26 | } else {
27 | window.jasmineRequire = window.jasmineRequire || {};
28 | return window.jasmineRequire;
29 | }
30 | }
31 |
32 | getJasmineRequireObj().console = function(jRequire, j$) {
33 | j$.ConsoleReporter = jRequire.ConsoleReporter();
34 | };
35 |
36 | getJasmineRequireObj().ConsoleReporter = function() {
37 |
38 | var noopTimer = {
39 | start: function(){},
40 | elapsed: function(){ return 0; }
41 | };
42 |
43 | function ConsoleReporter(options) {
44 | var print = options.print,
45 | showColors = options.showColors || false,
46 | onComplete = options.onComplete || function() {},
47 | timer = options.timer || noopTimer,
48 | specCount,
49 | failureCount,
50 | failedSpecs = [],
51 | pendingCount,
52 | ansi = {
53 | green: '\x1B[32m',
54 | red: '\x1B[31m',
55 | yellow: '\x1B[33m',
56 | none: '\x1B[0m'
57 | },
58 | failedSuites = [];
59 |
60 | print('ConsoleReporter is deprecated and will be removed in a future version.');
61 |
62 | this.jasmineStarted = function() {
63 | specCount = 0;
64 | failureCount = 0;
65 | pendingCount = 0;
66 | print('Started');
67 | printNewline();
68 | timer.start();
69 | };
70 |
71 | this.jasmineDone = function() {
72 | printNewline();
73 | for (var i = 0; i < failedSpecs.length; i++) {
74 | specFailureDetails(failedSpecs[i]);
75 | }
76 |
77 | if(specCount > 0) {
78 | printNewline();
79 |
80 | var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
81 | failureCount + ' ' + plural('failure', failureCount);
82 |
83 | if (pendingCount) {
84 | specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
85 | }
86 |
87 | print(specCounts);
88 | } else {
89 | print('No specs found');
90 | }
91 |
92 | printNewline();
93 | var seconds = timer.elapsed() / 1000;
94 | print('Finished in ' + seconds + ' ' + plural('second', seconds));
95 | printNewline();
96 |
97 | for(i = 0; i < failedSuites.length; i++) {
98 | suiteFailureDetails(failedSuites[i]);
99 | }
100 |
101 | onComplete(failureCount === 0);
102 | };
103 |
104 | this.specDone = function(result) {
105 | specCount++;
106 |
107 | if (result.status == 'pending') {
108 | pendingCount++;
109 | print(colored('yellow', '*'));
110 | return;
111 | }
112 |
113 | if (result.status == 'passed') {
114 | print(colored('green', '.'));
115 | return;
116 | }
117 |
118 | if (result.status == 'failed') {
119 | failureCount++;
120 | failedSpecs.push(result);
121 | print(colored('red', 'F'));
122 | }
123 | };
124 |
125 | this.suiteDone = function(result) {
126 | if (result.failedExpectations && result.failedExpectations.length > 0) {
127 | failureCount++;
128 | failedSuites.push(result);
129 | }
130 | };
131 |
132 | return this;
133 |
134 | function printNewline() {
135 | print('\n');
136 | }
137 |
138 | function colored(color, str) {
139 | return showColors ? (ansi[color] + str + ansi.none) : str;
140 | }
141 |
142 | function plural(str, count) {
143 | return count == 1 ? str : str + 's';
144 | }
145 |
146 | function repeat(thing, times) {
147 | var arr = [];
148 | for (var i = 0; i < times; i++) {
149 | arr.push(thing);
150 | }
151 | return arr;
152 | }
153 |
154 | function indent(str, spaces) {
155 | var lines = (str || '').split('\n');
156 | var newArr = [];
157 | for (var i = 0; i < lines.length; i++) {
158 | newArr.push(repeat(' ', spaces).join('') + lines[i]);
159 | }
160 | return newArr.join('\n');
161 | }
162 |
163 | function specFailureDetails(result) {
164 | printNewline();
165 | print(result.fullName);
166 |
167 | for (var i = 0; i < result.failedExpectations.length; i++) {
168 | var failedExpectation = result.failedExpectations[i];
169 | printNewline();
170 | print(indent(failedExpectation.message, 2));
171 | print(indent(failedExpectation.stack, 2));
172 | }
173 |
174 | printNewline();
175 | }
176 |
177 | function suiteFailureDetails(result) {
178 | for (var i = 0; i < result.failedExpectations.length; i++) {
179 | printNewline();
180 | print(colored('red', 'An error was thrown in an afterAll'));
181 | printNewline();
182 | print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
183 |
184 | }
185 | printNewline();
186 | }
187 | }
188 |
189 | return ConsoleReporter;
190 | };
191 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core.js:
--------------------------------------------------------------------------------
1 | module.exports = require("./jasmine-core/jasmine.js");
2 | module.exports.boot = require('./jasmine-core/node_boot.js');
3 |
4 | var path = require('path'),
5 | fs = require('fs');
6 |
7 | var rootPath = path.join(__dirname, "jasmine-core"),
8 | bootFiles = ['boot.js'],
9 | nodeBootFiles = ['node_boot.js'],
10 | cssFiles = [],
11 | jsFiles = [],
12 | jsFilesToSkip = ['jasmine.js'].concat(bootFiles, nodeBootFiles);
13 |
14 | fs.readdirSync(rootPath).forEach(function(file) {
15 | if(fs.statSync(path.join(rootPath, file)).isFile()) {
16 | switch(path.extname(file)) {
17 | case '.css':
18 | cssFiles.push(file);
19 | break;
20 | case '.js':
21 | if (jsFilesToSkip.indexOf(file) < 0) {
22 | jsFiles.push(file);
23 | }
24 | break;
25 | }
26 | }
27 | });
28 |
29 | module.exports.files = {
30 | path: rootPath,
31 | bootDir: rootPath,
32 | bootFiles: bootFiles,
33 | nodeBootFiles: nodeBootFiles,
34 | cssFiles: cssFiles,
35 | jsFiles: ['jasmine.js'].concat(jsFiles),
36 | imagesDir: path.join(__dirname, '../images')
37 | };
38 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core.rb:
--------------------------------------------------------------------------------
1 | module Jasmine
2 | module Core
3 | class << self
4 | def path
5 | File.join(File.dirname(__FILE__), "jasmine-core")
6 | end
7 |
8 | def js_files
9 | (["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files - node_boot_files
10 | end
11 |
12 | SPEC_TYPES = ["core", "html", "node"]
13 |
14 | def core_spec_files
15 | spec_files("core")
16 | end
17 |
18 | def html_spec_files
19 | spec_files("html")
20 | end
21 |
22 | def node_spec_files
23 | spec_files("node")
24 | end
25 |
26 | def boot_files
27 | ["boot.js"]
28 | end
29 |
30 | def node_boot_files
31 | ["node_boot.js"]
32 | end
33 |
34 | def boot_dir
35 | path
36 | end
37 |
38 | def spec_files(type)
39 | raise ArgumentError.new("Unrecognized spec type") unless SPEC_TYPES.include?(type)
40 | (Dir.glob(File.join(path, "spec", type, "*.js"))).map { |f| File.join("spec", type, File.basename(f)) }.uniq
41 | end
42 |
43 | def css_files
44 | Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
45 | end
46 |
47 | def images_dir
48 | File.join(File.dirname(__FILE__), '../images')
49 | end
50 |
51 | end
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/__init__.py:
--------------------------------------------------------------------------------
1 | from .core import Core
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/boot.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2016 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | /**
24 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
25 |
26 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
27 |
28 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
29 |
30 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem
31 | */
32 |
33 | (function() {
34 |
35 | /**
36 | * ## Require & Instantiate
37 | *
38 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
39 | */
40 | window.jasmine = jasmineRequire.core(jasmineRequire);
41 |
42 | /**
43 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
44 | */
45 | jasmineRequire.html(jasmine);
46 |
47 | /**
48 | * Create the Jasmine environment. This is used to run all specs in a project.
49 | */
50 | var env = jasmine.getEnv();
51 |
52 | /**
53 | * ## The Global Interface
54 | *
55 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
56 | */
57 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
58 |
59 | /**
60 | * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
61 | */
62 | extend(window, jasmineInterface);
63 |
64 | /**
65 | * ## Runner Parameters
66 | *
67 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
68 | */
69 |
70 | var queryString = new jasmine.QueryString({
71 | getWindowLocation: function() { return window.location; }
72 | });
73 |
74 | var catchingExceptions = queryString.getParam("catch");
75 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
76 |
77 | var throwingExpectationFailures = queryString.getParam("throwFailures");
78 | env.throwOnExpectationFailure(throwingExpectationFailures);
79 |
80 | var random = queryString.getParam("random");
81 | env.randomizeTests(random);
82 |
83 | var seed = queryString.getParam("seed");
84 | if (seed) {
85 | env.seed(seed);
86 | }
87 |
88 | /**
89 | * ## Reporters
90 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
91 | */
92 | var htmlReporter = new jasmine.HtmlReporter({
93 | env: env,
94 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
95 | onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
96 | onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
97 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
98 | getContainer: function() { return document.body; },
99 | createElement: function() { return document.createElement.apply(document, arguments); },
100 | createTextNode: function() { return document.createTextNode.apply(document, arguments); },
101 | timer: new jasmine.Timer()
102 | });
103 |
104 | /**
105 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
106 | */
107 | env.addReporter(jasmineInterface.jsApiReporter);
108 | env.addReporter(htmlReporter);
109 |
110 | /**
111 | * Filter which specs will be run by matching the start of the full name against the `spec` query param.
112 | */
113 | var specFilter = new jasmine.HtmlSpecFilter({
114 | filterString: function() { return queryString.getParam("spec"); }
115 | });
116 |
117 | env.specFilter = function(spec) {
118 | return specFilter.matches(spec.getFullName());
119 | };
120 |
121 | /**
122 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
123 | */
124 | window.setTimeout = window.setTimeout;
125 | window.setInterval = window.setInterval;
126 | window.clearTimeout = window.clearTimeout;
127 | window.clearInterval = window.clearInterval;
128 |
129 | /**
130 | * ## Execution
131 | *
132 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
133 | */
134 | var currentWindowOnload = window.onload;
135 |
136 | window.onload = function() {
137 | if (currentWindowOnload) {
138 | currentWindowOnload();
139 | }
140 | htmlReporter.initialize();
141 | env.execute();
142 | };
143 |
144 | /**
145 | * Helper function for readability above.
146 | */
147 | function extend(destination, source) {
148 | for (var property in source) destination[property] = source[property];
149 | return destination;
150 | }
151 |
152 | }());
153 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/boot/boot.js:
--------------------------------------------------------------------------------
1 | /**
2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3 |
4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5 |
6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7 |
8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9 | */
10 |
11 | (function() {
12 |
13 | /**
14 | * ## Require & Instantiate
15 | *
16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17 | */
18 | window.jasmine = jasmineRequire.core(jasmineRequire);
19 |
20 | /**
21 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
22 | */
23 | jasmineRequire.html(jasmine);
24 |
25 | /**
26 | * Create the Jasmine environment. This is used to run all specs in a project.
27 | */
28 | var env = jasmine.getEnv();
29 |
30 | /**
31 | * ## The Global Interface
32 | *
33 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
34 | */
35 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
36 |
37 | /**
38 | * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
39 | */
40 | extend(window, jasmineInterface);
41 |
42 | /**
43 | * ## Runner Parameters
44 | *
45 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
46 | */
47 |
48 | var queryString = new jasmine.QueryString({
49 | getWindowLocation: function() { return window.location; }
50 | });
51 |
52 | var catchingExceptions = queryString.getParam("catch");
53 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
54 |
55 | var throwingExpectationFailures = queryString.getParam("throwFailures");
56 | env.throwOnExpectationFailure(throwingExpectationFailures);
57 |
58 | var random = queryString.getParam("random");
59 | env.randomizeTests(random);
60 |
61 | var seed = queryString.getParam("seed");
62 | if (seed) {
63 | env.seed(seed);
64 | }
65 |
66 | /**
67 | * ## Reporters
68 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
69 | */
70 | var htmlReporter = new jasmine.HtmlReporter({
71 | env: env,
72 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
73 | onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
74 | onRandomClick: function() { queryString.navigateWithNewParam("random", !env.randomTests()); },
75 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
76 | getContainer: function() { return document.body; },
77 | createElement: function() { return document.createElement.apply(document, arguments); },
78 | createTextNode: function() { return document.createTextNode.apply(document, arguments); },
79 | timer: new jasmine.Timer()
80 | });
81 |
82 | /**
83 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
84 | */
85 | env.addReporter(jasmineInterface.jsApiReporter);
86 | env.addReporter(htmlReporter);
87 |
88 | /**
89 | * Filter which specs will be run by matching the start of the full name against the `spec` query param.
90 | */
91 | var specFilter = new jasmine.HtmlSpecFilter({
92 | filterString: function() { return queryString.getParam("spec"); }
93 | });
94 |
95 | env.specFilter = function(spec) {
96 | return specFilter.matches(spec.getFullName());
97 | };
98 |
99 | /**
100 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
101 | */
102 | window.setTimeout = window.setTimeout;
103 | window.setInterval = window.setInterval;
104 | window.clearTimeout = window.clearTimeout;
105 | window.clearInterval = window.clearInterval;
106 |
107 | /**
108 | * ## Execution
109 | *
110 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
111 | */
112 | var currentWindowOnload = window.onload;
113 |
114 | window.onload = function() {
115 | if (currentWindowOnload) {
116 | currentWindowOnload();
117 | }
118 | htmlReporter.initialize();
119 | env.execute();
120 | };
121 |
122 | /**
123 | * Helper function for readability above.
124 | */
125 | function extend(destination, source) {
126 | for (var property in source) destination[property] = source[property];
127 | return destination;
128 | }
129 |
130 | }());
131 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/boot/node_boot.js:
--------------------------------------------------------------------------------
1 | module.exports = function(jasmineRequire) {
2 | var jasmine = jasmineRequire.core(jasmineRequire);
3 |
4 | var consoleFns = require('../console/console.js');
5 | consoleFns.console(consoleFns, jasmine);
6 |
7 | var env = jasmine.getEnv();
8 |
9 | var jasmineInterface = jasmineRequire.interface(jasmine, env);
10 |
11 | extend(global, jasmineInterface);
12 |
13 | function extend(destination, source) {
14 | for (var property in source) destination[property] = source[property];
15 | return destination;
16 | }
17 |
18 | return jasmine;
19 | };
20 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/core.py:
--------------------------------------------------------------------------------
1 | import pkg_resources
2 |
3 | try:
4 | from collections import OrderedDict
5 | except ImportError:
6 | from ordereddict import OrderedDict
7 |
8 | class Core(object):
9 | @classmethod
10 | def js_package(cls):
11 | return __package__
12 |
13 | @classmethod
14 | def css_package(cls):
15 | return __package__
16 |
17 | @classmethod
18 | def image_package(cls):
19 | return __package__ + ".images"
20 |
21 | @classmethod
22 | def js_files(cls):
23 | js_files = sorted(list(filter(lambda x: '.js' in x, pkg_resources.resource_listdir(cls.js_package(), '.'))))
24 |
25 | # jasmine.js needs to be first
26 | js_files.insert(0, 'jasmine.js')
27 |
28 | # boot needs to be last
29 | js_files.remove('boot.js')
30 | js_files.append('boot.js')
31 |
32 | return cls._uniq(js_files)
33 |
34 | @classmethod
35 | def css_files(cls):
36 | return cls._uniq(sorted(filter(lambda x: '.css' in x, pkg_resources.resource_listdir(cls.css_package(), '.'))))
37 |
38 | @classmethod
39 | def favicon(cls):
40 | return 'jasmine_favicon.png'
41 |
42 | @classmethod
43 | def _uniq(self, items, idfun=None):
44 | # order preserving
45 |
46 | if idfun is None:
47 | def idfun(x): return x
48 | seen = {}
49 | result = []
50 | for item in items:
51 | marker = idfun(item)
52 | # in old Python versions:
53 | # if seen.has_key(marker)
54 | # but in new ones:
55 | if marker in seen:
56 | continue
57 |
58 | seen[marker] = 1
59 | result.append(item)
60 | return result
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js:
--------------------------------------------------------------------------------
1 | function Player() {
2 | }
3 | Player.prototype.play = function(song) {
4 | this.currentlyPlayingSong = song;
5 | this.isPlaying = true;
6 | };
7 |
8 | Player.prototype.pause = function() {
9 | this.isPlaying = false;
10 | };
11 |
12 | Player.prototype.resume = function() {
13 | if (this.isPlaying) {
14 | throw new Error("song is already playing");
15 | }
16 |
17 | this.isPlaying = true;
18 | };
19 |
20 | Player.prototype.makeFavorite = function() {
21 | this.currentlyPlayingSong.persistFavoriteStatus(true);
22 | };
23 |
24 | module.exports = Player;
25 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js:
--------------------------------------------------------------------------------
1 | function Song() {
2 | }
3 |
4 | Song.prototype.persistFavoriteStatus = function(value) {
5 | // something complicated
6 | throw new Error("not yet implemented");
7 | };
8 |
9 | module.exports = Song;
10 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js:
--------------------------------------------------------------------------------
1 | beforeEach(function () {
2 | jasmine.addMatchers({
3 | toBePlaying: function () {
4 | return {
5 | compare: function (actual, expected) {
6 | var player = actual;
7 |
8 | return {
9 | pass: player.currentlyPlayingSong === expected && player.isPlaying
10 | }
11 | }
12 | };
13 | }
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js:
--------------------------------------------------------------------------------
1 | describe("Player", function() {
2 | var Player = require('../../lib/jasmine_examples/Player');
3 | var Song = require('../../lib/jasmine_examples/Song');
4 | var player;
5 | var song;
6 |
7 | beforeEach(function() {
8 | player = new Player();
9 | song = new Song();
10 | });
11 |
12 | it("should be able to play a Song", function() {
13 | player.play(song);
14 | expect(player.currentlyPlayingSong).toEqual(song);
15 |
16 | //demonstrates use of custom matcher
17 | expect(player).toBePlaying(song);
18 | });
19 |
20 | describe("when song has been paused", function() {
21 | beforeEach(function() {
22 | player.play(song);
23 | player.pause();
24 | });
25 |
26 | it("should indicate that the song is currently paused", function() {
27 | expect(player.isPlaying).toBeFalsy();
28 |
29 | // demonstrates use of 'not' with a custom matcher
30 | expect(player).not.toBePlaying(song);
31 | });
32 |
33 | it("should be possible to resume", function() {
34 | player.resume();
35 | expect(player.isPlaying).toBeTruthy();
36 | expect(player.currentlyPlayingSong).toEqual(song);
37 | });
38 | });
39 |
40 | // demonstrates use of spies to intercept and test method calls
41 | it("tells the current song if the user has made it a favorite", function() {
42 | spyOn(song, 'persistFavoriteStatus');
43 |
44 | player.play(song);
45 | player.makeFavorite();
46 |
47 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
48 | });
49 |
50 | //demonstrates use of expected exceptions
51 | describe("#resume", function() {
52 | it("should throw an exception if song is already playing", function() {
53 | player.play(song);
54 |
55 | expect(function() {
56 | player.resume();
57 | }).toThrowError("song is already playing");
58 | });
59 | });
60 | });
61 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/spec/PlayerSpec.js:
--------------------------------------------------------------------------------
1 | describe("Player", function() {
2 | var player;
3 | var song;
4 |
5 | beforeEach(function() {
6 | player = new Player();
7 | song = new Song();
8 | });
9 |
10 | it("should be able to play a Song", function() {
11 | player.play(song);
12 | expect(player.currentlyPlayingSong).toEqual(song);
13 |
14 | //demonstrates use of custom matcher
15 | expect(player).toBePlaying(song);
16 | });
17 |
18 | describe("when song has been paused", function() {
19 | beforeEach(function() {
20 | player.play(song);
21 | player.pause();
22 | });
23 |
24 | it("should indicate that the song is currently paused", function() {
25 | expect(player.isPlaying).toBeFalsy();
26 |
27 | // demonstrates use of 'not' with a custom matcher
28 | expect(player).not.toBePlaying(song);
29 | });
30 |
31 | it("should be possible to resume", function() {
32 | player.resume();
33 | expect(player.isPlaying).toBeTruthy();
34 | expect(player.currentlyPlayingSong).toEqual(song);
35 | });
36 | });
37 |
38 | // demonstrates use of spies to intercept and test method calls
39 | it("tells the current song if the user has made it a favorite", function() {
40 | spyOn(song, 'persistFavoriteStatus');
41 |
42 | player.play(song);
43 | player.makeFavorite();
44 |
45 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
46 | });
47 |
48 | //demonstrates use of expected exceptions
49 | describe("#resume", function() {
50 | it("should throw an exception if song is already playing", function() {
51 | player.play(song);
52 |
53 | expect(function() {
54 | player.resume();
55 | }).toThrowError("song is already playing");
56 | });
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/spec/SpecHelper.js:
--------------------------------------------------------------------------------
1 | beforeEach(function () {
2 | jasmine.addMatchers({
3 | toBePlaying: function () {
4 | return {
5 | compare: function (actual, expected) {
6 | var player = actual;
7 |
8 | return {
9 | pass: player.currentlyPlayingSong === expected && player.isPlaying
10 | };
11 | }
12 | };
13 | }
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/src/Player.js:
--------------------------------------------------------------------------------
1 | function Player() {
2 | }
3 | Player.prototype.play = function(song) {
4 | this.currentlyPlayingSong = song;
5 | this.isPlaying = true;
6 | };
7 |
8 | Player.prototype.pause = function() {
9 | this.isPlaying = false;
10 | };
11 |
12 | Player.prototype.resume = function() {
13 | if (this.isPlaying) {
14 | throw new Error("song is already playing");
15 | }
16 |
17 | this.isPlaying = true;
18 | };
19 |
20 | Player.prototype.makeFavorite = function() {
21 | this.currentlyPlayingSong.persistFavoriteStatus(true);
22 | };
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/example/src/Song.js:
--------------------------------------------------------------------------------
1 | function Song() {
2 | }
3 |
4 | Song.prototype.persistFavoriteStatus = function(value) {
5 | // something complicated
6 | throw new Error("not yet implemented");
7 | };
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/jasmine-html.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2016 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | jasmineRequire.html = function(j$) {
24 | j$.ResultsNode = jasmineRequire.ResultsNode();
25 | j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
26 | j$.QueryString = jasmineRequire.QueryString();
27 | j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
28 | };
29 |
30 | jasmineRequire.HtmlReporter = function(j$) {
31 |
32 | var noopTimer = {
33 | start: function() {},
34 | elapsed: function() { return 0; }
35 | };
36 |
37 | function HtmlReporter(options) {
38 | var env = options.env || {},
39 | getContainer = options.getContainer,
40 | createElement = options.createElement,
41 | createTextNode = options.createTextNode,
42 | onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
43 | onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
44 | onRandomClick = options.onRandomClick || function() {},
45 | addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
46 | timer = options.timer || noopTimer,
47 | results = [],
48 | specsExecuted = 0,
49 | failureCount = 0,
50 | pendingSpecCount = 0,
51 | htmlReporterMain,
52 | symbols,
53 | failedSuites = [];
54 |
55 | this.initialize = function() {
56 | clearPrior();
57 | htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
58 | createDom('div', {className: 'jasmine-banner'},
59 | createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
60 | createDom('span', {className: 'jasmine-version'}, j$.version)
61 | ),
62 | createDom('ul', {className: 'jasmine-symbol-summary'}),
63 | createDom('div', {className: 'jasmine-alert'}),
64 | createDom('div', {className: 'jasmine-results'},
65 | createDom('div', {className: 'jasmine-failures'})
66 | )
67 | );
68 | getContainer().appendChild(htmlReporterMain);
69 | };
70 |
71 | var totalSpecsDefined;
72 | this.jasmineStarted = function(options) {
73 | totalSpecsDefined = options.totalSpecsDefined || 0;
74 | timer.start();
75 | };
76 |
77 | var summary = createDom('div', {className: 'jasmine-summary'});
78 |
79 | var topResults = new j$.ResultsNode({}, '', null),
80 | currentParent = topResults;
81 |
82 | this.suiteStarted = function(result) {
83 | currentParent.addChild(result, 'suite');
84 | currentParent = currentParent.last();
85 | };
86 |
87 | this.suiteDone = function(result) {
88 | if (result.status == 'failed') {
89 | failedSuites.push(result);
90 | }
91 |
92 | if (currentParent == topResults) {
93 | return;
94 | }
95 |
96 | currentParent = currentParent.parent;
97 | };
98 |
99 | this.specStarted = function(result) {
100 | currentParent.addChild(result, 'spec');
101 | };
102 |
103 | var failures = [];
104 | this.specDone = function(result) {
105 | if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
106 | console.error('Spec \'' + result.fullName + '\' has no expectations.');
107 | }
108 |
109 | if (result.status != 'disabled') {
110 | specsExecuted++;
111 | }
112 |
113 | if (!symbols){
114 | symbols = find('.jasmine-symbol-summary');
115 | }
116 |
117 | symbols.appendChild(createDom('li', {
118 | className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
119 | id: 'spec_' + result.id,
120 | title: result.fullName
121 | }
122 | ));
123 |
124 | if (result.status == 'failed') {
125 | failureCount++;
126 |
127 | var failure =
128 | createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
129 | createDom('div', {className: 'jasmine-description'},
130 | createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
131 | ),
132 | createDom('div', {className: 'jasmine-messages'})
133 | );
134 | var messages = failure.childNodes[1];
135 |
136 | for (var i = 0; i < result.failedExpectations.length; i++) {
137 | var expectation = result.failedExpectations[i];
138 | messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
139 | messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
140 | }
141 |
142 | failures.push(failure);
143 | }
144 |
145 | if (result.status == 'pending') {
146 | pendingSpecCount++;
147 | }
148 | };
149 |
150 | this.jasmineDone = function(doneResult) {
151 | var banner = find('.jasmine-banner');
152 | var alert = find('.jasmine-alert');
153 | var order = doneResult && doneResult.order;
154 | alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
155 |
156 | banner.appendChild(
157 | createDom('div', { className: 'jasmine-run-options' },
158 | createDom('span', { className: 'jasmine-trigger' }, 'Options'),
159 | createDom('div', { className: 'jasmine-payload' },
160 | createDom('div', { className: 'jasmine-exceptions' },
161 | createDom('input', {
162 | className: 'jasmine-raise',
163 | id: 'jasmine-raise-exceptions',
164 | type: 'checkbox'
165 | }),
166 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-raise-exceptions' }, 'raise exceptions')),
167 | createDom('div', { className: 'jasmine-throw-failures' },
168 | createDom('input', {
169 | className: 'jasmine-throw',
170 | id: 'jasmine-throw-failures',
171 | type: 'checkbox'
172 | }),
173 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
174 | createDom('div', { className: 'jasmine-random-order' },
175 | createDom('input', {
176 | className: 'jasmine-random',
177 | id: 'jasmine-random-order',
178 | type: 'checkbox'
179 | }),
180 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order'))
181 | )
182 | ));
183 |
184 | var raiseCheckbox = find('#jasmine-raise-exceptions');
185 |
186 | raiseCheckbox.checked = !env.catchingExceptions();
187 | raiseCheckbox.onclick = onRaiseExceptionsClick;
188 |
189 | var throwCheckbox = find('#jasmine-throw-failures');
190 | throwCheckbox.checked = env.throwingExpectationFailures();
191 | throwCheckbox.onclick = onThrowExpectationsClick;
192 |
193 | var randomCheckbox = find('#jasmine-random-order');
194 | randomCheckbox.checked = env.randomTests();
195 | randomCheckbox.onclick = onRandomClick;
196 |
197 | var optionsMenu = find('.jasmine-run-options'),
198 | optionsTrigger = optionsMenu.querySelector('.jasmine-trigger'),
199 | optionsPayload = optionsMenu.querySelector('.jasmine-payload'),
200 | isOpen = /\bjasmine-open\b/;
201 |
202 | optionsTrigger.onclick = function() {
203 | if (isOpen.test(optionsPayload.className)) {
204 | optionsPayload.className = optionsPayload.className.replace(isOpen, '');
205 | } else {
206 | optionsPayload.className += ' jasmine-open';
207 | }
208 | };
209 |
210 | if (specsExecuted < totalSpecsDefined) {
211 | var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
212 | var skippedLink = order && order.random ? '?random=true' : '?';
213 | alert.appendChild(
214 | createDom('span', {className: 'jasmine-bar jasmine-skipped'},
215 | createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)
216 | )
217 | );
218 | }
219 | var statusBarMessage = '';
220 | var statusBarClassName = 'jasmine-bar ';
221 |
222 | if (totalSpecsDefined > 0) {
223 | statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
224 | if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
225 | statusBarClassName += (failureCount > 0) ? 'jasmine-failed' : 'jasmine-passed';
226 | } else {
227 | statusBarClassName += 'jasmine-skipped';
228 | statusBarMessage += 'No specs found';
229 | }
230 |
231 | var seedBar;
232 | if (order && order.random) {
233 | seedBar = createDom('span', {className: 'jasmine-seed-bar'},
234 | ', randomized with seed ',
235 | createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
236 | );
237 | }
238 |
239 | alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
240 |
241 | var errorBarClassName = 'jasmine-bar jasmine-errored';
242 | var errorBarMessagePrefix = 'AfterAll ';
243 |
244 | for(var i = 0; i < failedSuites.length; i++) {
245 | var failedSuite = failedSuites[i];
246 | for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
247 | alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failedSuite.failedExpectations[j].message));
248 | }
249 | }
250 |
251 | var globalFailures = (doneResult && doneResult.failedExpectations) || [];
252 | for(i = 0; i < globalFailures.length; i++) {
253 | var failure = globalFailures[i];
254 | alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
255 | }
256 |
257 | var results = find('.jasmine-results');
258 | results.appendChild(summary);
259 |
260 | summaryList(topResults, summary);
261 |
262 | function summaryList(resultsTree, domParent) {
263 | var specListNode;
264 | for (var i = 0; i < resultsTree.children.length; i++) {
265 | var resultNode = resultsTree.children[i];
266 | if (resultNode.type == 'suite') {
267 | var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
268 | createDom('li', {className: 'jasmine-suite-detail'},
269 | createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
270 | )
271 | );
272 |
273 | summaryList(resultNode, suiteListNode);
274 | domParent.appendChild(suiteListNode);
275 | }
276 | if (resultNode.type == 'spec') {
277 | if (domParent.getAttribute('class') != 'jasmine-specs') {
278 | specListNode = createDom('ul', {className: 'jasmine-specs'});
279 | domParent.appendChild(specListNode);
280 | }
281 | var specDescription = resultNode.result.description;
282 | if(noExpectations(resultNode.result)) {
283 | specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
284 | }
285 | if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
286 | specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
287 | }
288 | specListNode.appendChild(
289 | createDom('li', {
290 | className: 'jasmine-' + resultNode.result.status,
291 | id: 'spec-' + resultNode.result.id
292 | },
293 | createDom('a', {href: specHref(resultNode.result)}, specDescription)
294 | )
295 | );
296 | }
297 | }
298 | }
299 |
300 | if (failures.length) {
301 | alert.appendChild(
302 | createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
303 | createDom('span', {}, 'Spec List | '),
304 | createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
305 | alert.appendChild(
306 | createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
307 | createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
308 | createDom('span', {}, ' | Failures ')));
309 |
310 | find('.jasmine-failures-menu').onclick = function() {
311 | setMenuModeTo('jasmine-failure-list');
312 | };
313 | find('.jasmine-spec-list-menu').onclick = function() {
314 | setMenuModeTo('jasmine-spec-list');
315 | };
316 |
317 | setMenuModeTo('jasmine-failure-list');
318 |
319 | var failureNode = find('.jasmine-failures');
320 | for (i = 0; i < failures.length; i++) {
321 | failureNode.appendChild(failures[i]);
322 | }
323 | }
324 | };
325 |
326 | return this;
327 |
328 | function find(selector) {
329 | return getContainer().querySelector('.jasmine_html-reporter ' + selector);
330 | }
331 |
332 | function clearPrior() {
333 | // return the reporter
334 | var oldReporter = find('');
335 |
336 | if(oldReporter) {
337 | getContainer().removeChild(oldReporter);
338 | }
339 | }
340 |
341 | function createDom(type, attrs, childrenVarArgs) {
342 | var el = createElement(type);
343 |
344 | for (var i = 2; i < arguments.length; i++) {
345 | var child = arguments[i];
346 |
347 | if (typeof child === 'string') {
348 | el.appendChild(createTextNode(child));
349 | } else {
350 | if (child) {
351 | el.appendChild(child);
352 | }
353 | }
354 | }
355 |
356 | for (var attr in attrs) {
357 | if (attr == 'className') {
358 | el[attr] = attrs[attr];
359 | } else {
360 | el.setAttribute(attr, attrs[attr]);
361 | }
362 | }
363 |
364 | return el;
365 | }
366 |
367 | function pluralize(singular, count) {
368 | var word = (count == 1 ? singular : singular + 's');
369 |
370 | return '' + count + ' ' + word;
371 | }
372 |
373 | function specHref(result) {
374 | return addToExistingQueryString('spec', result.fullName);
375 | }
376 |
377 | function seedHref(seed) {
378 | return addToExistingQueryString('seed', seed);
379 | }
380 |
381 | function defaultQueryString(key, value) {
382 | return '?' + key + '=' + value;
383 | }
384 |
385 | function setMenuModeTo(mode) {
386 | htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
387 | }
388 |
389 | function noExpectations(result) {
390 | return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
391 | result.status === 'passed';
392 | }
393 | }
394 |
395 | return HtmlReporter;
396 | };
397 |
398 | jasmineRequire.HtmlSpecFilter = function() {
399 | function HtmlSpecFilter(options) {
400 | var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
401 | var filterPattern = new RegExp(filterString);
402 |
403 | this.matches = function(specName) {
404 | return filterPattern.test(specName);
405 | };
406 | }
407 |
408 | return HtmlSpecFilter;
409 | };
410 |
411 | jasmineRequire.ResultsNode = function() {
412 | function ResultsNode(result, type, parent) {
413 | this.result = result;
414 | this.type = type;
415 | this.parent = parent;
416 |
417 | this.children = [];
418 |
419 | this.addChild = function(result, type) {
420 | this.children.push(new ResultsNode(result, type, this));
421 | };
422 |
423 | this.last = function() {
424 | return this.children[this.children.length - 1];
425 | };
426 | }
427 |
428 | return ResultsNode;
429 | };
430 |
431 | jasmineRequire.QueryString = function() {
432 | function QueryString(options) {
433 |
434 | this.navigateWithNewParam = function(key, value) {
435 | options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
436 | };
437 |
438 | this.fullStringWithNewParam = function(key, value) {
439 | var paramMap = queryStringToParamMap();
440 | paramMap[key] = value;
441 | return toQueryString(paramMap);
442 | };
443 |
444 | this.getParam = function(key) {
445 | return queryStringToParamMap()[key];
446 | };
447 |
448 | return this;
449 |
450 | function toQueryString(paramMap) {
451 | var qStrPairs = [];
452 | for (var prop in paramMap) {
453 | qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
454 | }
455 | return '?' + qStrPairs.join('&');
456 | }
457 |
458 | function queryStringToParamMap() {
459 | var paramStr = options.getWindowLocation().search.substring(1),
460 | params = [],
461 | paramMap = {};
462 |
463 | if (paramStr.length > 0) {
464 | params = paramStr.split('&');
465 | for (var i = 0; i < params.length; i++) {
466 | var p = params[i].split('=');
467 | var value = decodeURIComponent(p[1]);
468 | if (value === 'true' || value === 'false') {
469 | value = JSON.parse(value);
470 | }
471 | paramMap[decodeURIComponent(p[0])] = value;
472 | }
473 | }
474 |
475 | return paramMap;
476 | }
477 |
478 | }
479 |
480 | return QueryString;
481 | };
482 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/jasmine.css:
--------------------------------------------------------------------------------
1 | body { overflow-y: scroll; }
2 |
3 | .jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
4 | .jasmine_html-reporter a { text-decoration: none; }
5 | .jasmine_html-reporter a:hover { text-decoration: underline; }
6 | .jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; }
7 | .jasmine_html-reporter .jasmine-banner, .jasmine_html-reporter .jasmine-symbol-summary, .jasmine_html-reporter .jasmine-summary, .jasmine_html-reporter .jasmine-result-message, .jasmine_html-reporter .jasmine-spec .jasmine-description, .jasmine_html-reporter .jasmine-spec-detail .jasmine-description, .jasmine_html-reporter .jasmine-alert .jasmine-bar, .jasmine_html-reporter .jasmine-stack-trace { padding-left: 9px; padding-right: 9px; }
8 | .jasmine_html-reporter .jasmine-banner { position: relative; }
9 | .jasmine_html-reporter .jasmine-banner .jasmine-title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4KIQoSKQYKIQICIQISMQoSKQYKLQIOLQoOJQYGLQIOKQIOMQoGKQYOLQYGKQIOLQoGJQYOJQIOKQYGJQIOKQoGKQIGLQIKLQ4KKQoGLQYKJQIGKQYKJQIGKQIKJQoGKQYKLQIGKQYKLQIOJQoKKQoOJQYKKQIOJQoKKQoOKQIOLQoKKQYOLQYKJQIOKQoKKQYKKQoKJQYOKQYKLQIOKQoKLQYOKQYKLQIOJQoGKQYKJQYGJQoGKQYKLQoGLQYGKQoGJQYKKQYGJQIKKQoGJQYKLQIKKQYGLQYKKQYGKQYGKQYKJQYOKQoKJQYOKQYKLQYOLQYOKQYKLQYOKQoKKQYKKQYOKQYOJQYKKQYKLQYKKQIKKQoKKQYKKQYKKQoKJQIKKQYKLQYKKQYKKQIKKQYKKQYKKQYKKQIKKQYKJQYGLQYGKQYKKQYKKQYGKQIKKQYGKQYOJQoKKQYOLQYKKQYOKQoKKQYKKQoKKQYKKQYKJQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKJQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKmIDpEAAAA0XRSTlMAAQIDBAUGBwgJCgsMD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N1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -moz-background-size: 100%; -o-background-size: 100%; -webkit-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; }
10 | .jasmine_html-reporter .jasmine-banner .jasmine-version { margin-left: 14px; position: relative; top: 6px; }
11 | .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; }
12 | .jasmine_html-reporter .jasmine-version { color: #aaa; }
13 | .jasmine_html-reporter .jasmine-banner { margin-top: 14px; }
14 | .jasmine_html-reporter .jasmine-duration { color: #fff; float: right; line-height: 28px; padding-right: 9px; }
15 | .jasmine_html-reporter .jasmine-symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
16 | .jasmine_html-reporter .jasmine-symbol-summary li { display: inline-block; height: 10px; width: 14px; font-size: 16px; }
17 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed { font-size: 14px; }
18 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: "\02022"; }
19 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed { line-height: 9px; }
20 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
21 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-disabled { font-size: 14px; }
22 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-disabled:before { color: #bababa; content: "\02022"; }
23 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending { line-height: 17px; }
24 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before { color: #ba9d37; content: "*"; }
25 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty { font-size: 14px; }
26 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: "\02022"; }
27 | .jasmine_html-reporter .jasmine-run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; }
28 | .jasmine_html-reporter .jasmine-run-options .jasmine-trigger { cursor: pointer; padding: 8px 16px; }
29 | .jasmine_html-reporter .jasmine-run-options .jasmine-payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; }
30 | .jasmine_html-reporter .jasmine-run-options .jasmine-payload.jasmine-open { display: block; }
31 | .jasmine_html-reporter .jasmine-bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
32 | .jasmine_html-reporter .jasmine-bar.jasmine-failed { background-color: #ca3a11; }
33 | .jasmine_html-reporter .jasmine-bar.jasmine-passed { background-color: #007069; }
34 | .jasmine_html-reporter .jasmine-bar.jasmine-skipped { background-color: #bababa; }
35 | .jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; }
36 | .jasmine_html-reporter .jasmine-bar.jasmine-menu { background-color: #fff; color: #aaa; }
37 | .jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; }
38 | .jasmine_html-reporter .jasmine-bar a { color: white; }
39 | .jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list, .jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures { display: none; }
40 | .jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list, .jasmine_html-reporter.jasmine-failure-list .jasmine-summary { display: none; }
41 | .jasmine_html-reporter .jasmine-results { margin-top: 14px; }
42 | .jasmine_html-reporter .jasmine-summary { margin-top: 14px; }
43 | .jasmine_html-reporter .jasmine-summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
44 | .jasmine_html-reporter .jasmine-summary ul.jasmine-suite { margin-top: 7px; margin-bottom: 7px; }
45 | .jasmine_html-reporter .jasmine-summary li.jasmine-passed a { color: #007069; }
46 | .jasmine_html-reporter .jasmine-summary li.jasmine-failed a { color: #ca3a11; }
47 | .jasmine_html-reporter .jasmine-summary li.jasmine-empty a { color: #ba9d37; }
48 | .jasmine_html-reporter .jasmine-summary li.jasmine-pending a { color: #ba9d37; }
49 | .jasmine_html-reporter .jasmine-summary li.jasmine-disabled a { color: #bababa; }
50 | .jasmine_html-reporter .jasmine-description + .jasmine-suite { margin-top: 0; }
51 | .jasmine_html-reporter .jasmine-suite { margin-top: 14px; }
52 | .jasmine_html-reporter .jasmine-suite a { color: #333; }
53 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail { margin-bottom: 28px; }
54 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail .jasmine-description { background-color: #ca3a11; }
55 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail .jasmine-description a { color: white; }
56 | .jasmine_html-reporter .jasmine-result-message { padding-top: 14px; color: #333; white-space: pre; }
57 | .jasmine_html-reporter .jasmine-result-message span.jasmine-result { display: block; }
58 | .jasmine_html-reporter .jasmine-stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666; border: 1px solid #ddd; background: white; white-space: pre; }
59 |
--------------------------------------------------------------------------------
/jasmine-lib/jasmine-core/jasmine.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2016 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | var getJasmineRequireObj = (function (jasmineGlobal) {
24 | var jasmineRequire;
25 |
26 | if (typeof module !== 'undefined' && module.exports && typeof exports !== 'undefined') {
27 | if (typeof global !== 'undefined') {
28 | jasmineGlobal = global;
29 | } else {
30 | jasmineGlobal = {};
31 | }
32 | jasmineRequire = exports;
33 | } else {
34 | if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
35 | jasmineGlobal = window;
36 | }
37 | jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
38 | }
39 |
40 | function getJasmineRequire() {
41 | return jasmineRequire;
42 | }
43 |
44 | getJasmineRequire().core = function(jRequire) {
45 | var j$ = {};
46 |
47 | jRequire.base(j$, jasmineGlobal);
48 | j$.util = jRequire.util();
49 | j$.errors = jRequire.errors();
50 | j$.formatErrorMsg = jRequire.formatErrorMsg();
51 | j$.Any = jRequire.Any(j$);
52 | j$.Anything = jRequire.Anything(j$);
53 | j$.CallTracker = jRequire.CallTracker(j$);
54 | j$.MockDate = jRequire.MockDate();
55 | j$.Clock = jRequire.Clock();
56 | j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
57 | j$.Env = jRequire.Env(j$);
58 | j$.ExceptionFormatter = jRequire.ExceptionFormatter();
59 | j$.Expectation = jRequire.Expectation();
60 | j$.buildExpectationResult = jRequire.buildExpectationResult();
61 | j$.JsApiReporter = jRequire.JsApiReporter();
62 | j$.matchersUtil = jRequire.matchersUtil(j$);
63 | j$.ObjectContaining = jRequire.ObjectContaining(j$);
64 | j$.ArrayContaining = jRequire.ArrayContaining(j$);
65 | j$.pp = jRequire.pp(j$);
66 | j$.QueueRunner = jRequire.QueueRunner(j$);
67 | j$.ReportDispatcher = jRequire.ReportDispatcher();
68 | j$.Spec = jRequire.Spec(j$);
69 | j$.SpyRegistry = jRequire.SpyRegistry(j$);
70 | j$.SpyStrategy = jRequire.SpyStrategy();
71 | j$.StringMatching = jRequire.StringMatching(j$);
72 | j$.Suite = jRequire.Suite(j$);
73 | j$.Timer = jRequire.Timer();
74 | j$.TreeProcessor = jRequire.TreeProcessor();
75 | j$.version = jRequire.version();
76 | j$.Order = jRequire.Order();
77 |
78 | j$.matchers = jRequire.requireMatchers(jRequire, j$);
79 |
80 | return j$;
81 | };
82 |
83 | return getJasmineRequire;
84 | })(this);
85 |
86 | getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
87 | var availableMatchers = [
88 | 'toBe',
89 | 'toBeCloseTo',
90 | 'toBeDefined',
91 | 'toBeFalsy',
92 | 'toBeGreaterThan',
93 | 'toBeGreaterThanOrEqual',
94 | 'toBeLessThanOrEqual',
95 | 'toBeLessThan',
96 | 'toBeNaN',
97 | 'toBeNull',
98 | 'toBeTruthy',
99 | 'toBeUndefined',
100 | 'toContain',
101 | 'toEqual',
102 | 'toHaveBeenCalled',
103 | 'toHaveBeenCalledWith',
104 | 'toHaveBeenCalledTimes',
105 | 'toMatch',
106 | 'toThrow',
107 | 'toThrowError'
108 | ],
109 | matchers = {};
110 |
111 | for (var i = 0; i < availableMatchers.length; i++) {
112 | var name = availableMatchers[i];
113 | matchers[name] = jRequire[name](j$);
114 | }
115 |
116 | return matchers;
117 | };
118 |
119 | getJasmineRequireObj().base = function(j$, jasmineGlobal) {
120 | j$.unimplementedMethod_ = function() {
121 | throw new Error('unimplemented method');
122 | };
123 |
124 | j$.MAX_PRETTY_PRINT_DEPTH = 40;
125 | j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100;
126 | j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
127 |
128 | j$.getGlobal = function() {
129 | return jasmineGlobal;
130 | };
131 |
132 | j$.getEnv = function(options) {
133 | var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
134 | //jasmine. singletons in here (setTimeout blah blah).
135 | return env;
136 | };
137 |
138 | j$.isArray_ = function(value) {
139 | return j$.isA_('Array', value);
140 | };
141 |
142 | j$.isString_ = function(value) {
143 | return j$.isA_('String', value);
144 | };
145 |
146 | j$.isNumber_ = function(value) {
147 | return j$.isA_('Number', value);
148 | };
149 |
150 | j$.isA_ = function(typeName, value) {
151 | return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
152 | };
153 |
154 | j$.isDomNode = function(obj) {
155 | return obj.nodeType > 0;
156 | };
157 |
158 | j$.fnNameFor = function(func) {
159 | if (func.name) {
160 | return func.name;
161 | }
162 |
163 | var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
164 | return matches ? matches[1] : '';
165 | };
166 |
167 | j$.any = function(clazz) {
168 | return new j$.Any(clazz);
169 | };
170 |
171 | j$.anything = function() {
172 | return new j$.Anything();
173 | };
174 |
175 | j$.objectContaining = function(sample) {
176 | return new j$.ObjectContaining(sample);
177 | };
178 |
179 | j$.stringMatching = function(expected) {
180 | return new j$.StringMatching(expected);
181 | };
182 |
183 | j$.arrayContaining = function(sample) {
184 | return new j$.ArrayContaining(sample);
185 | };
186 |
187 | j$.createSpy = function(name, originalFn) {
188 |
189 | var spyStrategy = new j$.SpyStrategy({
190 | name: name,
191 | fn: originalFn,
192 | getSpy: function() { return spy; }
193 | }),
194 | callTracker = new j$.CallTracker(),
195 | spy = function() {
196 | var callData = {
197 | object: this,
198 | args: Array.prototype.slice.apply(arguments)
199 | };
200 |
201 | callTracker.track(callData);
202 | var returnValue = spyStrategy.exec.apply(this, arguments);
203 | callData.returnValue = returnValue;
204 |
205 | return returnValue;
206 | };
207 |
208 | for (var prop in originalFn) {
209 | if (prop === 'and' || prop === 'calls') {
210 | throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon');
211 | }
212 |
213 | spy[prop] = originalFn[prop];
214 | }
215 |
216 | spy.and = spyStrategy;
217 | spy.calls = callTracker;
218 |
219 | return spy;
220 | };
221 |
222 | j$.isSpy = function(putativeSpy) {
223 | if (!putativeSpy) {
224 | return false;
225 | }
226 | return putativeSpy.and instanceof j$.SpyStrategy &&
227 | putativeSpy.calls instanceof j$.CallTracker;
228 | };
229 |
230 | j$.createSpyObj = function(baseName, methodNames) {
231 | if (j$.isArray_(baseName) && j$.util.isUndefined(methodNames)) {
232 | methodNames = baseName;
233 | baseName = 'unknown';
234 | }
235 |
236 | if (!j$.isArray_(methodNames) || methodNames.length === 0) {
237 | throw 'createSpyObj requires a non-empty array of method names to create spies for';
238 | }
239 | var obj = {};
240 | for (var i = 0; i < methodNames.length; i++) {
241 | obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
242 | }
243 | return obj;
244 | };
245 | };
246 |
247 | getJasmineRequireObj().util = function() {
248 |
249 | var util = {};
250 |
251 | util.inherit = function(childClass, parentClass) {
252 | var Subclass = function() {
253 | };
254 | Subclass.prototype = parentClass.prototype;
255 | childClass.prototype = new Subclass();
256 | };
257 |
258 | util.htmlEscape = function(str) {
259 | if (!str) {
260 | return str;
261 | }
262 | return str.replace(/&/g, '&')
263 | .replace(//g, '>');
265 | };
266 |
267 | util.argsToArray = function(args) {
268 | var arrayOfArgs = [];
269 | for (var i = 0; i < args.length; i++) {
270 | arrayOfArgs.push(args[i]);
271 | }
272 | return arrayOfArgs;
273 | };
274 |
275 | util.isUndefined = function(obj) {
276 | return obj === void 0;
277 | };
278 |
279 | util.arrayContains = function(array, search) {
280 | var i = array.length;
281 | while (i--) {
282 | if (array[i] === search) {
283 | return true;
284 | }
285 | }
286 | return false;
287 | };
288 |
289 | util.clone = function(obj) {
290 | if (Object.prototype.toString.apply(obj) === '[object Array]') {
291 | return obj.slice();
292 | }
293 |
294 | var cloned = {};
295 | for (var prop in obj) {
296 | if (obj.hasOwnProperty(prop)) {
297 | cloned[prop] = obj[prop];
298 | }
299 | }
300 |
301 | return cloned;
302 | };
303 |
304 | return util;
305 | };
306 |
307 | getJasmineRequireObj().Spec = function(j$) {
308 | function Spec(attrs) {
309 | this.expectationFactory = attrs.expectationFactory;
310 | this.resultCallback = attrs.resultCallback || function() {};
311 | this.id = attrs.id;
312 | this.description = attrs.description || '';
313 | this.queueableFn = attrs.queueableFn;
314 | this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
315 | this.userContext = attrs.userContext || function() { return {}; };
316 | this.onStart = attrs.onStart || function() {};
317 | this.getSpecName = attrs.getSpecName || function() { return ''; };
318 | this.expectationResultFactory = attrs.expectationResultFactory || function() { };
319 | this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
320 | this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
321 | this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
322 |
323 | if (!this.queueableFn.fn) {
324 | this.pend();
325 | }
326 |
327 | this.result = {
328 | id: this.id,
329 | description: this.description,
330 | fullName: this.getFullName(),
331 | failedExpectations: [],
332 | passedExpectations: [],
333 | pendingReason: ''
334 | };
335 | }
336 |
337 | Spec.prototype.addExpectationResult = function(passed, data, isError) {
338 | var expectationResult = this.expectationResultFactory(data);
339 | if (passed) {
340 | this.result.passedExpectations.push(expectationResult);
341 | } else {
342 | this.result.failedExpectations.push(expectationResult);
343 |
344 | if (this.throwOnExpectationFailure && !isError) {
345 | throw new j$.errors.ExpectationFailed();
346 | }
347 | }
348 | };
349 |
350 | Spec.prototype.expect = function(actual) {
351 | return this.expectationFactory(actual, this);
352 | };
353 |
354 | Spec.prototype.execute = function(onComplete, enabled) {
355 | var self = this;
356 |
357 | this.onStart(this);
358 |
359 | if (!this.isExecutable() || this.markedPending || enabled === false) {
360 | complete(enabled);
361 | return;
362 | }
363 |
364 | var fns = this.beforeAndAfterFns();
365 | var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
366 |
367 | this.queueRunnerFactory({
368 | queueableFns: allFns,
369 | onException: function() { self.onException.apply(self, arguments); },
370 | onComplete: complete,
371 | userContext: this.userContext()
372 | });
373 |
374 | function complete(enabledAgain) {
375 | self.result.status = self.status(enabledAgain);
376 | self.resultCallback(self.result);
377 |
378 | if (onComplete) {
379 | onComplete();
380 | }
381 | }
382 | };
383 |
384 | Spec.prototype.onException = function onException(e) {
385 | if (Spec.isPendingSpecException(e)) {
386 | this.pend(extractCustomPendingMessage(e));
387 | return;
388 | }
389 |
390 | if (e instanceof j$.errors.ExpectationFailed) {
391 | return;
392 | }
393 |
394 | this.addExpectationResult(false, {
395 | matcherName: '',
396 | passed: false,
397 | expected: '',
398 | actual: '',
399 | error: e
400 | }, true);
401 | };
402 |
403 | Spec.prototype.disable = function() {
404 | this.disabled = true;
405 | };
406 |
407 | Spec.prototype.pend = function(message) {
408 | this.markedPending = true;
409 | if (message) {
410 | this.result.pendingReason = message;
411 | }
412 | };
413 |
414 | Spec.prototype.getResult = function() {
415 | this.result.status = this.status();
416 | return this.result;
417 | };
418 |
419 | Spec.prototype.status = function(enabled) {
420 | if (this.disabled || enabled === false) {
421 | return 'disabled';
422 | }
423 |
424 | if (this.markedPending) {
425 | return 'pending';
426 | }
427 |
428 | if (this.result.failedExpectations.length > 0) {
429 | return 'failed';
430 | } else {
431 | return 'passed';
432 | }
433 | };
434 |
435 | Spec.prototype.isExecutable = function() {
436 | return !this.disabled;
437 | };
438 |
439 | Spec.prototype.getFullName = function() {
440 | return this.getSpecName(this);
441 | };
442 |
443 | var extractCustomPendingMessage = function(e) {
444 | var fullMessage = e.toString(),
445 | boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
446 | boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length;
447 |
448 | return fullMessage.substr(boilerplateEnd);
449 | };
450 |
451 | Spec.pendingSpecExceptionMessage = '=> marked Pending';
452 |
453 | Spec.isPendingSpecException = function(e) {
454 | return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1);
455 | };
456 |
457 | return Spec;
458 | };
459 |
460 | if (typeof window == void 0 && typeof exports == 'object') {
461 | exports.Spec = jasmineRequire.Spec;
462 | }
463 |
464 | /*jshint bitwise: false*/
465 |
466 | getJasmineRequireObj().Order = function() {
467 | function Order(options) {
468 | this.random = 'random' in options ? options.random : true;
469 | var seed = this.seed = options.seed || generateSeed();
470 | this.sort = this.random ? randomOrder : naturalOrder;
471 |
472 | function naturalOrder(items) {
473 | return items;
474 | }
475 |
476 | function randomOrder(items) {
477 | var copy = items.slice();
478 | copy.sort(function(a, b) {
479 | return jenkinsHash(seed + a.id) - jenkinsHash(seed + b.id);
480 | });
481 | return copy;
482 | }
483 |
484 | function generateSeed() {
485 | return String(Math.random()).slice(-5);
486 | }
487 |
488 | // Bob Jenkins One-at-a-Time Hash algorithm is a non-cryptographic hash function
489 | // used to get a different output when the key changes slighly.
490 | // We use your return to sort the children randomly in a consistent way when
491 | // used in conjunction with a seed
492 |
493 | function jenkinsHash(key) {
494 | var hash, i;
495 | for(hash = i = 0; i < key.length; ++i) {
496 | hash += key.charCodeAt(i);
497 | hash += (hash << 10);
498 | hash ^= (hash >> 6);
499 | }
500 | hash += (hash << 3);
501 | hash ^= (hash >> 11);
502 | hash += (hash << 15);
503 | return hash;
504 | }
505 |
506 | }
507 |
508 | return Order;
509 | };
510 |
511 | getJasmineRequireObj().Env = function(j$) {
512 | function Env(options) {
513 | options = options || {};
514 |
515 | var self = this;
516 | var global = options.global || j$.getGlobal();
517 |
518 | var totalSpecsDefined = 0;
519 |
520 | var catchExceptions = true;
521 |
522 | var realSetTimeout = j$.getGlobal().setTimeout;
523 | var realClearTimeout = j$.getGlobal().clearTimeout;
524 | this.clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
525 |
526 | var runnableResources = {};
527 |
528 | var currentSpec = null;
529 | var currentlyExecutingSuites = [];
530 | var currentDeclarationSuite = null;
531 | var throwOnExpectationFailure = false;
532 | var random = false;
533 | var seed = null;
534 |
535 | var currentSuite = function() {
536 | return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
537 | };
538 |
539 | var currentRunnable = function() {
540 | return currentSpec || currentSuite();
541 | };
542 |
543 | var reporter = new j$.ReportDispatcher([
544 | 'jasmineStarted',
545 | 'jasmineDone',
546 | 'suiteStarted',
547 | 'suiteDone',
548 | 'specStarted',
549 | 'specDone'
550 | ]);
551 |
552 | this.specFilter = function() {
553 | return true;
554 | };
555 |
556 | this.addCustomEqualityTester = function(tester) {
557 | if(!currentRunnable()) {
558 | throw new Error('Custom Equalities must be added in a before function or a spec');
559 | }
560 | runnableResources[currentRunnable().id].customEqualityTesters.push(tester);
561 | };
562 |
563 | this.addMatchers = function(matchersToAdd) {
564 | if(!currentRunnable()) {
565 | throw new Error('Matchers must be added in a before function or a spec');
566 | }
567 | var customMatchers = runnableResources[currentRunnable().id].customMatchers;
568 | for (var matcherName in matchersToAdd) {
569 | customMatchers[matcherName] = matchersToAdd[matcherName];
570 | }
571 | };
572 |
573 | j$.Expectation.addCoreMatchers(j$.matchers);
574 |
575 | var nextSpecId = 0;
576 | var getNextSpecId = function() {
577 | return 'spec' + nextSpecId++;
578 | };
579 |
580 | var nextSuiteId = 0;
581 | var getNextSuiteId = function() {
582 | return 'suite' + nextSuiteId++;
583 | };
584 |
585 | var expectationFactory = function(actual, spec) {
586 | return j$.Expectation.Factory({
587 | util: j$.matchersUtil,
588 | customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
589 | customMatchers: runnableResources[spec.id].customMatchers,
590 | actual: actual,
591 | addExpectationResult: addExpectationResult
592 | });
593 |
594 | function addExpectationResult(passed, result) {
595 | return spec.addExpectationResult(passed, result);
596 | }
597 | };
598 |
599 | var defaultResourcesForRunnable = function(id, parentRunnableId) {
600 | var resources = {spies: [], customEqualityTesters: [], customMatchers: {}};
601 |
602 | if(runnableResources[parentRunnableId]){
603 | resources.customEqualityTesters = j$.util.clone(runnableResources[parentRunnableId].customEqualityTesters);
604 | resources.customMatchers = j$.util.clone(runnableResources[parentRunnableId].customMatchers);
605 | }
606 |
607 | runnableResources[id] = resources;
608 | };
609 |
610 | var clearResourcesForRunnable = function(id) {
611 | spyRegistry.clearSpies();
612 | delete runnableResources[id];
613 | };
614 |
615 | var beforeAndAfterFns = function(suite) {
616 | return function() {
617 | var befores = [],
618 | afters = [];
619 |
620 | while(suite) {
621 | befores = befores.concat(suite.beforeFns);
622 | afters = afters.concat(suite.afterFns);
623 |
624 | suite = suite.parentSuite;
625 | }
626 |
627 | return {
628 | befores: befores.reverse(),
629 | afters: afters
630 | };
631 | };
632 | };
633 |
634 | var getSpecName = function(spec, suite) {
635 | var fullName = [spec.description],
636 | suiteFullName = suite.getFullName();
637 |
638 | if (suiteFullName !== '') {
639 | fullName.unshift(suiteFullName);
640 | }
641 | return fullName.join(' ');
642 | };
643 |
644 | // TODO: we may just be able to pass in the fn instead of wrapping here
645 | var buildExpectationResult = j$.buildExpectationResult,
646 | exceptionFormatter = new j$.ExceptionFormatter(),
647 | expectationResultFactory = function(attrs) {
648 | attrs.messageFormatter = exceptionFormatter.message;
649 | attrs.stackFormatter = exceptionFormatter.stack;
650 |
651 | return buildExpectationResult(attrs);
652 | };
653 |
654 | // TODO: fix this naming, and here's where the value comes in
655 | this.catchExceptions = function(value) {
656 | catchExceptions = !!value;
657 | return catchExceptions;
658 | };
659 |
660 | this.catchingExceptions = function() {
661 | return catchExceptions;
662 | };
663 |
664 | var maximumSpecCallbackDepth = 20;
665 | var currentSpecCallbackDepth = 0;
666 |
667 | function clearStack(fn) {
668 | currentSpecCallbackDepth++;
669 | if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) {
670 | currentSpecCallbackDepth = 0;
671 | realSetTimeout(fn, 0);
672 | } else {
673 | fn();
674 | }
675 | }
676 |
677 | var catchException = function(e) {
678 | return j$.Spec.isPendingSpecException(e) || catchExceptions;
679 | };
680 |
681 | this.throwOnExpectationFailure = function(value) {
682 | throwOnExpectationFailure = !!value;
683 | };
684 |
685 | this.throwingExpectationFailures = function() {
686 | return throwOnExpectationFailure;
687 | };
688 |
689 | this.randomizeTests = function(value) {
690 | random = !!value;
691 | };
692 |
693 | this.randomTests = function() {
694 | return random;
695 | };
696 |
697 | this.seed = function(value) {
698 | if (value) {
699 | seed = value;
700 | }
701 | return seed;
702 | };
703 |
704 | var queueRunnerFactory = function(options) {
705 | options.catchException = catchException;
706 | options.clearStack = options.clearStack || clearStack;
707 | options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
708 | options.fail = self.fail;
709 |
710 | new j$.QueueRunner(options).execute();
711 | };
712 |
713 | var topSuite = new j$.Suite({
714 | env: this,
715 | id: getNextSuiteId(),
716 | description: 'Jasmine__TopLevel__Suite',
717 | expectationFactory: expectationFactory,
718 | expectationResultFactory: expectationResultFactory
719 | });
720 | defaultResourcesForRunnable(topSuite.id);
721 | currentDeclarationSuite = topSuite;
722 |
723 | this.topSuite = function() {
724 | return topSuite;
725 | };
726 |
727 | this.execute = function(runnablesToRun) {
728 | if(!runnablesToRun) {
729 | if (focusedRunnables.length) {
730 | runnablesToRun = focusedRunnables;
731 | } else {
732 | runnablesToRun = [topSuite.id];
733 | }
734 | }
735 |
736 | var order = new j$.Order({
737 | random: random,
738 | seed: seed
739 | });
740 |
741 | var processor = new j$.TreeProcessor({
742 | tree: topSuite,
743 | runnableIds: runnablesToRun,
744 | queueRunnerFactory: queueRunnerFactory,
745 | nodeStart: function(suite) {
746 | currentlyExecutingSuites.push(suite);
747 | defaultResourcesForRunnable(suite.id, suite.parentSuite.id);
748 | reporter.suiteStarted(suite.result);
749 | },
750 | nodeComplete: function(suite, result) {
751 | if (!suite.disabled) {
752 | clearResourcesForRunnable(suite.id);
753 | }
754 | currentlyExecutingSuites.pop();
755 | reporter.suiteDone(result);
756 | },
757 | orderChildren: function(node) {
758 | return order.sort(node.children);
759 | }
760 | });
761 |
762 | if(!processor.processTree().valid) {
763 | throw new Error('Invalid order: would cause a beforeAll or afterAll to be run multiple times');
764 | }
765 |
766 | reporter.jasmineStarted({
767 | totalSpecsDefined: totalSpecsDefined
768 | });
769 |
770 | currentlyExecutingSuites.push(topSuite);
771 |
772 | processor.execute(function() {
773 | clearResourcesForRunnable(topSuite.id);
774 | currentlyExecutingSuites.pop();
775 |
776 | reporter.jasmineDone({
777 | order: order,
778 | failedExpectations: topSuite.result.failedExpectations
779 | });
780 | });
781 | };
782 |
783 | this.addReporter = function(reporterToAdd) {
784 | reporter.addReporter(reporterToAdd);
785 | };
786 |
787 | this.provideFallbackReporter = function(reporterToAdd) {
788 | reporter.provideFallbackReporter(reporterToAdd);
789 | };
790 |
791 | var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
792 | if(!currentRunnable()) {
793 | throw new Error('Spies must be created in a before function or a spec');
794 | }
795 | return runnableResources[currentRunnable().id].spies;
796 | }});
797 |
798 | this.allowRespy = function(allow){
799 | spyRegistry.allowRespy(allow);
800 | };
801 |
802 | this.spyOn = function() {
803 | return spyRegistry.spyOn.apply(spyRegistry, arguments);
804 | };
805 |
806 | var suiteFactory = function(description) {
807 | var suite = new j$.Suite({
808 | env: self,
809 | id: getNextSuiteId(),
810 | description: description,
811 | parentSuite: currentDeclarationSuite,
812 | expectationFactory: expectationFactory,
813 | expectationResultFactory: expectationResultFactory,
814 | throwOnExpectationFailure: throwOnExpectationFailure
815 | });
816 |
817 | return suite;
818 | };
819 |
820 | this.describe = function(description, specDefinitions) {
821 | var suite = suiteFactory(description);
822 | if (specDefinitions.length > 0) {
823 | throw new Error('describe does not expect any arguments');
824 | }
825 | if (currentDeclarationSuite.markedPending) {
826 | suite.pend();
827 | }
828 | addSpecsToSuite(suite, specDefinitions);
829 | return suite;
830 | };
831 |
832 | this.xdescribe = function(description, specDefinitions) {
833 | var suite = suiteFactory(description);
834 | suite.pend();
835 | addSpecsToSuite(suite, specDefinitions);
836 | return suite;
837 | };
838 |
839 | var focusedRunnables = [];
840 |
841 | this.fdescribe = function(description, specDefinitions) {
842 | var suite = suiteFactory(description);
843 | suite.isFocused = true;
844 |
845 | focusedRunnables.push(suite.id);
846 | unfocusAncestor();
847 | addSpecsToSuite(suite, specDefinitions);
848 |
849 | return suite;
850 | };
851 |
852 | function addSpecsToSuite(suite, specDefinitions) {
853 | var parentSuite = currentDeclarationSuite;
854 | parentSuite.addChild(suite);
855 | currentDeclarationSuite = suite;
856 |
857 | var declarationError = null;
858 | try {
859 | specDefinitions.call(suite);
860 | } catch (e) {
861 | declarationError = e;
862 | }
863 |
864 | if (declarationError) {
865 | self.it('encountered a declaration exception', function() {
866 | throw declarationError;
867 | });
868 | }
869 |
870 | currentDeclarationSuite = parentSuite;
871 | }
872 |
873 | function findFocusedAncestor(suite) {
874 | while (suite) {
875 | if (suite.isFocused) {
876 | return suite.id;
877 | }
878 | suite = suite.parentSuite;
879 | }
880 |
881 | return null;
882 | }
883 |
884 | function unfocusAncestor() {
885 | var focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
886 | if (focusedAncestor) {
887 | for (var i = 0; i < focusedRunnables.length; i++) {
888 | if (focusedRunnables[i] === focusedAncestor) {
889 | focusedRunnables.splice(i, 1);
890 | break;
891 | }
892 | }
893 | }
894 | }
895 |
896 | var specFactory = function(description, fn, suite, timeout) {
897 | totalSpecsDefined++;
898 | var spec = new j$.Spec({
899 | id: getNextSpecId(),
900 | beforeAndAfterFns: beforeAndAfterFns(suite),
901 | expectationFactory: expectationFactory,
902 | resultCallback: specResultCallback,
903 | getSpecName: function(spec) {
904 | return getSpecName(spec, suite);
905 | },
906 | onStart: specStarted,
907 | description: description,
908 | expectationResultFactory: expectationResultFactory,
909 | queueRunnerFactory: queueRunnerFactory,
910 | userContext: function() { return suite.clonedSharedUserContext(); },
911 | queueableFn: {
912 | fn: fn,
913 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
914 | },
915 | throwOnExpectationFailure: throwOnExpectationFailure
916 | });
917 |
918 | if (!self.specFilter(spec)) {
919 | spec.disable();
920 | }
921 |
922 | return spec;
923 |
924 | function specResultCallback(result) {
925 | clearResourcesForRunnable(spec.id);
926 | currentSpec = null;
927 | reporter.specDone(result);
928 | }
929 |
930 | function specStarted(spec) {
931 | currentSpec = spec;
932 | defaultResourcesForRunnable(spec.id, suite.id);
933 | reporter.specStarted(spec.result);
934 | }
935 | };
936 |
937 | this.it = function(description, fn, timeout) {
938 | var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
939 | if (currentDeclarationSuite.markedPending) {
940 | spec.pend();
941 | }
942 | currentDeclarationSuite.addChild(spec);
943 | return spec;
944 | };
945 |
946 | this.xit = function() {
947 | var spec = this.it.apply(this, arguments);
948 | spec.pend('Temporarily disabled with xit');
949 | return spec;
950 | };
951 |
952 | this.fit = function(description, fn, timeout){
953 | var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
954 | currentDeclarationSuite.addChild(spec);
955 | focusedRunnables.push(spec.id);
956 | unfocusAncestor();
957 | return spec;
958 | };
959 |
960 | this.expect = function(actual) {
961 | if (!currentRunnable()) {
962 | throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out');
963 | }
964 |
965 | return currentRunnable().expect(actual);
966 | };
967 |
968 | this.beforeEach = function(beforeEachFunction, timeout) {
969 | currentDeclarationSuite.beforeEach({
970 | fn: beforeEachFunction,
971 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
972 | });
973 | };
974 |
975 | this.beforeAll = function(beforeAllFunction, timeout) {
976 | currentDeclarationSuite.beforeAll({
977 | fn: beforeAllFunction,
978 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
979 | });
980 | };
981 |
982 | this.afterEach = function(afterEachFunction, timeout) {
983 | currentDeclarationSuite.afterEach({
984 | fn: afterEachFunction,
985 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
986 | });
987 | };
988 |
989 | this.afterAll = function(afterAllFunction, timeout) {
990 | currentDeclarationSuite.afterAll({
991 | fn: afterAllFunction,
992 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
993 | });
994 | };
995 |
996 | this.pending = function(message) {
997 | var fullMessage = j$.Spec.pendingSpecExceptionMessage;
998 | if(message) {
999 | fullMessage += message;
1000 | }
1001 | throw fullMessage;
1002 | };
1003 |
1004 | this.fail = function(error) {
1005 | var message = 'Failed';
1006 | if (error) {
1007 | message += ': ';
1008 | message += error.message || error;
1009 | }
1010 |
1011 | currentRunnable().addExpectationResult(false, {
1012 | matcherName: '',
1013 | passed: false,
1014 | expected: '',
1015 | actual: '',
1016 | message: message,
1017 | error: error && error.message ? error : null
1018 | });
1019 | };
1020 | }
1021 |
1022 | return Env;
1023 | };
1024 |
1025 | getJasmineRequireObj().JsApiReporter = function() {
1026 |
1027 | var noopTimer = {
1028 | start: function(){},
1029 | elapsed: function(){ return 0; }
1030 | };
1031 |
1032 | function JsApiReporter(options) {
1033 | var timer = options.timer || noopTimer,
1034 | status = 'loaded';
1035 |
1036 | this.started = false;
1037 | this.finished = false;
1038 | this.runDetails = {};
1039 |
1040 | this.jasmineStarted = function() {
1041 | this.started = true;
1042 | status = 'started';
1043 | timer.start();
1044 | };
1045 |
1046 | var executionTime;
1047 |
1048 | this.jasmineDone = function(runDetails) {
1049 | this.finished = true;
1050 | this.runDetails = runDetails;
1051 | executionTime = timer.elapsed();
1052 | status = 'done';
1053 | };
1054 |
1055 | this.status = function() {
1056 | return status;
1057 | };
1058 |
1059 | var suites = [],
1060 | suites_hash = {};
1061 |
1062 | this.suiteStarted = function(result) {
1063 | suites_hash[result.id] = result;
1064 | };
1065 |
1066 | this.suiteDone = function(result) {
1067 | storeSuite(result);
1068 | };
1069 |
1070 | this.suiteResults = function(index, length) {
1071 | return suites.slice(index, index + length);
1072 | };
1073 |
1074 | function storeSuite(result) {
1075 | suites.push(result);
1076 | suites_hash[result.id] = result;
1077 | }
1078 |
1079 | this.suites = function() {
1080 | return suites_hash;
1081 | };
1082 |
1083 | var specs = [];
1084 |
1085 | this.specDone = function(result) {
1086 | specs.push(result);
1087 | };
1088 |
1089 | this.specResults = function(index, length) {
1090 | return specs.slice(index, index + length);
1091 | };
1092 |
1093 | this.specs = function() {
1094 | return specs;
1095 | };
1096 |
1097 | this.executionTime = function() {
1098 | return executionTime;
1099 | };
1100 |
1101 | }
1102 |
1103 | return JsApiReporter;
1104 | };
1105 |
1106 | getJasmineRequireObj().CallTracker = function(j$) {
1107 |
1108 | function CallTracker() {
1109 | var calls = [];
1110 | var opts = {};
1111 |
1112 | function argCloner(context) {
1113 | var clonedArgs = [];
1114 | var argsAsArray = j$.util.argsToArray(context.args);
1115 | for(var i = 0; i < argsAsArray.length; i++) {
1116 | if(Object.prototype.toString.apply(argsAsArray[i]).match(/^\[object/)) {
1117 | clonedArgs.push(j$.util.clone(argsAsArray[i]));
1118 | } else {
1119 | clonedArgs.push(argsAsArray[i]);
1120 | }
1121 | }
1122 | context.args = clonedArgs;
1123 | }
1124 |
1125 | this.track = function(context) {
1126 | if(opts.cloneArgs) {
1127 | argCloner(context);
1128 | }
1129 | calls.push(context);
1130 | };
1131 |
1132 | this.any = function() {
1133 | return !!calls.length;
1134 | };
1135 |
1136 | this.count = function() {
1137 | return calls.length;
1138 | };
1139 |
1140 | this.argsFor = function(index) {
1141 | var call = calls[index];
1142 | return call ? call.args : [];
1143 | };
1144 |
1145 | this.all = function() {
1146 | return calls;
1147 | };
1148 |
1149 | this.allArgs = function() {
1150 | var callArgs = [];
1151 | for(var i = 0; i < calls.length; i++){
1152 | callArgs.push(calls[i].args);
1153 | }
1154 |
1155 | return callArgs;
1156 | };
1157 |
1158 | this.first = function() {
1159 | return calls[0];
1160 | };
1161 |
1162 | this.mostRecent = function() {
1163 | return calls[calls.length - 1];
1164 | };
1165 |
1166 | this.reset = function() {
1167 | calls = [];
1168 | };
1169 |
1170 | this.saveArgumentsByValue = function() {
1171 | opts.cloneArgs = true;
1172 | };
1173 |
1174 | }
1175 |
1176 | return CallTracker;
1177 | };
1178 |
1179 | getJasmineRequireObj().Clock = function() {
1180 | function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
1181 | var self = this,
1182 | realTimingFunctions = {
1183 | setTimeout: global.setTimeout,
1184 | clearTimeout: global.clearTimeout,
1185 | setInterval: global.setInterval,
1186 | clearInterval: global.clearInterval
1187 | },
1188 | fakeTimingFunctions = {
1189 | setTimeout: setTimeout,
1190 | clearTimeout: clearTimeout,
1191 | setInterval: setInterval,
1192 | clearInterval: clearInterval
1193 | },
1194 | installed = false,
1195 | delayedFunctionScheduler,
1196 | timer;
1197 |
1198 |
1199 | self.install = function() {
1200 | if(!originalTimingFunctionsIntact()) {
1201 | throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?');
1202 | }
1203 | replace(global, fakeTimingFunctions);
1204 | timer = fakeTimingFunctions;
1205 | delayedFunctionScheduler = delayedFunctionSchedulerFactory();
1206 | installed = true;
1207 |
1208 | return self;
1209 | };
1210 |
1211 | self.uninstall = function() {
1212 | delayedFunctionScheduler = null;
1213 | mockDate.uninstall();
1214 | replace(global, realTimingFunctions);
1215 |
1216 | timer = realTimingFunctions;
1217 | installed = false;
1218 | };
1219 |
1220 | self.withMock = function(closure) {
1221 | this.install();
1222 | try {
1223 | closure();
1224 | } finally {
1225 | this.uninstall();
1226 | }
1227 | };
1228 |
1229 | self.mockDate = function(initialDate) {
1230 | mockDate.install(initialDate);
1231 | };
1232 |
1233 | self.setTimeout = function(fn, delay, params) {
1234 | if (legacyIE()) {
1235 | if (arguments.length > 2) {
1236 | throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill');
1237 | }
1238 | return timer.setTimeout(fn, delay);
1239 | }
1240 | return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]);
1241 | };
1242 |
1243 | self.setInterval = function(fn, delay, params) {
1244 | if (legacyIE()) {
1245 | if (arguments.length > 2) {
1246 | throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill');
1247 | }
1248 | return timer.setInterval(fn, delay);
1249 | }
1250 | return Function.prototype.apply.apply(timer.setInterval, [global, arguments]);
1251 | };
1252 |
1253 | self.clearTimeout = function(id) {
1254 | return Function.prototype.call.apply(timer.clearTimeout, [global, id]);
1255 | };
1256 |
1257 | self.clearInterval = function(id) {
1258 | return Function.prototype.call.apply(timer.clearInterval, [global, id]);
1259 | };
1260 |
1261 | self.tick = function(millis) {
1262 | if (installed) {
1263 | delayedFunctionScheduler.tick(millis, function(millis) { mockDate.tick(millis); });
1264 | } else {
1265 | throw new Error('Mock clock is not installed, use jasmine.clock().install()');
1266 | }
1267 | };
1268 |
1269 | return self;
1270 |
1271 | function originalTimingFunctionsIntact() {
1272 | return global.setTimeout === realTimingFunctions.setTimeout &&
1273 | global.clearTimeout === realTimingFunctions.clearTimeout &&
1274 | global.setInterval === realTimingFunctions.setInterval &&
1275 | global.clearInterval === realTimingFunctions.clearInterval;
1276 | }
1277 |
1278 | function legacyIE() {
1279 | //if these methods are polyfilled, apply will be present
1280 | return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
1281 | }
1282 |
1283 | function replace(dest, source) {
1284 | for (var prop in source) {
1285 | dest[prop] = source[prop];
1286 | }
1287 | }
1288 |
1289 | function setTimeout(fn, delay) {
1290 | return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
1291 | }
1292 |
1293 | function clearTimeout(id) {
1294 | return delayedFunctionScheduler.removeFunctionWithId(id);
1295 | }
1296 |
1297 | function setInterval(fn, interval) {
1298 | return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
1299 | }
1300 |
1301 | function clearInterval(id) {
1302 | return delayedFunctionScheduler.removeFunctionWithId(id);
1303 | }
1304 |
1305 | function argSlice(argsObj, n) {
1306 | return Array.prototype.slice.call(argsObj, n);
1307 | }
1308 | }
1309 |
1310 | return Clock;
1311 | };
1312 |
1313 | getJasmineRequireObj().DelayedFunctionScheduler = function() {
1314 | function DelayedFunctionScheduler() {
1315 | var self = this;
1316 | var scheduledLookup = [];
1317 | var scheduledFunctions = {};
1318 | var currentTime = 0;
1319 | var delayedFnCount = 0;
1320 |
1321 | self.tick = function(millis, tickDate) {
1322 | millis = millis || 0;
1323 | var endTime = currentTime + millis;
1324 |
1325 | runScheduledFunctions(endTime, tickDate);
1326 | currentTime = endTime;
1327 | };
1328 |
1329 | self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
1330 | var f;
1331 | if (typeof(funcToCall) === 'string') {
1332 | /* jshint evil: true */
1333 | f = function() { return eval(funcToCall); };
1334 | /* jshint evil: false */
1335 | } else {
1336 | f = funcToCall;
1337 | }
1338 |
1339 | millis = millis || 0;
1340 | timeoutKey = timeoutKey || ++delayedFnCount;
1341 | runAtMillis = runAtMillis || (currentTime + millis);
1342 |
1343 | var funcToSchedule = {
1344 | runAtMillis: runAtMillis,
1345 | funcToCall: f,
1346 | recurring: recurring,
1347 | params: params,
1348 | timeoutKey: timeoutKey,
1349 | millis: millis
1350 | };
1351 |
1352 | if (runAtMillis in scheduledFunctions) {
1353 | scheduledFunctions[runAtMillis].push(funcToSchedule);
1354 | } else {
1355 | scheduledFunctions[runAtMillis] = [funcToSchedule];
1356 | scheduledLookup.push(runAtMillis);
1357 | scheduledLookup.sort(function (a, b) {
1358 | return a - b;
1359 | });
1360 | }
1361 |
1362 | return timeoutKey;
1363 | };
1364 |
1365 | self.removeFunctionWithId = function(timeoutKey) {
1366 | for (var runAtMillis in scheduledFunctions) {
1367 | var funcs = scheduledFunctions[runAtMillis];
1368 | var i = indexOfFirstToPass(funcs, function (func) {
1369 | return func.timeoutKey === timeoutKey;
1370 | });
1371 |
1372 | if (i > -1) {
1373 | if (funcs.length === 1) {
1374 | delete scheduledFunctions[runAtMillis];
1375 | deleteFromLookup(runAtMillis);
1376 | } else {
1377 | funcs.splice(i, 1);
1378 | }
1379 |
1380 | // intervals get rescheduled when executed, so there's never more
1381 | // than a single scheduled function with a given timeoutKey
1382 | break;
1383 | }
1384 | }
1385 | };
1386 |
1387 | return self;
1388 |
1389 | function indexOfFirstToPass(array, testFn) {
1390 | var index = -1;
1391 |
1392 | for (var i = 0; i < array.length; ++i) {
1393 | if (testFn(array[i])) {
1394 | index = i;
1395 | break;
1396 | }
1397 | }
1398 |
1399 | return index;
1400 | }
1401 |
1402 | function deleteFromLookup(key) {
1403 | var value = Number(key);
1404 | var i = indexOfFirstToPass(scheduledLookup, function (millis) {
1405 | return millis === value;
1406 | });
1407 |
1408 | if (i > -1) {
1409 | scheduledLookup.splice(i, 1);
1410 | }
1411 | }
1412 |
1413 | function reschedule(scheduledFn) {
1414 | self.scheduleFunction(scheduledFn.funcToCall,
1415 | scheduledFn.millis,
1416 | scheduledFn.params,
1417 | true,
1418 | scheduledFn.timeoutKey,
1419 | scheduledFn.runAtMillis + scheduledFn.millis);
1420 | }
1421 |
1422 | function forEachFunction(funcsToRun, callback) {
1423 | for (var i = 0; i < funcsToRun.length; ++i) {
1424 | callback(funcsToRun[i]);
1425 | }
1426 | }
1427 |
1428 | function runScheduledFunctions(endTime, tickDate) {
1429 | tickDate = tickDate || function() {};
1430 | if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
1431 | tickDate(endTime);
1432 | return;
1433 | }
1434 |
1435 | do {
1436 | var newCurrentTime = scheduledLookup.shift();
1437 | tickDate(newCurrentTime - currentTime);
1438 |
1439 | currentTime = newCurrentTime;
1440 |
1441 | var funcsToRun = scheduledFunctions[currentTime];
1442 | delete scheduledFunctions[currentTime];
1443 |
1444 | forEachFunction(funcsToRun, function(funcToRun) {
1445 | if (funcToRun.recurring) {
1446 | reschedule(funcToRun);
1447 | }
1448 | });
1449 |
1450 | forEachFunction(funcsToRun, function(funcToRun) {
1451 | funcToRun.funcToCall.apply(null, funcToRun.params || []);
1452 | });
1453 | } while (scheduledLookup.length > 0 &&
1454 | // checking first if we're out of time prevents setTimeout(0)
1455 | // scheduled in a funcToRun from forcing an extra iteration
1456 | currentTime !== endTime &&
1457 | scheduledLookup[0] <= endTime);
1458 | }
1459 | }
1460 |
1461 | return DelayedFunctionScheduler;
1462 | };
1463 |
1464 | getJasmineRequireObj().ExceptionFormatter = function() {
1465 | function ExceptionFormatter() {
1466 | this.message = function(error) {
1467 | var message = '';
1468 |
1469 | if (error.name && error.message) {
1470 | message += error.name + ': ' + error.message;
1471 | } else {
1472 | message += error.toString() + ' thrown';
1473 | }
1474 |
1475 | if (error.fileName || error.sourceURL) {
1476 | message += ' in ' + (error.fileName || error.sourceURL);
1477 | }
1478 |
1479 | if (error.line || error.lineNumber) {
1480 | message += ' (line ' + (error.line || error.lineNumber) + ')';
1481 | }
1482 |
1483 | return message;
1484 | };
1485 |
1486 | this.stack = function(error) {
1487 | return error ? error.stack : null;
1488 | };
1489 | }
1490 |
1491 | return ExceptionFormatter;
1492 | };
1493 |
1494 | getJasmineRequireObj().Expectation = function() {
1495 |
1496 | function Expectation(options) {
1497 | this.util = options.util || { buildFailureMessage: function() {} };
1498 | this.customEqualityTesters = options.customEqualityTesters || [];
1499 | this.actual = options.actual;
1500 | this.addExpectationResult = options.addExpectationResult || function(){};
1501 | this.isNot = options.isNot;
1502 |
1503 | var customMatchers = options.customMatchers || {};
1504 | for (var matcherName in customMatchers) {
1505 | this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]);
1506 | }
1507 | }
1508 |
1509 | Expectation.prototype.wrapCompare = function(name, matcherFactory) {
1510 | return function() {
1511 | var args = Array.prototype.slice.call(arguments, 0),
1512 | expected = args.slice(0),
1513 | message = '';
1514 |
1515 | args.unshift(this.actual);
1516 |
1517 | var matcher = matcherFactory(this.util, this.customEqualityTesters),
1518 | matcherCompare = matcher.compare;
1519 |
1520 | function defaultNegativeCompare() {
1521 | var result = matcher.compare.apply(null, args);
1522 | result.pass = !result.pass;
1523 | return result;
1524 | }
1525 |
1526 | if (this.isNot) {
1527 | matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
1528 | }
1529 |
1530 | var result = matcherCompare.apply(null, args);
1531 |
1532 | if (!result.pass) {
1533 | if (!result.message) {
1534 | args.unshift(this.isNot);
1535 | args.unshift(name);
1536 | message = this.util.buildFailureMessage.apply(null, args);
1537 | } else {
1538 | if (Object.prototype.toString.apply(result.message) === '[object Function]') {
1539 | message = result.message();
1540 | } else {
1541 | message = result.message;
1542 | }
1543 | }
1544 | }
1545 |
1546 | if (expected.length == 1) {
1547 | expected = expected[0];
1548 | }
1549 |
1550 | // TODO: how many of these params are needed?
1551 | this.addExpectationResult(
1552 | result.pass,
1553 | {
1554 | matcherName: name,
1555 | passed: result.pass,
1556 | message: message,
1557 | actual: this.actual,
1558 | expected: expected // TODO: this may need to be arrayified/sliced
1559 | }
1560 | );
1561 | };
1562 | };
1563 |
1564 | Expectation.addCoreMatchers = function(matchers) {
1565 | var prototype = Expectation.prototype;
1566 | for (var matcherName in matchers) {
1567 | var matcher = matchers[matcherName];
1568 | prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
1569 | }
1570 | };
1571 |
1572 | Expectation.Factory = function(options) {
1573 | options = options || {};
1574 |
1575 | var expect = new Expectation(options);
1576 |
1577 | // TODO: this would be nice as its own Object - NegativeExpectation
1578 | // TODO: copy instead of mutate options
1579 | options.isNot = true;
1580 | expect.not = new Expectation(options);
1581 |
1582 | return expect;
1583 | };
1584 |
1585 | return Expectation;
1586 | };
1587 |
1588 | //TODO: expectation result may make more sense as a presentation of an expectation.
1589 | getJasmineRequireObj().buildExpectationResult = function() {
1590 | function buildExpectationResult(options) {
1591 | var messageFormatter = options.messageFormatter || function() {},
1592 | stackFormatter = options.stackFormatter || function() {};
1593 |
1594 | var result = {
1595 | matcherName: options.matcherName,
1596 | message: message(),
1597 | stack: stack(),
1598 | passed: options.passed
1599 | };
1600 |
1601 | if(!result.passed) {
1602 | result.expected = options.expected;
1603 | result.actual = options.actual;
1604 | }
1605 |
1606 | return result;
1607 |
1608 | function message() {
1609 | if (options.passed) {
1610 | return 'Passed.';
1611 | } else if (options.message) {
1612 | return options.message;
1613 | } else if (options.error) {
1614 | return messageFormatter(options.error);
1615 | }
1616 | return '';
1617 | }
1618 |
1619 | function stack() {
1620 | if (options.passed) {
1621 | return '';
1622 | }
1623 |
1624 | var error = options.error;
1625 | if (!error) {
1626 | try {
1627 | throw new Error(message());
1628 | } catch (e) {
1629 | error = e;
1630 | }
1631 | }
1632 | return stackFormatter(error);
1633 | }
1634 | }
1635 |
1636 | return buildExpectationResult;
1637 | };
1638 |
1639 | getJasmineRequireObj().MockDate = function() {
1640 | function MockDate(global) {
1641 | var self = this;
1642 | var currentTime = 0;
1643 |
1644 | if (!global || !global.Date) {
1645 | self.install = function() {};
1646 | self.tick = function() {};
1647 | self.uninstall = function() {};
1648 | return self;
1649 | }
1650 |
1651 | var GlobalDate = global.Date;
1652 |
1653 | self.install = function(mockDate) {
1654 | if (mockDate instanceof GlobalDate) {
1655 | currentTime = mockDate.getTime();
1656 | } else {
1657 | currentTime = new GlobalDate().getTime();
1658 | }
1659 |
1660 | global.Date = FakeDate;
1661 | };
1662 |
1663 | self.tick = function(millis) {
1664 | millis = millis || 0;
1665 | currentTime = currentTime + millis;
1666 | };
1667 |
1668 | self.uninstall = function() {
1669 | currentTime = 0;
1670 | global.Date = GlobalDate;
1671 | };
1672 |
1673 | createDateProperties();
1674 |
1675 | return self;
1676 |
1677 | function FakeDate() {
1678 | switch(arguments.length) {
1679 | case 0:
1680 | return new GlobalDate(currentTime);
1681 | case 1:
1682 | return new GlobalDate(arguments[0]);
1683 | case 2:
1684 | return new GlobalDate(arguments[0], arguments[1]);
1685 | case 3:
1686 | return new GlobalDate(arguments[0], arguments[1], arguments[2]);
1687 | case 4:
1688 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]);
1689 | case 5:
1690 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1691 | arguments[4]);
1692 | case 6:
1693 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1694 | arguments[4], arguments[5]);
1695 | default:
1696 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1697 | arguments[4], arguments[5], arguments[6]);
1698 | }
1699 | }
1700 |
1701 | function createDateProperties() {
1702 | FakeDate.prototype = GlobalDate.prototype;
1703 |
1704 | FakeDate.now = function() {
1705 | if (GlobalDate.now) {
1706 | return currentTime;
1707 | } else {
1708 | throw new Error('Browser does not support Date.now()');
1709 | }
1710 | };
1711 |
1712 | FakeDate.toSource = GlobalDate.toSource;
1713 | FakeDate.toString = GlobalDate.toString;
1714 | FakeDate.parse = GlobalDate.parse;
1715 | FakeDate.UTC = GlobalDate.UTC;
1716 | }
1717 | }
1718 |
1719 | return MockDate;
1720 | };
1721 |
1722 | getJasmineRequireObj().pp = function(j$) {
1723 |
1724 | function PrettyPrinter() {
1725 | this.ppNestLevel_ = 0;
1726 | this.seen = [];
1727 | }
1728 |
1729 | PrettyPrinter.prototype.format = function(value) {
1730 | this.ppNestLevel_++;
1731 | try {
1732 | if (j$.util.isUndefined(value)) {
1733 | this.emitScalar('undefined');
1734 | } else if (value === null) {
1735 | this.emitScalar('null');
1736 | } else if (value === 0 && 1/value === -Infinity) {
1737 | this.emitScalar('-0');
1738 | } else if (value === j$.getGlobal()) {
1739 | this.emitScalar('');
1740 | } else if (value.jasmineToString) {
1741 | this.emitScalar(value.jasmineToString());
1742 | } else if (typeof value === 'string') {
1743 | this.emitString(value);
1744 | } else if (j$.isSpy(value)) {
1745 | this.emitScalar('spy on ' + value.and.identity());
1746 | } else if (value instanceof RegExp) {
1747 | this.emitScalar(value.toString());
1748 | } else if (typeof value === 'function') {
1749 | this.emitScalar('Function');
1750 | } else if (typeof value.nodeType === 'number') {
1751 | this.emitScalar('HTMLNode');
1752 | } else if (value instanceof Date) {
1753 | this.emitScalar('Date(' + value + ')');
1754 | } else if (value.toString && typeof value === 'object' && !(value instanceof Array) && value.toString !== Object.prototype.toString) {
1755 | this.emitScalar(value.toString());
1756 | } else if (j$.util.arrayContains(this.seen, value)) {
1757 | this.emitScalar('');
1758 | } else if (j$.isArray_(value) || j$.isA_('Object', value)) {
1759 | this.seen.push(value);
1760 | if (j$.isArray_(value)) {
1761 | this.emitArray(value);
1762 | } else {
1763 | this.emitObject(value);
1764 | }
1765 | this.seen.pop();
1766 | } else {
1767 | this.emitScalar(value.toString());
1768 | }
1769 | } finally {
1770 | this.ppNestLevel_--;
1771 | }
1772 | };
1773 |
1774 | PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1775 | for (var property in obj) {
1776 | if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
1777 | fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1778 | obj.__lookupGetter__(property) !== null) : false);
1779 | }
1780 | };
1781 |
1782 | PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
1783 | PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
1784 | PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
1785 | PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
1786 |
1787 | function StringPrettyPrinter() {
1788 | PrettyPrinter.call(this);
1789 |
1790 | this.string = '';
1791 | }
1792 |
1793 | j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
1794 |
1795 | StringPrettyPrinter.prototype.emitScalar = function(value) {
1796 | this.append(value);
1797 | };
1798 |
1799 | StringPrettyPrinter.prototype.emitString = function(value) {
1800 | this.append('\'' + value + '\'');
1801 | };
1802 |
1803 | StringPrettyPrinter.prototype.emitArray = function(array) {
1804 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1805 | this.append('Array');
1806 | return;
1807 | }
1808 | var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
1809 | this.append('[ ');
1810 | for (var i = 0; i < length; i++) {
1811 | if (i > 0) {
1812 | this.append(', ');
1813 | }
1814 | this.format(array[i]);
1815 | }
1816 | if(array.length > length){
1817 | this.append(', ...');
1818 | }
1819 |
1820 | var self = this;
1821 | var first = array.length === 0;
1822 | this.iterateObject(array, function(property, isGetter) {
1823 | if (property.match(/^\d+$/)) {
1824 | return;
1825 | }
1826 |
1827 | if (first) {
1828 | first = false;
1829 | } else {
1830 | self.append(', ');
1831 | }
1832 |
1833 | self.formatProperty(array, property, isGetter);
1834 | });
1835 |
1836 | this.append(' ]');
1837 | };
1838 |
1839 | StringPrettyPrinter.prototype.emitObject = function(obj) {
1840 | var constructorName = obj.constructor ? j$.fnNameFor(obj.constructor) : 'null';
1841 | this.append(constructorName);
1842 |
1843 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1844 | return;
1845 | }
1846 |
1847 | var self = this;
1848 | this.append('({ ');
1849 | var first = true;
1850 |
1851 | this.iterateObject(obj, function(property, isGetter) {
1852 | if (first) {
1853 | first = false;
1854 | } else {
1855 | self.append(', ');
1856 | }
1857 |
1858 | self.formatProperty(obj, property, isGetter);
1859 | });
1860 |
1861 | this.append(' })');
1862 | };
1863 |
1864 | StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
1865 | this.append(property);
1866 | this.append(': ');
1867 | if (isGetter) {
1868 | this.append('');
1869 | } else {
1870 | this.format(obj[property]);
1871 | }
1872 | };
1873 |
1874 | StringPrettyPrinter.prototype.append = function(value) {
1875 | this.string += value;
1876 | };
1877 |
1878 | return function(value) {
1879 | var stringPrettyPrinter = new StringPrettyPrinter();
1880 | stringPrettyPrinter.format(value);
1881 | return stringPrettyPrinter.string;
1882 | };
1883 | };
1884 |
1885 | getJasmineRequireObj().QueueRunner = function(j$) {
1886 |
1887 | function once(fn) {
1888 | var called = false;
1889 | return function() {
1890 | if (!called) {
1891 | called = true;
1892 | fn();
1893 | }
1894 | return null;
1895 | };
1896 | }
1897 |
1898 | function QueueRunner(attrs) {
1899 | this.queueableFns = attrs.queueableFns || [];
1900 | this.onComplete = attrs.onComplete || function() {};
1901 | this.clearStack = attrs.clearStack || function(fn) {fn();};
1902 | this.onException = attrs.onException || function() {};
1903 | this.catchException = attrs.catchException || function() { return true; };
1904 | this.userContext = attrs.userContext || {};
1905 | this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
1906 | this.fail = attrs.fail || function() {};
1907 | }
1908 |
1909 | QueueRunner.prototype.execute = function() {
1910 | this.run(this.queueableFns, 0);
1911 | };
1912 |
1913 | QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
1914 | var length = queueableFns.length,
1915 | self = this,
1916 | iterativeIndex;
1917 |
1918 |
1919 | for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
1920 | var queueableFn = queueableFns[iterativeIndex];
1921 | if (queueableFn.fn.length > 0) {
1922 | attemptAsync(queueableFn);
1923 | return;
1924 | } else {
1925 | attemptSync(queueableFn);
1926 | }
1927 | }
1928 |
1929 | var runnerDone = iterativeIndex >= length;
1930 |
1931 | if (runnerDone) {
1932 | this.clearStack(this.onComplete);
1933 | }
1934 |
1935 | function attemptSync(queueableFn) {
1936 | try {
1937 | queueableFn.fn.call(self.userContext);
1938 | } catch (e) {
1939 | handleException(e, queueableFn);
1940 | }
1941 | }
1942 |
1943 | function attemptAsync(queueableFn) {
1944 | var clearTimeout = function () {
1945 | Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
1946 | },
1947 | next = once(function () {
1948 | clearTimeout(timeoutId);
1949 | self.run(queueableFns, iterativeIndex + 1);
1950 | }),
1951 | timeoutId;
1952 |
1953 | next.fail = function() {
1954 | self.fail.apply(null, arguments);
1955 | next();
1956 | };
1957 |
1958 | if (queueableFn.timeout) {
1959 | timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() {
1960 | var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
1961 | onException(error);
1962 | next();
1963 | }, queueableFn.timeout()]]);
1964 | }
1965 |
1966 | try {
1967 | queueableFn.fn.call(self.userContext, next);
1968 | } catch (e) {
1969 | handleException(e, queueableFn);
1970 | next();
1971 | }
1972 | }
1973 |
1974 | function onException(e) {
1975 | self.onException(e);
1976 | }
1977 |
1978 | function handleException(e, queueableFn) {
1979 | onException(e);
1980 | if (!self.catchException(e)) {
1981 | //TODO: set a var when we catch an exception and
1982 | //use a finally block to close the loop in a nice way..
1983 | throw e;
1984 | }
1985 | }
1986 | };
1987 |
1988 | return QueueRunner;
1989 | };
1990 |
1991 | getJasmineRequireObj().ReportDispatcher = function() {
1992 | function ReportDispatcher(methods) {
1993 |
1994 | var dispatchedMethods = methods || [];
1995 |
1996 | for (var i = 0; i < dispatchedMethods.length; i++) {
1997 | var method = dispatchedMethods[i];
1998 | this[method] = (function(m) {
1999 | return function() {
2000 | dispatch(m, arguments);
2001 | };
2002 | }(method));
2003 | }
2004 |
2005 | var reporters = [];
2006 | var fallbackReporter = null;
2007 |
2008 | this.addReporter = function(reporter) {
2009 | reporters.push(reporter);
2010 | };
2011 |
2012 | this.provideFallbackReporter = function(reporter) {
2013 | fallbackReporter = reporter;
2014 | };
2015 |
2016 |
2017 | return this;
2018 |
2019 | function dispatch(method, args) {
2020 | if (reporters.length === 0 && fallbackReporter !== null) {
2021 | reporters.push(fallbackReporter);
2022 | }
2023 | for (var i = 0; i < reporters.length; i++) {
2024 | var reporter = reporters[i];
2025 | if (reporter[method]) {
2026 | reporter[method].apply(reporter, args);
2027 | }
2028 | }
2029 | }
2030 | }
2031 |
2032 | return ReportDispatcher;
2033 | };
2034 |
2035 |
2036 | getJasmineRequireObj().SpyRegistry = function(j$) {
2037 |
2038 | var getErrorMsg = j$.formatErrorMsg('', 'spyOn(