├── README.md
├── classes.html
├── classes.js
├── destructuring.html
├── destructuring.js
├── for-in-delete.html
├── for-in-delete.js
├── higher-order.html
├── higher-order.js
├── index.html
├── nesting.html
├── nesting.js
└── test
├── MIT.LICENSE
├── lib
└── jasmine-2.3.4
│ ├── boot.js
│ ├── console.js
│ ├── jasmine-html.js
│ ├── jasmine.css
│ ├── jasmine.js
│ └── jasmine_favicon.png
└── spec
├── classesSpec.js
├── destructuringSpec.js
├── for-in-delete-spec.js
├── higher-order-spec.js
└── nestingSpec.js
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Project Summary
4 |
5 | In this project, we'll provide a variety of JavaScript problems to help improve your skills. We would like you to push yourselves as much as possible. We expect you to at least finish two problems in each section.
6 |
7 | If you would like to push yourself further, try to complete every problem. Otherwise, feel free to move on to other content.
8 |
9 | ## Setup
10 |
11 | * `Fork` this repository.
12 | * `Clone` your fork.
13 | * Open `./index.html` with your browser.
14 |
15 | `./index.html` will provide links to all the spec runners for your convenience. It also has all the JavaSript files you will be working in imported into it. This will allow you to use the browser debugger for all your code in one spot.
16 |
17 | ## Tips and Tricks
18 |
19 | One of the biggest tools at the developer's disposal is the browser's built-in debugger. To use it, open `./index.html` with your browser. Another great tool for small and isolated pieces of code is Pyton Tutor . Just make sure to change the code to `JavaScript ES6`.
20 |
21 | ## Contributions
22 |
23 | If you see a problem or a typo, please fork, make the necessary changes, and create a pull request so we can review your changes and merge them into the master repo and branch.
24 |
25 | ## Copyright
26 |
27 | © DevMountain LLC, 2017. Unauthorized use and/or duplication of this material without express and written permission from DevMountain, LLC is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to DevMountain with appropriate and specific direction to the original content.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/classes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.3.4
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/classes.js:
--------------------------------------------------------------------------------
1 | /*
2 | Once you complete a problem, refresh ./classes.html in your browser and check to see if the problem's test(s) are passing.
3 | Passed tests will be indicated by a green circle.
4 | Failed tests will be indicated by a red X.
5 |
6 | You can refresh the page at any time to re-run all the tests.
7 |
8 | Classes are a tool for building similar objects over and over again.
9 | They are a construct that helps your organize your code.
10 |
11 | Let's work with some employees at a company.
12 | You work for Widget Co. They have hundreds of employees.
13 | */
14 |
15 | ////////// PROBLEM 1 //////////
16 |
17 | /*
18 | Make a class to help us build all of the employees.
19 | Each employee has the following properties:
20 | - first_name
21 | - last_name
22 | - email
23 | - age
24 | Each employee has the following methods:
25 | - makeWidget
26 | - This returns a string equal to the employees first name + last name + the word widget
27 | - Example: "Dave Smith Widget"
28 |
29 | Call your class Employee and receive all the data in the constructor in the order listed above.
30 | */
31 |
32 | //Code Here
33 |
34 |
35 |
36 | ////////// PROBLEM 2 //////////
37 |
38 | /*
39 | Next, make a manager for Widget Co.
40 | The manager has all the same properties as an Employee. Copy the Employee class and rename it Manager.
41 | Each manager has the following additional properties:
42 | - reports (other employees) that defaults to an empty array
43 | Each manager has the following additional methods:
44 | - hire (employee)
45 | - Accepts a new employee as a parameter and pushes it to their list of reports.
46 | - fire (index)
47 | - Fire removes employees from their list of reports at the given index
48 |
49 | Call your new class Manager
50 | */
51 |
52 | //Code Here
53 |
54 |
55 |
56 | ////////// PROBLEM 3 //////////
57 |
58 | /*
59 | Managers for Widget Co. get promoted when they get more employees, and get a bonus when they fire employees.
60 | Progressive managers have all the same properties as managers. Copy the Manager class and rename
61 | it to ProgressiveManager. Add the following additional properties:
62 | - title - default 'Not a manager'
63 | - bonus - default 0
64 |
65 | When employees are hired or fired, the manager's title should be updated based on the number of reports.
66 | 0 reports : Not a manager
67 | 1-3 reports : Barely Manager
68 | 4-10 reports : Mostly Manager
69 | 11-50 reports : Manager
70 | 51-100 reports : Manager Plus
71 | 101+ reports : Bestest Manager
72 |
73 | Everytime they fire an employee they get $100 added to their bonus.
74 |
75 | Call your new class ProgressiveManager
76 | */
77 |
78 | //Code Here
79 |
80 |
81 |
82 | ////////// PROBLEM 4 - Black Diamond //////////
83 |
84 | /*
85 | Widget Co has a factory that makes widgets.
86 | Factories have Machines.
87 |
88 | Make a Machine class that takes in no parameters
89 | A Machine has the following properties:
90 | - widgets_made_count - default 0
91 | - wear_and_tear_count - default 0
92 | - needs_reboot - default false
93 |
94 | A Machine has the following methods:
95 | - makeWidgets
96 | - This function takes in a number and increases widgets_made_count by that amount
97 | - It also increases wear_and_tear_count by 1 for every 50
98 | - fixMachine
99 | - This function sets needs_reboot to true
100 | - reboot
101 | - This function returns an anonymous function that is called when the machine is done rebooting
102 | - The anonymous function should decrease wear_and_tear_count by 10, and set needs_reboot to false
103 | */
104 |
105 | //Code Here
106 |
107 |
108 |
--------------------------------------------------------------------------------
/destructuring.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.3.4
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/destructuring.js:
--------------------------------------------------------------------------------
1 | /*
2 | Once you complete a problem, refresh ./destructuring.html in your browser and check to see if the problem's test(s) are passing.
3 | Passed tests will be indicated by a green circle.
4 | Failed tests will be indicated by a red X.
5 |
6 | You can refresh the page at any time to re-run all the tests.
7 | */
8 |
9 | ////////// PROBLEM 1 //////////
10 |
11 | // Do not edit the code below.
12 | var carDetails = {
13 | color: 'red',
14 | make: 'toyota',
15 | model: 'tacoma',
16 | year: 1994
17 | }
18 | // Do not edit the code above.
19 |
20 | /*
21 | Use object destructuring to save the property values from the object carDetails into new variables.
22 | */
23 |
24 | //Code Here
25 |
26 |
27 |
28 | ////////// PROBLEM 2 //////////
29 |
30 | /*
31 | In the function below named greeting, it is receiving an object as a parameter.
32 | Use object destructuring to save the object properties to new variables.
33 | The property names are firstName, lastName, and title.
34 | */
35 |
36 | function greeting( obj ) {
37 | //Code Here
38 |
39 | // Do not edit the code below.
40 | return 'Hello, ' + title + ' ' + firstName + ' ' + lastName + '!';
41 | // Do not edit the code above.
42 | }
43 |
44 |
45 |
46 | ////////// PROBLEM 3 //////////
47 |
48 | /*
49 | Write a function called totalPopulation that will take in an object.
50 | That object will have 4 properties named utah, california, texas and arizona.
51 | The property values will be numbers.
52 | Use object destructuring to save the property values to new variables.
53 | Sum up the values and return the total number.
54 | */
55 |
56 | //Code Here
57 |
58 |
59 |
60 | ////////// PROBLEM 4 //////////
61 |
62 | /*
63 | Write a function called ingredients that will take in an object.
64 | This object will have 3 properties named carb, fat, and protein.
65 | The property values will be strings.
66 | Use object destructuring to save the property values to new variables.
67 | Push these new variables to an array and return the array.
68 | */
69 |
70 | //Code Here
71 |
72 |
73 |
74 | ////////// PROBLEM 5 //////////
75 |
76 | /*
77 | Now we will use object destructuring as the function's parameter instead of destructuring the object inside of the function declaration.
78 | Example:
79 | function example( {one, two, three} ) {
80 | return one + two + three
81 | }
82 |
83 | Write a function called largeNumbers that will take a destructured object as it's parameter.
84 | The object properties will be named first, second, and third and their values will be numbers.
85 | Find the smallest number of the three and return that number.
86 | */
87 |
88 | //Code Here
89 |
90 |
91 |
92 | ////////// PROBLEM 6 //////////
93 |
94 | /*
95 | Write a function called numberGroups that will take a destructured object as it's parameter.
96 | The object properties will be named a, b, and c and their values will be arrays of numbers.
97 | Find the longest array and return that array.
98 | */
99 |
100 | //Code Here
101 |
102 |
103 |
--------------------------------------------------------------------------------
/for-in-delete.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.3.4
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/for-in-delete.js:
--------------------------------------------------------------------------------
1 | /*
2 | Once you complete a problem, refresh ./for-in-delete.html in your browser and check to see if the problem's test(s) are passing.
3 | Passed tests will be indicated by a green circle.
4 | Failed tests will be indicated by a red X.
5 |
6 | You can refresh the page at any time to re-run all the tests.
7 | */
8 |
9 | /*
10 | First we'll look at the difference between accessing property values in a for in loop and accessing the property name in a for in loop.
11 | In the example below, we are accessing the property values. Uncomment the code below, run it and look at what prints in the console.
12 | */
13 |
14 | // var values = {
15 | // one: 'These',
16 | // two: ' are',
17 | // three: ' the',
18 | // four: ' property',
19 | // five: ' values.'
20 | // }
21 |
22 | // for(var key in values) {
23 | // console.log(values[key])
24 | // }
25 |
26 | /*
27 | In this next example, we are accessing the property names themselves. Uncomment the code below, run it and look at what prints in the console.
28 | */
29 |
30 | // for(var key in values) {
31 | // console.log(key)
32 | // }
33 |
34 |
35 |
36 | ////////// PROBLEM 1 //////////
37 |
38 | /*
39 | Inside the function showValues, write a for in loop that concatenates each of the property values and returns the concatenated string.
40 | */
41 |
42 | function showValues( obj ) {
43 | //Code Here
44 | }
45 |
46 |
47 |
48 | ////////// PROBLEM 2 //////////
49 |
50 | /*
51 | Write a function called greaterThan10 that takes in an object.
52 | Write a for in loop that loops over the object and changes any value that is greater than 10 to 0.
53 | Return the updated object.
54 | */
55 |
56 | //Code Here
57 |
58 |
59 |
60 | ////////// PROBLEM 3 //////////
61 |
62 | /*
63 | Write a function called double that takes in an object.
64 | Write a for in loop that loops over the object and changes every value to be itself multipled by 2.
65 | Return the updated object.
66 | */
67 |
68 | //Code Here
69 |
70 |
71 |
72 | ////////// PROBLEM 4 //////////
73 |
74 | /*
75 | Write a function called secrets that will take in an object.
76 | Create an empty string variable.
77 | Write a for in loop that loops over the object.
78 | If the property name starts with an 'sh', concatenate the value to the string variable.
79 | By the end of the for in loop, you should have a sentence, return that sentence.
80 | */
81 |
82 | //Code Here
83 |
84 |
85 |
86 | /*
87 | Sometimes it's needed to delete object properties.
88 | All you need is the word delete before a reference to the object property value.
89 | Uncomment the example below to see a for in loop deleting all the properties inside an object.
90 | */
91 |
92 | // var deleteAllThethings = {
93 | // one: 1,
94 | // two: 2,
95 | // three: 3
96 | // }
97 |
98 | // for(var key in deleteAllThethings) {
99 | // delete deleteAllThethings[key]
100 | // }
101 |
102 | // console.log(deleteAllThethings)
103 |
104 |
105 |
106 | ////////// PROBLEM 5 //////////
107 |
108 | /*
109 | Write a function called removePassword that takes in an object.
110 | Delete the property password and return the object.
111 | */
112 |
113 | //Code Here
114 |
115 |
116 |
117 | ////////// PROBLEM 6 //////////
118 |
119 | // Do not edit the code below.
120 | var deleteTheBigNumbers = {
121 | first: 10,
122 | second: 20,
123 | third: 110,
124 | fourth: 200
125 | }
126 | // Do not edit the code above.
127 |
128 | /*
129 | Write a for in loop that deletes every property from the object deleteTheBigNumbers whose value is greater than 100.
130 | */
131 |
132 | //Code Here
133 |
134 |
135 |
136 | ////////// PROBLEM 7 //////////
137 |
138 | /*
139 | Write a function called startsWithK that takes an object as a parameter.
140 | Write a for in loop to loop over the object.
141 | If any property name starts with k, delete that property.
142 | Return the updated object.
143 | */
144 |
145 | //Code Here
146 |
147 |
148 |
149 | ////////// PROBLEM 8 //////////
150 |
151 | /*
152 | Write a function called hiddenTreasure that takes in an object.
153 | Write a for in loop that loops over this object. Each property will have a sentence as it's value.
154 | If the property value does not contain the word 'treasure', delete the property.
155 | Return the updated object.
156 |
157 | (hint: the method includes() may be of use...)
158 | */
159 |
160 | //Code Here
161 |
162 |
163 |
--------------------------------------------------------------------------------
/higher-order.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.3.4
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/higher-order.js:
--------------------------------------------------------------------------------
1 | /*
2 | Once you complete a problem, refresh ./higher-order.html in your browser and check to see if the problem's test(s) are passing.
3 | Passed tests will be indicated by a green circle.
4 | Failed tests will be indicated by a red X.
5 |
6 | You can refresh the page at any time to re-run all the tests.
7 | */
8 |
9 | ////////// PROBLEM 1 //////////
10 |
11 | // Do not edit the code below.
12 | const mixedNumbers = [6,3,1,7,5,2,6,8,9,4,2,7,9,3,1,8,4,3];
13 | // Do not edit the code above.
14 |
15 | /*
16 | Use the filter method on mixedNumbers to make a new array of just the even numbers.
17 |
18 | The filter function takes a callback with the parameters
19 | function(element, index, wholeArray){} Function Form
20 | (element, index, wholeArray)=>{} Arrow Form
21 | */
22 |
23 | //Code Here
24 | let evenNumbers // = mixedNumbers.filter(/* Provide Your Callback Here */)
25 |
26 |
27 |
28 | ////////// PROBLEM 2 //////////
29 |
30 | // Do not edit the code below.
31 | const prices = [15.00, 23.00, 78.00, 34.00, 12.00, 86.00, 12.00, 79.00, 32.00];
32 | // Do not edit the code above.
33 |
34 | /*
35 | Use the map method on the prices array to calculate a new array of post-tax prices.
36 | Use a 7% tax rate.
37 |
38 | Math reminder! To calculate the price after tax, multiply the price by 1 plus the taxRate as a decimal.
39 | Example: if tax is 7%, the price afterTax could be calculated like this: afterTax = price * 1.07)
40 |
41 | The map function also takes a callback with the parameters
42 | function(element, index, wholeArray){} Function Form
43 | (element, index, wholeArray)=>{} Arrow Form
44 | */
45 |
46 | //Code Here
47 | let postTaxPrices // = prices.map(/* Provide Your Callback Here );
48 |
49 |
50 |
51 | ////////// PROBLEM 3 //////////
52 |
53 | // Do not edit the code below.
54 | const populations = [8175133, 3792621, 2695598, 2100263];
55 | // Do not edit the code above.
56 |
57 | /*
58 | Use the reduce method to calculate the sum of all the populations in the array.
59 |
60 | The reduce function has a slightly different setup for it's callback.
61 | function(runningTotal, curElement, curIndex, wholeArray){} Function Form
62 | (runningTotal, curElement, curIndex, wholeArray)=>{} Arrow Form
63 | */
64 |
65 | //Code Here
66 | let totalPopulation // = populations.reduce(/* Provide Your Callback Here */)
67 |
68 |
69 |
70 | ////////// PROBLEM 4 //////////
71 |
72 | // Do not edit the code below.
73 | const monstersInYourPocket = [{"monster":"Bulbabunny","CP":156},{"monster":"Bulbabunny","CP":135},
74 | {"monster":"Bulbabunny","CP":250},{"monster":"Ponylopse","CP":277},{"monster":"Ponylopse","CP":184},
75 | {"monster":"Pikadoughnet","CP":207},{"monster":"Bulbabunny","CP":139},{"monster":"Pikadoughnet","CP":47},
76 | {"monster":"Pikadoughnet","CP":175},{"monster":"WaterHorsia","CP":26},{"monster":"Ponylopse","CP":19},
77 | {"monster":"Pikadoughnet","CP":218},{"monster":"Charaflier","CP":101},{"monster":"WaterHorsia","CP":96},
78 | {"monster":"Pikadoughnet","CP":253},{"monster":"Sandmush","CP":146},{"monster":"Bulbabunny","CP":247},
79 | {"monster":"Charaflier","CP":55},{"monster":"Bulbabunny","CP":72},{"monster":"Pikadoughnet","CP":300},
80 | {"monster":"Sandmush","CP":262},{"monster":"Sandmush","CP":25},{"monster":"Charaflier","CP":215},
81 | {"monster":"Ponylopse","CP":125},{"monster":"Bulbabunny","CP":178}];
82 | // Do not edit the code above.
83 |
84 | /*
85 | Now we're going to ramp these up a little bit.
86 | Instead of just arrays of numbers, we are going to have array of objects that we want to use map, filter, and reduce with.
87 |
88 | Use the filter method to return only the monsters that have a CP of over 200.
89 | */
90 |
91 | //Code Here
92 | let myStrongest // = monstersInYourPocket.filter(/* Provide Your Callback Here */)
93 |
94 |
95 |
96 | ////////// PROBLEM 5 //////////
97 |
98 | // Do not edit code below.
99 | const orders = [{"price":15,"tax":0.09},{"price":42,"tax":0.07},{"price":56,"tax":0.11},
100 | {"price":80,"tax":0.11},{"price":69,"tax":0.06},{"price":68,"tax":0.14},
101 | {"price":72,"tax":0.14},{"price":51,"tax":0.09},{"price":89,"tax":0.15},
102 | {"price":48,"tax":0.13}];
103 | // Do not edit code above.
104 |
105 | /*
106 | Use a higher order method to get all the order totals after adding in the sales tax. Your answer should be an array of numbers, one total for each order.
107 | */
108 |
109 | let orderTotals // Code here
110 |
111 |
112 |
113 | ////////// PROBLEM 6 //////////
114 |
115 | // Do not edit the code below.
116 | const purchases = [{"owner":"Barry","price":103},{"owner":"Bob","price":75},
117 | {"owner":"Bob","price":73},{"owner":"Barry","price":57},{"owner":"Barry","price":128},
118 | {"owner":"Bob","price":119},{"owner":"Barry","price":133},{"owner":"Barry","price":27},
119 | {"owner":"Barry","price":138},{"owner":"Bob","price":68},{"owner":"Bob","price":50},
120 | {"owner":"Barry","price":9},{"owner":"Bob","price":123},{"owner":"Bob","price":135},
121 | {"owner":"Barry","price":30},{"owner":"Barry","price":129},{"owner":"Barry","price":38},
122 | {"owner":"Bob","price":133},{"owner":"Barry","price":109},{"owner":"Bob","price":115}];
123 | // Do not edit the code above.
124 |
125 | /*
126 | Use a high order method to create to get the sum of bobsTotal.
127 | */
128 |
129 | let bobsTotal //Code Here
130 |
131 |
132 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Javascript and Debugging
6 |
7 |
8 |
9 | Spec Runners:
10 |
17 |
18 | To use the debugger, right click this page and press Inspect. You can also use the hotkey combination of L-CTRL ( Mac: L-Command ) + L-SHIFT + C
19 |
20 | Now that the debugger is visible on your screen, look for the Sources tab and open it.
21 |
22 | Refresh the page while you have the debugger open and the Sources tab active.
23 |
24 | Select the JavaScript file you would like to debug.
25 |
26 | For more information, checkout: Chrome DevTools
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/nesting.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jasmine Spec Runner v2.3.4
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/nesting.js:
--------------------------------------------------------------------------------
1 | /*
2 | Once you complete a problem, refresh ./nesting.html in your browser and check to see if the problem's test(s) are passing.
3 | Passed tests will be indicated by a green circle.
4 | Failed tests will be indicated by a red X.
5 |
6 | You can refresh the page at any time to re-run all the tests.
7 | */
8 |
9 | ////////// PROBLEM 1 //////////
10 |
11 | // Do not edit the code below.
12 | var employees = [
13 | {
14 | "firstName": "Von",
15 | "lastName": "Budibent",
16 | "email": "vbudibent0@163.com",
17 | "department": "Sales"
18 | },
19 | {
20 | "firstName": "Catherina",
21 | "lastName": "Swalowe",
22 | "email": "cswalowe1@example.com",
23 | "department": "Engineering"
24 | },
25 | {
26 | "firstName": "Theo",
27 | "lastName": "Trill",
28 | "email": "ttrill2@sina.com.cn",
29 | "department": "Services"
30 | },
31 | {
32 | "firstName": "Elsy",
33 | "lastName": "McCrorie",
34 | "email": "emccrorie3@netscape.com",
35 | "department": "Legal"
36 | },
37 | {
38 | "firstName": "Lorie",
39 | "lastName": "Handsheart",
40 | "email": "lhandsheart4@fotki.com",
41 | "department": "Research and Development"
42 | }
43 | ];
44 | // Do not edit the code above.
45 |
46 | /*
47 | Create a function called 'employeeUpdater' that takes no parameters. employeeUpdater will loop over the array above and perform the following:
48 | 1. If employee's first name is Theo, remove that employee because he just got fired.
49 | 2. If the employee's first name is Lorie, change her department to 'HR'.
50 | 3. Return the updated employee array.
51 | */
52 |
53 | //Code Here
54 |
55 |
56 |
57 | ////////// PROBLEM 2 //////////
58 |
59 | // Do not edit the code below.
60 | var workplaceAccidents = [12, 56, 44, 3, 29, 56, 56, 3, 7, 12];
61 | // Do not edit the code above.
62 |
63 | /*
64 | The array above represents IDs tied to reported workplace accidents.
65 | An employee accidentally entered in duplicates to array, making it look as though there are more accidents this year than there actually are.
66 | 1. Write a function called 'removeDuplicates' that will remove all duplicate entries in the workplaceAccidents array.
67 | 2. Use nested for loops to check for duplicate numbers, and then remove the duplicates from the array.
68 | 3. Return the updated array.
69 | */
70 |
71 | //Code Here
72 |
73 |
74 |
75 | ////////// PROBLEM 3 //////////
76 |
77 | // Do not edit the code below.
78 | var cat = {
79 | name: 'Fluffy',
80 | catFriends: [
81 | {
82 | name: 'Grumpy',
83 | activities: ['be grumpy', 'eat food']
84 | },
85 | {
86 | name: 'Lazy Bones',
87 | activities: ['sleep', 'pre-sleep naps']
88 | }
89 | ]
90 | }
91 | // Do not edit the code above.
92 |
93 | /*
94 | Fluffy has two friends, Grumpy and Lazy Bones.
95 | 1. Assign the value of Grumpy's 2nd activity to the grumpyActivity variable below.
96 | 2. Assign fluffy2ndFriend the name of Fluffy's 2nd friend.
97 | */
98 |
99 | //Code Here
100 | var grumpyActivity;
101 | var fluffy2ndFriend;
102 |
103 |
104 |
105 | ////////// PROBLEM 4 //////////
106 |
107 | // Do not edit the code below.
108 | var myCar = {
109 | make: 'Toyota',
110 | model: 'Corolla',
111 | year: 1992,
112 | accidents: [
113 | {
114 | date: '3/15/93',
115 | damage: '$5,000',
116 | atFaultForAccident: true
117 | },
118 | {
119 | date: '7/4/98',
120 | damage: '$2,200',
121 | atFaultForAccident: true
122 | },
123 | {
124 | date: '6/22/99',
125 | damage: '$7,900',
126 | atFaultForAccident: true
127 | }
128 | ]
129 | }
130 | // Do not edit the code above.
131 |
132 | /*
133 | Above is some information about my car. As you can see, I am not the best driver.
134 | I have caused a few accidents.
135 | Please update this driving record so that I can feel better about my driving skills.
136 | 1. Write a function called recordCleaner.
137 | 2. Loop over the accidents array.
138 | 3. Change atFaultForAccident from true to false.
139 | */
140 |
141 | //Code Here
142 |
143 |
144 |
145 | ////////// PROBLEM 5 //////////
146 |
147 | // Do not edit the code below.
148 | var numsArr = [ [1, 2, 3, 4], [5, 6], [7, 8, 9, 10, 11]];
149 | // Do not edit the code above.
150 |
151 | /*
152 | Above is an array of arrays. Use two for loops.
153 | 1. Write a function called 'looper'.
154 | 2. 'looper' should loop over the arrays.
155 | 3. If the number is odd, replace it with 'odd'.
156 | If the number is even, replace it with 'even'.
157 | 4. Return the modified numsArr.
158 | */
159 |
160 | //Code Here
161 |
162 |
163 |
--------------------------------------------------------------------------------
/test/MIT.LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-2014 Pivotal Labs
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/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 | /**
59 | * ## Reporters
60 | * 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).
61 | */
62 | var htmlReporter = new jasmine.HtmlReporter({
63 | env: env,
64 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
65 | onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
66 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
67 | getContainer: function() { return document.body; },
68 | createElement: function() { return document.createElement.apply(document, arguments); },
69 | createTextNode: function() { return document.createTextNode.apply(document, arguments); },
70 | timer: new jasmine.Timer()
71 | });
72 |
73 | /**
74 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
75 | */
76 | env.addReporter(jasmineInterface.jsApiReporter);
77 | env.addReporter(htmlReporter);
78 |
79 | /**
80 | * Filter which specs will be run by matching the start of the full name against the `spec` query param.
81 | */
82 | var specFilter = new jasmine.HtmlSpecFilter({
83 | filterString: function() { return queryString.getParam("spec"); }
84 | });
85 |
86 | env.specFilter = function(spec) {
87 | return specFilter.matches(spec.getFullName());
88 | };
89 |
90 | /**
91 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
92 | */
93 | window.setTimeout = window.setTimeout;
94 | window.setInterval = window.setInterval;
95 | window.clearTimeout = window.clearTimeout;
96 | window.clearInterval = window.clearInterval;
97 |
98 | /**
99 | * ## Execution
100 | *
101 | * 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.
102 | */
103 | var currentWindowOnload = window.onload;
104 |
105 | window.onload = function() {
106 | if (currentWindowOnload) {
107 | currentWindowOnload();
108 | }
109 | htmlReporter.initialize();
110 | env.execute();
111 | };
112 |
113 | /**
114 | * Helper function for readability above.
115 | */
116 | function extend(destination, source) {
117 | for (var property in source) destination[property] = source[property];
118 | return destination;
119 | }
120 |
121 | }());
122 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/console.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2015 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 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/jasmine-html.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2015 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 | addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
45 | timer = options.timer || noopTimer,
46 | results = [],
47 | specsExecuted = 0,
48 | failureCount = 0,
49 | pendingSpecCount = 0,
50 | htmlReporterMain,
51 | symbols,
52 | failedSuites = [];
53 |
54 | this.initialize = function() {
55 | clearPrior();
56 | htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
57 | createDom('div', {className: 'banner'},
58 | createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
59 | createDom('span', {className: 'version'}, j$.version)
60 | ),
61 | createDom('ul', {className: 'symbol-summary'}),
62 | createDom('div', {className: 'alert'}),
63 | createDom('div', {className: 'results'},
64 | createDom('div', {className: 'failures'})
65 | )
66 | );
67 | getContainer().appendChild(htmlReporterMain);
68 |
69 | symbols = find('.symbol-summary');
70 | };
71 |
72 | var totalSpecsDefined;
73 | this.jasmineStarted = function(options) {
74 | totalSpecsDefined = options.totalSpecsDefined || 0;
75 | timer.start();
76 | };
77 |
78 | var summary = createDom('div', {className: 'summary'});
79 |
80 | var topResults = new j$.ResultsNode({}, '', null),
81 | currentParent = topResults;
82 |
83 | this.suiteStarted = function(result) {
84 | currentParent.addChild(result, 'suite');
85 | currentParent = currentParent.last();
86 | };
87 |
88 | this.suiteDone = function(result) {
89 | if (result.status == 'failed') {
90 | failedSuites.push(result);
91 | }
92 |
93 | if (currentParent == topResults) {
94 | return;
95 | }
96 |
97 | currentParent = currentParent.parent;
98 | };
99 |
100 | this.specStarted = function(result) {
101 | currentParent.addChild(result, 'spec');
102 | };
103 |
104 | var failures = [];
105 | this.specDone = function(result) {
106 | if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
107 | console.error('Spec \'' + result.fullName + '\' has no expectations.');
108 | }
109 |
110 | if (result.status != 'disabled') {
111 | specsExecuted++;
112 | }
113 |
114 | symbols.appendChild(createDom('li', {
115 | className: noExpectations(result) ? 'empty' : result.status,
116 | id: 'spec_' + result.id,
117 | title: result.fullName
118 | }
119 | ));
120 |
121 | if (result.status == 'failed') {
122 | failureCount++;
123 |
124 | var failure =
125 | createDom('div', {className: 'spec-detail failed'},
126 | createDom('div', {className: 'description'},
127 | createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
128 | ),
129 | createDom('div', {className: 'messages'})
130 | );
131 | var messages = failure.childNodes[1];
132 |
133 | for (var i = 0; i < result.failedExpectations.length; i++) {
134 | var expectation = result.failedExpectations[i];
135 | messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
136 | messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
137 | }
138 |
139 | failures.push(failure);
140 | }
141 |
142 | if (result.status == 'pending') {
143 | pendingSpecCount++;
144 | }
145 | };
146 |
147 | this.jasmineDone = function() {
148 | var banner = find('.banner');
149 | var alert = find('.alert');
150 | alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
151 |
152 | banner.appendChild(
153 | createDom('div', { className: 'run-options' },
154 | createDom('span', { className: 'trigger' }, 'Options'),
155 | createDom('div', { className: 'payload' },
156 | createDom('div', { className: 'exceptions' },
157 | createDom('input', {
158 | className: 'raise',
159 | id: 'raise-exceptions',
160 | type: 'checkbox'
161 | }),
162 | createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')),
163 | createDom('div', { className: 'throw-failures' },
164 | createDom('input', {
165 | className: 'throw',
166 | id: 'throw-failures',
167 | type: 'checkbox'
168 | }),
169 | createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure'))
170 | )
171 | ));
172 |
173 | var raiseCheckbox = find('#raise-exceptions');
174 |
175 | raiseCheckbox.checked = !env.catchingExceptions();
176 | raiseCheckbox.onclick = onRaiseExceptionsClick;
177 |
178 | var throwCheckbox = find('#throw-failures');
179 | throwCheckbox.checked = env.throwingExpectationFailures();
180 | throwCheckbox.onclick = onThrowExpectationsClick;
181 |
182 | var optionsMenu = find('.run-options'),
183 | optionsTrigger = optionsMenu.querySelector('.trigger'),
184 | optionsPayload = optionsMenu.querySelector('.payload'),
185 | isOpen = /\bopen\b/;
186 |
187 | optionsTrigger.onclick = function() {
188 | if (isOpen.test(optionsPayload.className)) {
189 | optionsPayload.className = optionsPayload.className.replace(isOpen, '');
190 | } else {
191 | optionsPayload.className += ' open';
192 | }
193 | };
194 |
195 | if (specsExecuted < totalSpecsDefined) {
196 | var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
197 | alert.appendChild(
198 | createDom('span', {className: 'bar skipped'},
199 | createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
200 | )
201 | );
202 | }
203 | var statusBarMessage = '';
204 | var statusBarClassName = 'bar ';
205 |
206 | if (totalSpecsDefined > 0) {
207 | statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
208 | if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
209 | statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
210 | } else {
211 | statusBarClassName += 'skipped';
212 | statusBarMessage += 'No specs found';
213 | }
214 |
215 | alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
216 |
217 | for(i = 0; i < failedSuites.length; i++) {
218 | var failedSuite = failedSuites[i];
219 | for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
220 | var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
221 | var errorBarClassName = 'bar errored';
222 | alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
223 | }
224 | }
225 |
226 | var results = find('.results');
227 | results.appendChild(summary);
228 |
229 | summaryList(topResults, summary);
230 |
231 | function summaryList(resultsTree, domParent) {
232 | var specListNode;
233 | for (var i = 0; i < resultsTree.children.length; i++) {
234 | var resultNode = resultsTree.children[i];
235 | if (resultNode.type == 'suite') {
236 | var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
237 | createDom('li', {className: 'suite-detail'},
238 | createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
239 | )
240 | );
241 |
242 | summaryList(resultNode, suiteListNode);
243 | domParent.appendChild(suiteListNode);
244 | }
245 | if (resultNode.type == 'spec') {
246 | if (domParent.getAttribute('class') != 'specs') {
247 | specListNode = createDom('ul', {className: 'specs'});
248 | domParent.appendChild(specListNode);
249 | }
250 | var specDescription = resultNode.result.description;
251 | if(noExpectations(resultNode.result)) {
252 | specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
253 | }
254 | if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
255 | specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
256 | }
257 | specListNode.appendChild(
258 | createDom('li', {
259 | className: resultNode.result.status,
260 | id: 'spec-' + resultNode.result.id
261 | },
262 | createDom('a', {href: specHref(resultNode.result)}, specDescription)
263 | )
264 | );
265 | }
266 | }
267 | }
268 |
269 | if (failures.length) {
270 | alert.appendChild(
271 | createDom('span', {className: 'menu bar spec-list'},
272 | createDom('span', {}, 'Spec List | '),
273 | createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
274 | alert.appendChild(
275 | createDom('span', {className: 'menu bar failure-list'},
276 | createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
277 | createDom('span', {}, ' | Failures ')));
278 |
279 | find('.failures-menu').onclick = function() {
280 | setMenuModeTo('failure-list');
281 | };
282 | find('.spec-list-menu').onclick = function() {
283 | setMenuModeTo('spec-list');
284 | };
285 |
286 | setMenuModeTo('failure-list');
287 |
288 | var failureNode = find('.failures');
289 | for (var i = 0; i < failures.length; i++) {
290 | failureNode.appendChild(failures[i]);
291 | }
292 | }
293 | };
294 |
295 | return this;
296 |
297 | function find(selector) {
298 | return getContainer().querySelector('.jasmine_html-reporter ' + selector);
299 | }
300 |
301 | function clearPrior() {
302 | // return the reporter
303 | var oldReporter = find('');
304 |
305 | if(oldReporter) {
306 | getContainer().removeChild(oldReporter);
307 | }
308 | }
309 |
310 | function createDom(type, attrs, childrenVarArgs) {
311 | var el = createElement(type);
312 |
313 | for (var i = 2; i < arguments.length; i++) {
314 | var child = arguments[i];
315 |
316 | if (typeof child === 'string') {
317 | el.appendChild(createTextNode(child));
318 | } else {
319 | if (child) {
320 | el.appendChild(child);
321 | }
322 | }
323 | }
324 |
325 | for (var attr in attrs) {
326 | if (attr == 'className') {
327 | el[attr] = attrs[attr];
328 | } else {
329 | el.setAttribute(attr, attrs[attr]);
330 | }
331 | }
332 |
333 | return el;
334 | }
335 |
336 | function pluralize(singular, count) {
337 | var word = (count == 1 ? singular : singular + 's');
338 |
339 | return '' + count + ' ' + word;
340 | }
341 |
342 | function specHref(result) {
343 | return addToExistingQueryString('spec', result.fullName);
344 | }
345 |
346 | function defaultQueryString(key, value) {
347 | return '?' + key + '=' + value;
348 | }
349 |
350 | function setMenuModeTo(mode) {
351 | htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
352 | }
353 |
354 | function noExpectations(result) {
355 | return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
356 | result.status === 'passed';
357 | }
358 | }
359 |
360 | return HtmlReporter;
361 | };
362 |
363 | jasmineRequire.HtmlSpecFilter = function() {
364 | function HtmlSpecFilter(options) {
365 | var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
366 | var filterPattern = new RegExp(filterString);
367 |
368 | this.matches = function(specName) {
369 | return filterPattern.test(specName);
370 | };
371 | }
372 |
373 | return HtmlSpecFilter;
374 | };
375 |
376 | jasmineRequire.ResultsNode = function() {
377 | function ResultsNode(result, type, parent) {
378 | this.result = result;
379 | this.type = type;
380 | this.parent = parent;
381 |
382 | this.children = [];
383 |
384 | this.addChild = function(result, type) {
385 | this.children.push(new ResultsNode(result, type, this));
386 | };
387 |
388 | this.last = function() {
389 | return this.children[this.children.length - 1];
390 | };
391 | }
392 |
393 | return ResultsNode;
394 | };
395 |
396 | jasmineRequire.QueryString = function() {
397 | function QueryString(options) {
398 |
399 | this.navigateWithNewParam = function(key, value) {
400 | options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
401 | };
402 |
403 | this.fullStringWithNewParam = function(key, value) {
404 | var paramMap = queryStringToParamMap();
405 | paramMap[key] = value;
406 | return toQueryString(paramMap);
407 | };
408 |
409 | this.getParam = function(key) {
410 | return queryStringToParamMap()[key];
411 | };
412 |
413 | return this;
414 |
415 | function toQueryString(paramMap) {
416 | var qStrPairs = [];
417 | for (var prop in paramMap) {
418 | qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
419 | }
420 | return '?' + qStrPairs.join('&');
421 | }
422 |
423 | function queryStringToParamMap() {
424 | var paramStr = options.getWindowLocation().search.substring(1),
425 | params = [],
426 | paramMap = {};
427 |
428 | if (paramStr.length > 0) {
429 | params = paramStr.split('&');
430 | for (var i = 0; i < params.length; i++) {
431 | var p = params[i].split('=');
432 | var value = decodeURIComponent(p[1]);
433 | if (value === 'true' || value === 'false') {
434 | value = JSON.parse(value);
435 | }
436 | paramMap[decodeURIComponent(p[0])] = value;
437 | }
438 | }
439 |
440 | return paramMap;
441 | }
442 |
443 | }
444 |
445 | return QueryString;
446 | };
447 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/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 .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
8 | .jasmine_html-reporter .banner { position: relative; }
9 | .jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4KIQoSKQYKIQICIQISMQoSKQYKLQIOLQoOJQYGLQIOKQIOMQoGKQYOLQYGKQIOLQoGJQYOJQIOKQYGJQIOKQoGKQIGLQIKLQ4KKQoGLQYKJQIGKQYKJQIGKQIKJQoGKQYKLQIGKQYKLQIOJQoKKQoOJQYKKQIOJQoKKQoOKQIOLQoKKQYOLQYKJQIOKQoKKQYKKQoKJQYOKQYKLQIOKQoKLQYOKQYKLQIOJQoGKQYKJQYGJQoGKQYKLQoGLQYGKQoGJQYKKQYGJQIKKQoGJQYKLQIKKQYGLQYKKQYGKQYGKQYKJQYOKQoKJQYOKQYKLQYOLQYOKQYKLQYOKQoKKQYKKQYOKQYOJQYKKQYKLQYKKQIKKQoKKQYKKQYKKQoKJQIKKQYKLQYKKQYKKQIKKQYKKQYKKQYKKQIKKQYKJQYGLQYGKQYKKQYKKQYGKQIKKQYGKQYOJ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hNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+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 .banner .version { margin-left: 14px; position: relative; top: 6px; }
11 | .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; }
12 | .jasmine_html-reporter .version { color: #aaa; }
13 | .jasmine_html-reporter .banner { margin-top: 14px; }
14 | .jasmine_html-reporter .duration { color: #fff; float: right; line-height: 28px; padding-right: 9px; }
15 | .jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
16 | .jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
17 | .jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; }
18 | .jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; }
19 | .jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; }
20 | .jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
21 | .jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; }
22 | .jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
23 | .jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; }
24 | .jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
25 | .jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; }
26 | .jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; }
27 | .jasmine_html-reporter .run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; }
28 | .jasmine_html-reporter .run-options .trigger { cursor: pointer; padding: 8px 16px; }
29 | .jasmine_html-reporter .run-options .payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; }
30 | .jasmine_html-reporter .run-options .payload.open { display: block; }
31 | .jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
32 | .jasmine_html-reporter .bar.failed { background-color: #ca3a11; }
33 | .jasmine_html-reporter .bar.passed { background-color: #007069; }
34 | .jasmine_html-reporter .bar.skipped { background-color: #bababa; }
35 | .jasmine_html-reporter .bar.errored { background-color: #ca3a11; }
36 | .jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaa; }
37 | .jasmine_html-reporter .bar.menu a { color: #333; }
38 | .jasmine_html-reporter .bar a { color: white; }
39 | .jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; }
40 | .jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; }
41 | .jasmine_html-reporter .results { margin-top: 14px; }
42 | .jasmine_html-reporter .summary { margin-top: 14px; }
43 | .jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
44 | .jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
45 | .jasmine_html-reporter .summary li.passed a { color: #007069; }
46 | .jasmine_html-reporter .summary li.failed a { color: #ca3a11; }
47 | .jasmine_html-reporter .summary li.empty a { color: #ba9d37; }
48 | .jasmine_html-reporter .summary li.pending a { color: #ba9d37; }
49 | .jasmine_html-reporter .summary li.disabled a { color: #bababa; }
50 | .jasmine_html-reporter .description + .suite { margin-top: 0; }
51 | .jasmine_html-reporter .suite { margin-top: 14px; }
52 | .jasmine_html-reporter .suite a { color: #333; }
53 | .jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; }
54 | .jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; }
55 | .jasmine_html-reporter .failures .spec-detail .description a { color: white; }
56 | .jasmine_html-reporter .result-message { padding-top: 14px; color: #333; white-space: pre; }
57 | .jasmine_html-reporter .result-message span.result { display: block; }
58 | .jasmine_html-reporter .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 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/jasmine.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2015 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) {
27 | jasmineGlobal = global;
28 | jasmineRequire = exports;
29 | } else {
30 | if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') {
31 | jasmineGlobal = window;
32 | }
33 | jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
34 | }
35 |
36 | function getJasmineRequire() {
37 | return jasmineRequire;
38 | }
39 |
40 | getJasmineRequire().core = function(jRequire) {
41 | var j$ = {};
42 |
43 | jRequire.base(j$, jasmineGlobal);
44 | j$.util = jRequire.util();
45 | j$.errors = jRequire.errors();
46 | j$.Any = jRequire.Any(j$);
47 | j$.Anything = jRequire.Anything(j$);
48 | j$.CallTracker = jRequire.CallTracker();
49 | j$.MockDate = jRequire.MockDate();
50 | j$.Clock = jRequire.Clock();
51 | j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
52 | j$.Env = jRequire.Env(j$);
53 | j$.ExceptionFormatter = jRequire.ExceptionFormatter();
54 | j$.Expectation = jRequire.Expectation();
55 | j$.buildExpectationResult = jRequire.buildExpectationResult();
56 | j$.JsApiReporter = jRequire.JsApiReporter();
57 | j$.matchersUtil = jRequire.matchersUtil(j$);
58 | j$.ObjectContaining = jRequire.ObjectContaining(j$);
59 | j$.ArrayContaining = jRequire.ArrayContaining(j$);
60 | j$.pp = jRequire.pp(j$);
61 | j$.QueueRunner = jRequire.QueueRunner(j$);
62 | j$.ReportDispatcher = jRequire.ReportDispatcher();
63 | j$.Spec = jRequire.Spec(j$);
64 | j$.SpyRegistry = jRequire.SpyRegistry(j$);
65 | j$.SpyStrategy = jRequire.SpyStrategy();
66 | j$.StringMatching = jRequire.StringMatching(j$);
67 | j$.Suite = jRequire.Suite(j$);
68 | j$.Timer = jRequire.Timer();
69 | j$.TreeProcessor = jRequire.TreeProcessor();
70 | j$.version = jRequire.version();
71 |
72 | j$.matchers = jRequire.requireMatchers(jRequire, j$);
73 |
74 | return j$;
75 | };
76 |
77 | return getJasmineRequire;
78 | })(this);
79 |
80 | getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
81 | var availableMatchers = [
82 | 'toBe',
83 | 'toBeCloseTo',
84 | 'toBeDefined',
85 | 'toBeFalsy',
86 | 'toBeGreaterThan',
87 | 'toBeLessThan',
88 | 'toBeNaN',
89 | 'toBeNull',
90 | 'toBeTruthy',
91 | 'toBeUndefined',
92 | 'toContain',
93 | 'toEqual',
94 | 'toHaveBeenCalled',
95 | 'toHaveBeenCalledWith',
96 | 'toMatch',
97 | 'toThrow',
98 | 'toThrowError'
99 | ],
100 | matchers = {};
101 |
102 | for (var i = 0; i < availableMatchers.length; i++) {
103 | var name = availableMatchers[i];
104 | matchers[name] = jRequire[name](j$);
105 | }
106 |
107 | return matchers;
108 | };
109 |
110 | getJasmineRequireObj().base = function(j$, jasmineGlobal) {
111 | j$.unimplementedMethod_ = function() {
112 | throw new Error('unimplemented method');
113 | };
114 |
115 | j$.MAX_PRETTY_PRINT_DEPTH = 40;
116 | j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100;
117 | j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
118 |
119 | j$.getGlobal = function() {
120 | return jasmineGlobal;
121 | };
122 |
123 | j$.getEnv = function(options) {
124 | var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
125 | //jasmine. singletons in here (setTimeout blah blah).
126 | return env;
127 | };
128 |
129 | j$.isArray_ = function(value) {
130 | return j$.isA_('Array', value);
131 | };
132 |
133 | j$.isString_ = function(value) {
134 | return j$.isA_('String', value);
135 | };
136 |
137 | j$.isNumber_ = function(value) {
138 | return j$.isA_('Number', value);
139 | };
140 |
141 | j$.isA_ = function(typeName, value) {
142 | return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
143 | };
144 |
145 | j$.isDomNode = function(obj) {
146 | return obj.nodeType > 0;
147 | };
148 |
149 | j$.fnNameFor = function(func) {
150 | return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
151 | };
152 |
153 | j$.any = function(clazz) {
154 | return new j$.Any(clazz);
155 | };
156 |
157 | j$.anything = function() {
158 | return new j$.Anything();
159 | };
160 |
161 | j$.objectContaining = function(sample) {
162 | return new j$.ObjectContaining(sample);
163 | };
164 |
165 | j$.stringMatching = function(expected) {
166 | return new j$.StringMatching(expected);
167 | };
168 |
169 | j$.arrayContaining = function(sample) {
170 | return new j$.ArrayContaining(sample);
171 | };
172 |
173 | j$.createSpy = function(name, originalFn) {
174 |
175 | var spyStrategy = new j$.SpyStrategy({
176 | name: name,
177 | fn: originalFn,
178 | getSpy: function() { return spy; }
179 | }),
180 | callTracker = new j$.CallTracker(),
181 | spy = function() {
182 | var callData = {
183 | object: this,
184 | args: Array.prototype.slice.apply(arguments)
185 | };
186 |
187 | callTracker.track(callData);
188 | var returnValue = spyStrategy.exec.apply(this, arguments);
189 | callData.returnValue = returnValue;
190 |
191 | return returnValue;
192 | };
193 |
194 | for (var prop in originalFn) {
195 | if (prop === 'and' || prop === 'calls') {
196 | throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon');
197 | }
198 |
199 | spy[prop] = originalFn[prop];
200 | }
201 |
202 | spy.and = spyStrategy;
203 | spy.calls = callTracker;
204 |
205 | return spy;
206 | };
207 |
208 | j$.isSpy = function(putativeSpy) {
209 | if (!putativeSpy) {
210 | return false;
211 | }
212 | return putativeSpy.and instanceof j$.SpyStrategy &&
213 | putativeSpy.calls instanceof j$.CallTracker;
214 | };
215 |
216 | j$.createSpyObj = function(baseName, methodNames) {
217 | if (j$.isArray_(baseName) && j$.util.isUndefined(methodNames)) {
218 | methodNames = baseName;
219 | baseName = 'unknown';
220 | }
221 |
222 | if (!j$.isArray_(methodNames) || methodNames.length === 0) {
223 | throw 'createSpyObj requires a non-empty array of method names to create spies for';
224 | }
225 | var obj = {};
226 | for (var i = 0; i < methodNames.length; i++) {
227 | obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
228 | }
229 | return obj;
230 | };
231 | };
232 |
233 | getJasmineRequireObj().util = function() {
234 |
235 | var util = {};
236 |
237 | util.inherit = function(childClass, parentClass) {
238 | var Subclass = function() {
239 | };
240 | Subclass.prototype = parentClass.prototype;
241 | childClass.prototype = new Subclass();
242 | };
243 |
244 | util.htmlEscape = function(str) {
245 | if (!str) {
246 | return str;
247 | }
248 | return str.replace(/&/g, '&')
249 | .replace(//g, '>');
251 | };
252 |
253 | util.argsToArray = function(args) {
254 | var arrayOfArgs = [];
255 | for (var i = 0; i < args.length; i++) {
256 | arrayOfArgs.push(args[i]);
257 | }
258 | return arrayOfArgs;
259 | };
260 |
261 | util.isUndefined = function(obj) {
262 | return obj === void 0;
263 | };
264 |
265 | util.arrayContains = function(array, search) {
266 | var i = array.length;
267 | while (i--) {
268 | if (array[i] === search) {
269 | return true;
270 | }
271 | }
272 | return false;
273 | };
274 |
275 | util.clone = function(obj) {
276 | if (Object.prototype.toString.apply(obj) === '[object Array]') {
277 | return obj.slice();
278 | }
279 |
280 | var cloned = {};
281 | for (var prop in obj) {
282 | if (obj.hasOwnProperty(prop)) {
283 | cloned[prop] = obj[prop];
284 | }
285 | }
286 |
287 | return cloned;
288 | };
289 |
290 | return util;
291 | };
292 |
293 | getJasmineRequireObj().Spec = function(j$) {
294 | function Spec(attrs) {
295 | this.expectationFactory = attrs.expectationFactory;
296 | this.resultCallback = attrs.resultCallback || function() {};
297 | this.id = attrs.id;
298 | this.description = attrs.description || '';
299 | this.queueableFn = attrs.queueableFn;
300 | this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
301 | this.userContext = attrs.userContext || function() { return {}; };
302 | this.onStart = attrs.onStart || function() {};
303 | this.getSpecName = attrs.getSpecName || function() { return ''; };
304 | this.expectationResultFactory = attrs.expectationResultFactory || function() { };
305 | this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
306 | this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
307 | this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
308 |
309 | if (!this.queueableFn.fn) {
310 | this.pend();
311 | }
312 |
313 | this.result = {
314 | id: this.id,
315 | description: this.description,
316 | fullName: this.getFullName(),
317 | failedExpectations: [],
318 | passedExpectations: [],
319 | pendingReason: ''
320 | };
321 | }
322 |
323 | Spec.prototype.addExpectationResult = function(passed, data, isError) {
324 | var expectationResult = this.expectationResultFactory(data);
325 | if (passed) {
326 | this.result.passedExpectations.push(expectationResult);
327 | } else {
328 | this.result.failedExpectations.push(expectationResult);
329 |
330 | if (this.throwOnExpectationFailure && !isError) {
331 | throw new j$.errors.ExpectationFailed();
332 | }
333 | }
334 | };
335 |
336 | Spec.prototype.expect = function(actual) {
337 | return this.expectationFactory(actual, this);
338 | };
339 |
340 | Spec.prototype.execute = function(onComplete, enabled) {
341 | var self = this;
342 |
343 | this.onStart(this);
344 |
345 | if (!this.isExecutable() || this.markedPending || enabled === false) {
346 | complete(enabled);
347 | return;
348 | }
349 |
350 | var fns = this.beforeAndAfterFns();
351 | var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
352 |
353 | this.queueRunnerFactory({
354 | queueableFns: allFns,
355 | onException: function() { self.onException.apply(self, arguments); },
356 | onComplete: complete,
357 | userContext: this.userContext()
358 | });
359 |
360 | function complete(enabledAgain) {
361 | self.result.status = self.status(enabledAgain);
362 | self.resultCallback(self.result);
363 |
364 | if (onComplete) {
365 | onComplete();
366 | }
367 | }
368 | };
369 |
370 | Spec.prototype.onException = function onException(e) {
371 | if (Spec.isPendingSpecException(e)) {
372 | this.pend(extractCustomPendingMessage(e));
373 | return;
374 | }
375 |
376 | if (e instanceof j$.errors.ExpectationFailed) {
377 | return;
378 | }
379 |
380 | this.addExpectationResult(false, {
381 | matcherName: '',
382 | passed: false,
383 | expected: '',
384 | actual: '',
385 | error: e
386 | }, true);
387 | };
388 |
389 | Spec.prototype.disable = function() {
390 | this.disabled = true;
391 | };
392 |
393 | Spec.prototype.pend = function(message) {
394 | this.markedPending = true;
395 | if (message) {
396 | this.result.pendingReason = message;
397 | }
398 | };
399 |
400 | Spec.prototype.getResult = function() {
401 | this.result.status = this.status();
402 | return this.result;
403 | };
404 |
405 | Spec.prototype.status = function(enabled) {
406 | if (this.disabled || enabled === false) {
407 | return 'disabled';
408 | }
409 |
410 | if (this.markedPending) {
411 | return 'pending';
412 | }
413 |
414 | if (this.result.failedExpectations.length > 0) {
415 | return 'failed';
416 | } else {
417 | return 'passed';
418 | }
419 | };
420 |
421 | Spec.prototype.isExecutable = function() {
422 | return !this.disabled;
423 | };
424 |
425 | Spec.prototype.getFullName = function() {
426 | return this.getSpecName(this);
427 | };
428 |
429 | var extractCustomPendingMessage = function(e) {
430 | var fullMessage = e.toString(),
431 | boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
432 | boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length;
433 |
434 | return fullMessage.substr(boilerplateEnd);
435 | };
436 |
437 | Spec.pendingSpecExceptionMessage = '=> marked Pending';
438 |
439 | Spec.isPendingSpecException = function(e) {
440 | return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1);
441 | };
442 |
443 | return Spec;
444 | };
445 |
446 | if (typeof window == void 0 && typeof exports == 'object') {
447 | exports.Spec = jasmineRequire.Spec;
448 | }
449 |
450 | getJasmineRequireObj().Env = function(j$) {
451 | function Env(options) {
452 | options = options || {};
453 |
454 | var self = this;
455 | var global = options.global || j$.getGlobal();
456 |
457 | var totalSpecsDefined = 0;
458 |
459 | var catchExceptions = true;
460 |
461 | var realSetTimeout = j$.getGlobal().setTimeout;
462 | var realClearTimeout = j$.getGlobal().clearTimeout;
463 | this.clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global));
464 |
465 | var runnableLookupTable = {};
466 | var runnableResources = {};
467 |
468 | var currentSpec = null;
469 | var currentlyExecutingSuites = [];
470 | var currentDeclarationSuite = null;
471 | var throwOnExpectationFailure = false;
472 |
473 | var currentSuite = function() {
474 | return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
475 | };
476 |
477 | var currentRunnable = function() {
478 | return currentSpec || currentSuite();
479 | };
480 |
481 | var reporter = new j$.ReportDispatcher([
482 | 'jasmineStarted',
483 | 'jasmineDone',
484 | 'suiteStarted',
485 | 'suiteDone',
486 | 'specStarted',
487 | 'specDone'
488 | ]);
489 |
490 | this.specFilter = function() {
491 | return true;
492 | };
493 |
494 | this.addCustomEqualityTester = function(tester) {
495 | if(!currentRunnable()) {
496 | throw new Error('Custom Equalities must be added in a before function or a spec');
497 | }
498 | runnableResources[currentRunnable().id].customEqualityTesters.push(tester);
499 | };
500 |
501 | this.addMatchers = function(matchersToAdd) {
502 | if(!currentRunnable()) {
503 | throw new Error('Matchers must be added in a before function or a spec');
504 | }
505 | var customMatchers = runnableResources[currentRunnable().id].customMatchers;
506 | for (var matcherName in matchersToAdd) {
507 | customMatchers[matcherName] = matchersToAdd[matcherName];
508 | }
509 | };
510 |
511 | j$.Expectation.addCoreMatchers(j$.matchers);
512 |
513 | var nextSpecId = 0;
514 | var getNextSpecId = function() {
515 | return 'spec' + nextSpecId++;
516 | };
517 |
518 | var nextSuiteId = 0;
519 | var getNextSuiteId = function() {
520 | return 'suite' + nextSuiteId++;
521 | };
522 |
523 | var expectationFactory = function(actual, spec) {
524 | return j$.Expectation.Factory({
525 | util: j$.matchersUtil,
526 | customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
527 | customMatchers: runnableResources[spec.id].customMatchers,
528 | actual: actual,
529 | addExpectationResult: addExpectationResult
530 | });
531 |
532 | function addExpectationResult(passed, result) {
533 | return spec.addExpectationResult(passed, result);
534 | }
535 | };
536 |
537 | var defaultResourcesForRunnable = function(id, parentRunnableId) {
538 | var resources = {spies: [], customEqualityTesters: [], customMatchers: {}};
539 |
540 | if(runnableResources[parentRunnableId]){
541 | resources.customEqualityTesters = j$.util.clone(runnableResources[parentRunnableId].customEqualityTesters);
542 | resources.customMatchers = j$.util.clone(runnableResources[parentRunnableId].customMatchers);
543 | }
544 |
545 | runnableResources[id] = resources;
546 | };
547 |
548 | var clearResourcesForRunnable = function(id) {
549 | spyRegistry.clearSpies();
550 | delete runnableResources[id];
551 | };
552 |
553 | var beforeAndAfterFns = function(suite) {
554 | return function() {
555 | var befores = [],
556 | afters = [];
557 |
558 | while(suite) {
559 | befores = befores.concat(suite.beforeFns);
560 | afters = afters.concat(suite.afterFns);
561 |
562 | suite = suite.parentSuite;
563 | }
564 |
565 | return {
566 | befores: befores.reverse(),
567 | afters: afters
568 | };
569 | };
570 | };
571 |
572 | var getSpecName = function(spec, suite) {
573 | return suite.getFullName() + ' ' + spec.description;
574 | };
575 |
576 | // TODO: we may just be able to pass in the fn instead of wrapping here
577 | var buildExpectationResult = j$.buildExpectationResult,
578 | exceptionFormatter = new j$.ExceptionFormatter(),
579 | expectationResultFactory = function(attrs) {
580 | attrs.messageFormatter = exceptionFormatter.message;
581 | attrs.stackFormatter = exceptionFormatter.stack;
582 |
583 | return buildExpectationResult(attrs);
584 | };
585 |
586 | // TODO: fix this naming, and here's where the value comes in
587 | this.catchExceptions = function(value) {
588 | catchExceptions = !!value;
589 | return catchExceptions;
590 | };
591 |
592 | this.catchingExceptions = function() {
593 | return catchExceptions;
594 | };
595 |
596 | var maximumSpecCallbackDepth = 20;
597 | var currentSpecCallbackDepth = 0;
598 |
599 | function clearStack(fn) {
600 | currentSpecCallbackDepth++;
601 | if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) {
602 | currentSpecCallbackDepth = 0;
603 | realSetTimeout(fn, 0);
604 | } else {
605 | fn();
606 | }
607 | }
608 |
609 | var catchException = function(e) {
610 | return j$.Spec.isPendingSpecException(e) || catchExceptions;
611 | };
612 |
613 | this.throwOnExpectationFailure = function(value) {
614 | throwOnExpectationFailure = !!value;
615 | };
616 |
617 | this.throwingExpectationFailures = function() {
618 | return throwOnExpectationFailure;
619 | };
620 |
621 | var queueRunnerFactory = function(options) {
622 | options.catchException = catchException;
623 | options.clearStack = options.clearStack || clearStack;
624 | options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
625 | options.fail = self.fail;
626 |
627 | new j$.QueueRunner(options).execute();
628 | };
629 |
630 | var topSuite = new j$.Suite({
631 | env: this,
632 | id: getNextSuiteId(),
633 | description: 'Jasmine__TopLevel__Suite',
634 | queueRunner: queueRunnerFactory
635 | });
636 | runnableLookupTable[topSuite.id] = topSuite;
637 | defaultResourcesForRunnable(topSuite.id);
638 | currentDeclarationSuite = topSuite;
639 |
640 | this.topSuite = function() {
641 | return topSuite;
642 | };
643 |
644 | this.execute = function(runnablesToRun) {
645 | if(!runnablesToRun) {
646 | if (focusedRunnables.length) {
647 | runnablesToRun = focusedRunnables;
648 | } else {
649 | runnablesToRun = [topSuite.id];
650 | }
651 | }
652 | var processor = new j$.TreeProcessor({
653 | tree: topSuite,
654 | runnableIds: runnablesToRun,
655 | queueRunnerFactory: queueRunnerFactory,
656 | nodeStart: function(suite) {
657 | currentlyExecutingSuites.push(suite);
658 | defaultResourcesForRunnable(suite.id, suite.parentSuite.id);
659 | reporter.suiteStarted(suite.result);
660 | },
661 | nodeComplete: function(suite, result) {
662 | if (!suite.disabled) {
663 | clearResourcesForRunnable(suite.id);
664 | }
665 | currentlyExecutingSuites.pop();
666 | reporter.suiteDone(result);
667 | }
668 | });
669 |
670 | if(!processor.processTree().valid) {
671 | throw new Error('Invalid order: would cause a beforeAll or afterAll to be run multiple times');
672 | }
673 |
674 | reporter.jasmineStarted({
675 | totalSpecsDefined: totalSpecsDefined
676 | });
677 |
678 | processor.execute(reporter.jasmineDone);
679 | };
680 |
681 | this.addReporter = function(reporterToAdd) {
682 | reporter.addReporter(reporterToAdd);
683 | };
684 |
685 | var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
686 | if(!currentRunnable()) {
687 | throw new Error('Spies must be created in a before function or a spec');
688 | }
689 | return runnableResources[currentRunnable().id].spies;
690 | }});
691 |
692 | this.spyOn = function() {
693 | return spyRegistry.spyOn.apply(spyRegistry, arguments);
694 | };
695 |
696 | var suiteFactory = function(description) {
697 | var suite = new j$.Suite({
698 | env: self,
699 | id: getNextSuiteId(),
700 | description: description,
701 | parentSuite: currentDeclarationSuite,
702 | expectationFactory: expectationFactory,
703 | expectationResultFactory: expectationResultFactory,
704 | throwOnExpectationFailure: throwOnExpectationFailure
705 | });
706 |
707 | runnableLookupTable[suite.id] = suite;
708 | return suite;
709 | };
710 |
711 | this.describe = function(description, specDefinitions) {
712 | var suite = suiteFactory(description);
713 | addSpecsToSuite(suite, specDefinitions);
714 | return suite;
715 | };
716 |
717 | this.xdescribe = function(description, specDefinitions) {
718 | var suite = this.describe(description, specDefinitions);
719 | suite.disable();
720 | return suite;
721 | };
722 |
723 | var focusedRunnables = [];
724 |
725 | this.fdescribe = function(description, specDefinitions) {
726 | var suite = suiteFactory(description);
727 | suite.isFocused = true;
728 |
729 | focusedRunnables.push(suite.id);
730 | unfocusAncestor();
731 | addSpecsToSuite(suite, specDefinitions);
732 |
733 | return suite;
734 | };
735 |
736 | function addSpecsToSuite(suite, specDefinitions) {
737 | var parentSuite = currentDeclarationSuite;
738 | parentSuite.addChild(suite);
739 | currentDeclarationSuite = suite;
740 |
741 | var declarationError = null;
742 | try {
743 | specDefinitions.call(suite);
744 | } catch (e) {
745 | declarationError = e;
746 | }
747 |
748 | if (declarationError) {
749 | self.it('encountered a declaration exception', function() {
750 | throw declarationError;
751 | });
752 | }
753 |
754 | currentDeclarationSuite = parentSuite;
755 | }
756 |
757 | function findFocusedAncestor(suite) {
758 | while (suite) {
759 | if (suite.isFocused) {
760 | return suite.id;
761 | }
762 | suite = suite.parentSuite;
763 | }
764 |
765 | return null;
766 | }
767 |
768 | function unfocusAncestor() {
769 | var focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
770 | if (focusedAncestor) {
771 | for (var i = 0; i < focusedRunnables.length; i++) {
772 | if (focusedRunnables[i] === focusedAncestor) {
773 | focusedRunnables.splice(i, 1);
774 | break;
775 | }
776 | }
777 | }
778 | }
779 |
780 | var specFactory = function(description, fn, suite, timeout) {
781 | totalSpecsDefined++;
782 | var spec = new j$.Spec({
783 | id: getNextSpecId(),
784 | beforeAndAfterFns: beforeAndAfterFns(suite),
785 | expectationFactory: expectationFactory,
786 | resultCallback: specResultCallback,
787 | getSpecName: function(spec) {
788 | return getSpecName(spec, suite);
789 | },
790 | onStart: specStarted,
791 | description: description,
792 | expectationResultFactory: expectationResultFactory,
793 | queueRunnerFactory: queueRunnerFactory,
794 | userContext: function() { return suite.clonedSharedUserContext(); },
795 | queueableFn: {
796 | fn: fn,
797 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
798 | },
799 | throwOnExpectationFailure: throwOnExpectationFailure
800 | });
801 |
802 | runnableLookupTable[spec.id] = spec;
803 |
804 | if (!self.specFilter(spec)) {
805 | spec.disable();
806 | }
807 |
808 | return spec;
809 |
810 | function specResultCallback(result) {
811 | clearResourcesForRunnable(spec.id);
812 | currentSpec = null;
813 | reporter.specDone(result);
814 | }
815 |
816 | function specStarted(spec) {
817 | currentSpec = spec;
818 | defaultResourcesForRunnable(spec.id, suite.id);
819 | reporter.specStarted(spec.result);
820 | }
821 | };
822 |
823 | this.it = function(description, fn, timeout) {
824 | var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
825 | currentDeclarationSuite.addChild(spec);
826 | return spec;
827 | };
828 |
829 | this.xit = function() {
830 | var spec = this.it.apply(this, arguments);
831 | spec.pend();
832 | return spec;
833 | };
834 |
835 | this.fit = function(){
836 | var spec = this.it.apply(this, arguments);
837 |
838 | focusedRunnables.push(spec.id);
839 | unfocusAncestor();
840 | return spec;
841 | };
842 |
843 | this.expect = function(actual) {
844 | if (!currentRunnable()) {
845 | throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out');
846 | }
847 |
848 | return currentRunnable().expect(actual);
849 | };
850 |
851 | this.beforeEach = function(beforeEachFunction, timeout) {
852 | currentDeclarationSuite.beforeEach({
853 | fn: beforeEachFunction,
854 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
855 | });
856 | };
857 |
858 | this.beforeAll = function(beforeAllFunction, timeout) {
859 | currentDeclarationSuite.beforeAll({
860 | fn: beforeAllFunction,
861 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
862 | });
863 | };
864 |
865 | this.afterEach = function(afterEachFunction, timeout) {
866 | currentDeclarationSuite.afterEach({
867 | fn: afterEachFunction,
868 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
869 | });
870 | };
871 |
872 | this.afterAll = function(afterAllFunction, timeout) {
873 | currentDeclarationSuite.afterAll({
874 | fn: afterAllFunction,
875 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
876 | });
877 | };
878 |
879 | this.pending = function(message) {
880 | var fullMessage = j$.Spec.pendingSpecExceptionMessage;
881 | if(message) {
882 | fullMessage += message;
883 | }
884 | throw fullMessage;
885 | };
886 |
887 | this.fail = function(error) {
888 | var message = 'Failed';
889 | if (error) {
890 | message += ': ';
891 | message += error.message || error;
892 | }
893 |
894 | currentRunnable().addExpectationResult(false, {
895 | matcherName: '',
896 | passed: false,
897 | expected: '',
898 | actual: '',
899 | message: message,
900 | error: error && error.message ? error : null
901 | });
902 | };
903 | }
904 |
905 | return Env;
906 | };
907 |
908 | getJasmineRequireObj().JsApiReporter = function() {
909 |
910 | var noopTimer = {
911 | start: function(){},
912 | elapsed: function(){ return 0; }
913 | };
914 |
915 | function JsApiReporter(options) {
916 | var timer = options.timer || noopTimer,
917 | status = 'loaded';
918 |
919 | this.started = false;
920 | this.finished = false;
921 |
922 | this.jasmineStarted = function() {
923 | this.started = true;
924 | status = 'started';
925 | timer.start();
926 | };
927 |
928 | var executionTime;
929 |
930 | this.jasmineDone = function() {
931 | this.finished = true;
932 | executionTime = timer.elapsed();
933 | status = 'done';
934 | };
935 |
936 | this.status = function() {
937 | return status;
938 | };
939 |
940 | var suites = [],
941 | suites_hash = {};
942 |
943 | this.suiteStarted = function(result) {
944 | suites_hash[result.id] = result;
945 | };
946 |
947 | this.suiteDone = function(result) {
948 | storeSuite(result);
949 | };
950 |
951 | this.suiteResults = function(index, length) {
952 | return suites.slice(index, index + length);
953 | };
954 |
955 | function storeSuite(result) {
956 | suites.push(result);
957 | suites_hash[result.id] = result;
958 | }
959 |
960 | this.suites = function() {
961 | return suites_hash;
962 | };
963 |
964 | var specs = [];
965 |
966 | this.specDone = function(result) {
967 | specs.push(result);
968 | };
969 |
970 | this.specResults = function(index, length) {
971 | return specs.slice(index, index + length);
972 | };
973 |
974 | this.specs = function() {
975 | return specs;
976 | };
977 |
978 | this.executionTime = function() {
979 | return executionTime;
980 | };
981 |
982 | }
983 |
984 | return JsApiReporter;
985 | };
986 |
987 | getJasmineRequireObj().CallTracker = function() {
988 |
989 | function CallTracker() {
990 | var calls = [];
991 |
992 | this.track = function(context) {
993 | calls.push(context);
994 | };
995 |
996 | this.any = function() {
997 | return !!calls.length;
998 | };
999 |
1000 | this.count = function() {
1001 | return calls.length;
1002 | };
1003 |
1004 | this.argsFor = function(index) {
1005 | var call = calls[index];
1006 | return call ? call.args : [];
1007 | };
1008 |
1009 | this.all = function() {
1010 | return calls;
1011 | };
1012 |
1013 | this.allArgs = function() {
1014 | var callArgs = [];
1015 | for(var i = 0; i < calls.length; i++){
1016 | callArgs.push(calls[i].args);
1017 | }
1018 |
1019 | return callArgs;
1020 | };
1021 |
1022 | this.first = function() {
1023 | return calls[0];
1024 | };
1025 |
1026 | this.mostRecent = function() {
1027 | return calls[calls.length - 1];
1028 | };
1029 |
1030 | this.reset = function() {
1031 | calls = [];
1032 | };
1033 | }
1034 |
1035 | return CallTracker;
1036 | };
1037 |
1038 | getJasmineRequireObj().Clock = function() {
1039 | function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
1040 | var self = this,
1041 | realTimingFunctions = {
1042 | setTimeout: global.setTimeout,
1043 | clearTimeout: global.clearTimeout,
1044 | setInterval: global.setInterval,
1045 | clearInterval: global.clearInterval
1046 | },
1047 | fakeTimingFunctions = {
1048 | setTimeout: setTimeout,
1049 | clearTimeout: clearTimeout,
1050 | setInterval: setInterval,
1051 | clearInterval: clearInterval
1052 | },
1053 | installed = false,
1054 | delayedFunctionScheduler,
1055 | timer;
1056 |
1057 |
1058 | self.install = function() {
1059 | if(!originalTimingFunctionsIntact()) {
1060 | throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?');
1061 | }
1062 | replace(global, fakeTimingFunctions);
1063 | timer = fakeTimingFunctions;
1064 | delayedFunctionScheduler = delayedFunctionSchedulerFactory();
1065 | installed = true;
1066 |
1067 | return self;
1068 | };
1069 |
1070 | self.uninstall = function() {
1071 | delayedFunctionScheduler = null;
1072 | mockDate.uninstall();
1073 | replace(global, realTimingFunctions);
1074 |
1075 | timer = realTimingFunctions;
1076 | installed = false;
1077 | };
1078 |
1079 | self.withMock = function(closure) {
1080 | this.install();
1081 | try {
1082 | closure();
1083 | } finally {
1084 | this.uninstall();
1085 | }
1086 | };
1087 |
1088 | self.mockDate = function(initialDate) {
1089 | mockDate.install(initialDate);
1090 | };
1091 |
1092 | self.setTimeout = function(fn, delay, params) {
1093 | if (legacyIE()) {
1094 | if (arguments.length > 2) {
1095 | throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill');
1096 | }
1097 | return timer.setTimeout(fn, delay);
1098 | }
1099 | return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]);
1100 | };
1101 |
1102 | self.setInterval = function(fn, delay, params) {
1103 | if (legacyIE()) {
1104 | if (arguments.length > 2) {
1105 | throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill');
1106 | }
1107 | return timer.setInterval(fn, delay);
1108 | }
1109 | return Function.prototype.apply.apply(timer.setInterval, [global, arguments]);
1110 | };
1111 |
1112 | self.clearTimeout = function(id) {
1113 | return Function.prototype.call.apply(timer.clearTimeout, [global, id]);
1114 | };
1115 |
1116 | self.clearInterval = function(id) {
1117 | return Function.prototype.call.apply(timer.clearInterval, [global, id]);
1118 | };
1119 |
1120 | self.tick = function(millis) {
1121 | if (installed) {
1122 | mockDate.tick(millis);
1123 | delayedFunctionScheduler.tick(millis);
1124 | } else {
1125 | throw new Error('Mock clock is not installed, use jasmine.clock().install()');
1126 | }
1127 | };
1128 |
1129 | return self;
1130 |
1131 | function originalTimingFunctionsIntact() {
1132 | return global.setTimeout === realTimingFunctions.setTimeout &&
1133 | global.clearTimeout === realTimingFunctions.clearTimeout &&
1134 | global.setInterval === realTimingFunctions.setInterval &&
1135 | global.clearInterval === realTimingFunctions.clearInterval;
1136 | }
1137 |
1138 | function legacyIE() {
1139 | //if these methods are polyfilled, apply will be present
1140 | return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
1141 | }
1142 |
1143 | function replace(dest, source) {
1144 | for (var prop in source) {
1145 | dest[prop] = source[prop];
1146 | }
1147 | }
1148 |
1149 | function setTimeout(fn, delay) {
1150 | return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
1151 | }
1152 |
1153 | function clearTimeout(id) {
1154 | return delayedFunctionScheduler.removeFunctionWithId(id);
1155 | }
1156 |
1157 | function setInterval(fn, interval) {
1158 | return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
1159 | }
1160 |
1161 | function clearInterval(id) {
1162 | return delayedFunctionScheduler.removeFunctionWithId(id);
1163 | }
1164 |
1165 | function argSlice(argsObj, n) {
1166 | return Array.prototype.slice.call(argsObj, n);
1167 | }
1168 | }
1169 |
1170 | return Clock;
1171 | };
1172 |
1173 | getJasmineRequireObj().DelayedFunctionScheduler = function() {
1174 | function DelayedFunctionScheduler() {
1175 | var self = this;
1176 | var scheduledLookup = [];
1177 | var scheduledFunctions = {};
1178 | var currentTime = 0;
1179 | var delayedFnCount = 0;
1180 |
1181 | self.tick = function(millis) {
1182 | millis = millis || 0;
1183 | var endTime = currentTime + millis;
1184 |
1185 | runScheduledFunctions(endTime);
1186 | currentTime = endTime;
1187 | };
1188 |
1189 | self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
1190 | var f;
1191 | if (typeof(funcToCall) === 'string') {
1192 | /* jshint evil: true */
1193 | f = function() { return eval(funcToCall); };
1194 | /* jshint evil: false */
1195 | } else {
1196 | f = funcToCall;
1197 | }
1198 |
1199 | millis = millis || 0;
1200 | timeoutKey = timeoutKey || ++delayedFnCount;
1201 | runAtMillis = runAtMillis || (currentTime + millis);
1202 |
1203 | var funcToSchedule = {
1204 | runAtMillis: runAtMillis,
1205 | funcToCall: f,
1206 | recurring: recurring,
1207 | params: params,
1208 | timeoutKey: timeoutKey,
1209 | millis: millis
1210 | };
1211 |
1212 | if (runAtMillis in scheduledFunctions) {
1213 | scheduledFunctions[runAtMillis].push(funcToSchedule);
1214 | } else {
1215 | scheduledFunctions[runAtMillis] = [funcToSchedule];
1216 | scheduledLookup.push(runAtMillis);
1217 | scheduledLookup.sort(function (a, b) {
1218 | return a - b;
1219 | });
1220 | }
1221 |
1222 | return timeoutKey;
1223 | };
1224 |
1225 | self.removeFunctionWithId = function(timeoutKey) {
1226 | for (var runAtMillis in scheduledFunctions) {
1227 | var funcs = scheduledFunctions[runAtMillis];
1228 | var i = indexOfFirstToPass(funcs, function (func) {
1229 | return func.timeoutKey === timeoutKey;
1230 | });
1231 |
1232 | if (i > -1) {
1233 | if (funcs.length === 1) {
1234 | delete scheduledFunctions[runAtMillis];
1235 | deleteFromLookup(runAtMillis);
1236 | } else {
1237 | funcs.splice(i, 1);
1238 | }
1239 |
1240 | // intervals get rescheduled when executed, so there's never more
1241 | // than a single scheduled function with a given timeoutKey
1242 | break;
1243 | }
1244 | }
1245 | };
1246 |
1247 | return self;
1248 |
1249 | function indexOfFirstToPass(array, testFn) {
1250 | var index = -1;
1251 |
1252 | for (var i = 0; i < array.length; ++i) {
1253 | if (testFn(array[i])) {
1254 | index = i;
1255 | break;
1256 | }
1257 | }
1258 |
1259 | return index;
1260 | }
1261 |
1262 | function deleteFromLookup(key) {
1263 | var value = Number(key);
1264 | var i = indexOfFirstToPass(scheduledLookup, function (millis) {
1265 | return millis === value;
1266 | });
1267 |
1268 | if (i > -1) {
1269 | scheduledLookup.splice(i, 1);
1270 | }
1271 | }
1272 |
1273 | function reschedule(scheduledFn) {
1274 | self.scheduleFunction(scheduledFn.funcToCall,
1275 | scheduledFn.millis,
1276 | scheduledFn.params,
1277 | true,
1278 | scheduledFn.timeoutKey,
1279 | scheduledFn.runAtMillis + scheduledFn.millis);
1280 | }
1281 |
1282 | function forEachFunction(funcsToRun, callback) {
1283 | for (var i = 0; i < funcsToRun.length; ++i) {
1284 | callback(funcsToRun[i]);
1285 | }
1286 | }
1287 |
1288 | function runScheduledFunctions(endTime) {
1289 | if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
1290 | return;
1291 | }
1292 |
1293 | do {
1294 | currentTime = scheduledLookup.shift();
1295 |
1296 | var funcsToRun = scheduledFunctions[currentTime];
1297 | delete scheduledFunctions[currentTime];
1298 |
1299 | forEachFunction(funcsToRun, function(funcToRun) {
1300 | if (funcToRun.recurring) {
1301 | reschedule(funcToRun);
1302 | }
1303 | });
1304 |
1305 | forEachFunction(funcsToRun, function(funcToRun) {
1306 | funcToRun.funcToCall.apply(null, funcToRun.params || []);
1307 | });
1308 | } while (scheduledLookup.length > 0 &&
1309 | // checking first if we're out of time prevents setTimeout(0)
1310 | // scheduled in a funcToRun from forcing an extra iteration
1311 | currentTime !== endTime &&
1312 | scheduledLookup[0] <= endTime);
1313 | }
1314 | }
1315 |
1316 | return DelayedFunctionScheduler;
1317 | };
1318 |
1319 | getJasmineRequireObj().ExceptionFormatter = function() {
1320 | function ExceptionFormatter() {
1321 | this.message = function(error) {
1322 | var message = '';
1323 |
1324 | if (error.name && error.message) {
1325 | message += error.name + ': ' + error.message;
1326 | } else {
1327 | message += error.toString() + ' thrown';
1328 | }
1329 |
1330 | if (error.fileName || error.sourceURL) {
1331 | message += ' in ' + (error.fileName || error.sourceURL);
1332 | }
1333 |
1334 | if (error.line || error.lineNumber) {
1335 | message += ' (line ' + (error.line || error.lineNumber) + ')';
1336 | }
1337 |
1338 | return message;
1339 | };
1340 |
1341 | this.stack = function(error) {
1342 | return error ? error.stack : null;
1343 | };
1344 | }
1345 |
1346 | return ExceptionFormatter;
1347 | };
1348 |
1349 | getJasmineRequireObj().Expectation = function() {
1350 |
1351 | function Expectation(options) {
1352 | this.util = options.util || { buildFailureMessage: function() {} };
1353 | this.customEqualityTesters = options.customEqualityTesters || [];
1354 | this.actual = options.actual;
1355 | this.addExpectationResult = options.addExpectationResult || function(){};
1356 | this.isNot = options.isNot;
1357 |
1358 | var customMatchers = options.customMatchers || {};
1359 | for (var matcherName in customMatchers) {
1360 | this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]);
1361 | }
1362 | }
1363 |
1364 | Expectation.prototype.wrapCompare = function(name, matcherFactory) {
1365 | return function() {
1366 | var args = Array.prototype.slice.call(arguments, 0),
1367 | expected = args.slice(0),
1368 | message = '';
1369 |
1370 | args.unshift(this.actual);
1371 |
1372 | var matcher = matcherFactory(this.util, this.customEqualityTesters),
1373 | matcherCompare = matcher.compare;
1374 |
1375 | function defaultNegativeCompare() {
1376 | var result = matcher.compare.apply(null, args);
1377 | result.pass = !result.pass;
1378 | return result;
1379 | }
1380 |
1381 | if (this.isNot) {
1382 | matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
1383 | }
1384 |
1385 | var result = matcherCompare.apply(null, args);
1386 |
1387 | if (!result.pass) {
1388 | if (!result.message) {
1389 | args.unshift(this.isNot);
1390 | args.unshift(name);
1391 | message = this.util.buildFailureMessage.apply(null, args);
1392 | } else {
1393 | if (Object.prototype.toString.apply(result.message) === '[object Function]') {
1394 | message = result.message();
1395 | } else {
1396 | message = result.message;
1397 | }
1398 | }
1399 | }
1400 |
1401 | if (expected.length == 1) {
1402 | expected = expected[0];
1403 | }
1404 |
1405 | // TODO: how many of these params are needed?
1406 | this.addExpectationResult(
1407 | result.pass,
1408 | {
1409 | matcherName: name,
1410 | passed: result.pass,
1411 | message: message,
1412 | actual: this.actual,
1413 | expected: expected // TODO: this may need to be arrayified/sliced
1414 | }
1415 | );
1416 | };
1417 | };
1418 |
1419 | Expectation.addCoreMatchers = function(matchers) {
1420 | var prototype = Expectation.prototype;
1421 | for (var matcherName in matchers) {
1422 | var matcher = matchers[matcherName];
1423 | prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
1424 | }
1425 | };
1426 |
1427 | Expectation.Factory = function(options) {
1428 | options = options || {};
1429 |
1430 | var expect = new Expectation(options);
1431 |
1432 | // TODO: this would be nice as its own Object - NegativeExpectation
1433 | // TODO: copy instead of mutate options
1434 | options.isNot = true;
1435 | expect.not = new Expectation(options);
1436 |
1437 | return expect;
1438 | };
1439 |
1440 | return Expectation;
1441 | };
1442 |
1443 | //TODO: expectation result may make more sense as a presentation of an expectation.
1444 | getJasmineRequireObj().buildExpectationResult = function() {
1445 | function buildExpectationResult(options) {
1446 | var messageFormatter = options.messageFormatter || function() {},
1447 | stackFormatter = options.stackFormatter || function() {};
1448 |
1449 | var result = {
1450 | matcherName: options.matcherName,
1451 | message: message(),
1452 | stack: stack(),
1453 | passed: options.passed
1454 | };
1455 |
1456 | if(!result.passed) {
1457 | result.expected = options.expected;
1458 | result.actual = options.actual;
1459 | }
1460 |
1461 | return result;
1462 |
1463 | function message() {
1464 | if (options.passed) {
1465 | return 'Passed.';
1466 | } else if (options.message) {
1467 | return options.message;
1468 | } else if (options.error) {
1469 | return messageFormatter(options.error);
1470 | }
1471 | return '';
1472 | }
1473 |
1474 | function stack() {
1475 | if (options.passed) {
1476 | return '';
1477 | }
1478 |
1479 | var error = options.error;
1480 | if (!error) {
1481 | try {
1482 | throw new Error(message());
1483 | } catch (e) {
1484 | error = e;
1485 | }
1486 | }
1487 | return stackFormatter(error);
1488 | }
1489 | }
1490 |
1491 | return buildExpectationResult;
1492 | };
1493 |
1494 | getJasmineRequireObj().MockDate = function() {
1495 | function MockDate(global) {
1496 | var self = this;
1497 | var currentTime = 0;
1498 |
1499 | if (!global || !global.Date) {
1500 | self.install = function() {};
1501 | self.tick = function() {};
1502 | self.uninstall = function() {};
1503 | return self;
1504 | }
1505 |
1506 | var GlobalDate = global.Date;
1507 |
1508 | self.install = function(mockDate) {
1509 | if (mockDate instanceof GlobalDate) {
1510 | currentTime = mockDate.getTime();
1511 | } else {
1512 | currentTime = new GlobalDate().getTime();
1513 | }
1514 |
1515 | global.Date = FakeDate;
1516 | };
1517 |
1518 | self.tick = function(millis) {
1519 | millis = millis || 0;
1520 | currentTime = currentTime + millis;
1521 | };
1522 |
1523 | self.uninstall = function() {
1524 | currentTime = 0;
1525 | global.Date = GlobalDate;
1526 | };
1527 |
1528 | createDateProperties();
1529 |
1530 | return self;
1531 |
1532 | function FakeDate() {
1533 | switch(arguments.length) {
1534 | case 0:
1535 | return new GlobalDate(currentTime);
1536 | case 1:
1537 | return new GlobalDate(arguments[0]);
1538 | case 2:
1539 | return new GlobalDate(arguments[0], arguments[1]);
1540 | case 3:
1541 | return new GlobalDate(arguments[0], arguments[1], arguments[2]);
1542 | case 4:
1543 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]);
1544 | case 5:
1545 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1546 | arguments[4]);
1547 | case 6:
1548 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1549 | arguments[4], arguments[5]);
1550 | default:
1551 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1552 | arguments[4], arguments[5], arguments[6]);
1553 | }
1554 | }
1555 |
1556 | function createDateProperties() {
1557 | FakeDate.prototype = GlobalDate.prototype;
1558 |
1559 | FakeDate.now = function() {
1560 | if (GlobalDate.now) {
1561 | return currentTime;
1562 | } else {
1563 | throw new Error('Browser does not support Date.now()');
1564 | }
1565 | };
1566 |
1567 | FakeDate.toSource = GlobalDate.toSource;
1568 | FakeDate.toString = GlobalDate.toString;
1569 | FakeDate.parse = GlobalDate.parse;
1570 | FakeDate.UTC = GlobalDate.UTC;
1571 | }
1572 | }
1573 |
1574 | return MockDate;
1575 | };
1576 |
1577 | getJasmineRequireObj().pp = function(j$) {
1578 |
1579 | function PrettyPrinter() {
1580 | this.ppNestLevel_ = 0;
1581 | this.seen = [];
1582 | }
1583 |
1584 | PrettyPrinter.prototype.format = function(value) {
1585 | this.ppNestLevel_++;
1586 | try {
1587 | if (j$.util.isUndefined(value)) {
1588 | this.emitScalar('undefined');
1589 | } else if (value === null) {
1590 | this.emitScalar('null');
1591 | } else if (value === 0 && 1/value === -Infinity) {
1592 | this.emitScalar('-0');
1593 | } else if (value === j$.getGlobal()) {
1594 | this.emitScalar('');
1595 | } else if (value.jasmineToString) {
1596 | this.emitScalar(value.jasmineToString());
1597 | } else if (typeof value === 'string') {
1598 | this.emitString(value);
1599 | } else if (j$.isSpy(value)) {
1600 | this.emitScalar('spy on ' + value.and.identity());
1601 | } else if (value instanceof RegExp) {
1602 | this.emitScalar(value.toString());
1603 | } else if (typeof value === 'function') {
1604 | this.emitScalar('Function');
1605 | } else if (typeof value.nodeType === 'number') {
1606 | this.emitScalar('HTMLNode');
1607 | } else if (value instanceof Date) {
1608 | this.emitScalar('Date(' + value + ')');
1609 | } else if (j$.util.arrayContains(this.seen, value)) {
1610 | this.emitScalar('');
1611 | } else if (j$.isArray_(value) || j$.isA_('Object', value)) {
1612 | this.seen.push(value);
1613 | if (j$.isArray_(value)) {
1614 | this.emitArray(value);
1615 | } else {
1616 | this.emitObject(value);
1617 | }
1618 | this.seen.pop();
1619 | } else {
1620 | this.emitScalar(value.toString());
1621 | }
1622 | } finally {
1623 | this.ppNestLevel_--;
1624 | }
1625 | };
1626 |
1627 | PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1628 | for (var property in obj) {
1629 | if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
1630 | fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1631 | obj.__lookupGetter__(property) !== null) : false);
1632 | }
1633 | };
1634 |
1635 | PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
1636 | PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
1637 | PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
1638 | PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
1639 |
1640 | function StringPrettyPrinter() {
1641 | PrettyPrinter.call(this);
1642 |
1643 | this.string = '';
1644 | }
1645 |
1646 | j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
1647 |
1648 | StringPrettyPrinter.prototype.emitScalar = function(value) {
1649 | this.append(value);
1650 | };
1651 |
1652 | StringPrettyPrinter.prototype.emitString = function(value) {
1653 | this.append('\'' + value + '\'');
1654 | };
1655 |
1656 | StringPrettyPrinter.prototype.emitArray = function(array) {
1657 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1658 | this.append('Array');
1659 | return;
1660 | }
1661 | var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
1662 | this.append('[ ');
1663 | for (var i = 0; i < length; i++) {
1664 | if (i > 0) {
1665 | this.append(', ');
1666 | }
1667 | this.format(array[i]);
1668 | }
1669 | if(array.length > length){
1670 | this.append(', ...');
1671 | }
1672 |
1673 | var self = this;
1674 | var first = array.length === 0;
1675 | this.iterateObject(array, function(property, isGetter) {
1676 | if (property.match(/^\d+$/)) {
1677 | return;
1678 | }
1679 |
1680 | if (first) {
1681 | first = false;
1682 | } else {
1683 | self.append(', ');
1684 | }
1685 |
1686 | self.formatProperty(array, property, isGetter);
1687 | });
1688 |
1689 | this.append(' ]');
1690 | };
1691 |
1692 | StringPrettyPrinter.prototype.emitObject = function(obj) {
1693 | var constructorName = obj.constructor ? j$.fnNameFor(obj.constructor) : 'null';
1694 | this.append(constructorName);
1695 |
1696 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1697 | return;
1698 | }
1699 |
1700 | var self = this;
1701 | this.append('({ ');
1702 | var first = true;
1703 |
1704 | this.iterateObject(obj, function(property, isGetter) {
1705 | if (first) {
1706 | first = false;
1707 | } else {
1708 | self.append(', ');
1709 | }
1710 |
1711 | self.formatProperty(obj, property, isGetter);
1712 | });
1713 |
1714 | this.append(' })');
1715 | };
1716 |
1717 | StringPrettyPrinter.prototype.formatProperty = function(obj, property, isGetter) {
1718 | this.append(property);
1719 | this.append(': ');
1720 | if (isGetter) {
1721 | this.append('');
1722 | } else {
1723 | this.format(obj[property]);
1724 | }
1725 | };
1726 |
1727 | StringPrettyPrinter.prototype.append = function(value) {
1728 | this.string += value;
1729 | };
1730 |
1731 | return function(value) {
1732 | var stringPrettyPrinter = new StringPrettyPrinter();
1733 | stringPrettyPrinter.format(value);
1734 | return stringPrettyPrinter.string;
1735 | };
1736 | };
1737 |
1738 | getJasmineRequireObj().QueueRunner = function(j$) {
1739 |
1740 | function once(fn) {
1741 | var called = false;
1742 | return function() {
1743 | if (!called) {
1744 | called = true;
1745 | fn();
1746 | }
1747 | };
1748 | }
1749 |
1750 | function QueueRunner(attrs) {
1751 | this.queueableFns = attrs.queueableFns || [];
1752 | this.onComplete = attrs.onComplete || function() {};
1753 | this.clearStack = attrs.clearStack || function(fn) {fn();};
1754 | this.onException = attrs.onException || function() {};
1755 | this.catchException = attrs.catchException || function() { return true; };
1756 | this.userContext = attrs.userContext || {};
1757 | this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
1758 | this.fail = attrs.fail || function() {};
1759 | }
1760 |
1761 | QueueRunner.prototype.execute = function() {
1762 | this.run(this.queueableFns, 0);
1763 | };
1764 |
1765 | QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
1766 | var length = queueableFns.length,
1767 | self = this,
1768 | iterativeIndex;
1769 |
1770 |
1771 | for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
1772 | var queueableFn = queueableFns[iterativeIndex];
1773 | if (queueableFn.fn.length > 0) {
1774 | attemptAsync(queueableFn);
1775 | return;
1776 | } else {
1777 | attemptSync(queueableFn);
1778 | }
1779 | }
1780 |
1781 | var runnerDone = iterativeIndex >= length;
1782 |
1783 | if (runnerDone) {
1784 | this.clearStack(this.onComplete);
1785 | }
1786 |
1787 | function attemptSync(queueableFn) {
1788 | try {
1789 | queueableFn.fn.call(self.userContext);
1790 | } catch (e) {
1791 | handleException(e, queueableFn);
1792 | }
1793 | }
1794 |
1795 | function attemptAsync(queueableFn) {
1796 | var clearTimeout = function () {
1797 | Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
1798 | },
1799 | next = once(function () {
1800 | clearTimeout(timeoutId);
1801 | self.run(queueableFns, iterativeIndex + 1);
1802 | }),
1803 | timeoutId;
1804 |
1805 | next.fail = function() {
1806 | self.fail.apply(null, arguments);
1807 | next();
1808 | };
1809 |
1810 | if (queueableFn.timeout) {
1811 | timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() {
1812 | var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
1813 | onException(error, queueableFn);
1814 | next();
1815 | }, queueableFn.timeout()]]);
1816 | }
1817 |
1818 | try {
1819 | queueableFn.fn.call(self.userContext, next);
1820 | } catch (e) {
1821 | handleException(e, queueableFn);
1822 | next();
1823 | }
1824 | }
1825 |
1826 | function onException(e, queueableFn) {
1827 | self.onException(e);
1828 | }
1829 |
1830 | function handleException(e, queueableFn) {
1831 | onException(e, queueableFn);
1832 | if (!self.catchException(e)) {
1833 | //TODO: set a var when we catch an exception and
1834 | //use a finally block to close the loop in a nice way..
1835 | throw e;
1836 | }
1837 | }
1838 | };
1839 |
1840 | return QueueRunner;
1841 | };
1842 |
1843 | getJasmineRequireObj().ReportDispatcher = function() {
1844 | function ReportDispatcher(methods) {
1845 |
1846 | var dispatchedMethods = methods || [];
1847 |
1848 | for (var i = 0; i < dispatchedMethods.length; i++) {
1849 | var method = dispatchedMethods[i];
1850 | this[method] = (function(m) {
1851 | return function() {
1852 | dispatch(m, arguments);
1853 | };
1854 | }(method));
1855 | }
1856 |
1857 | var reporters = [];
1858 |
1859 | this.addReporter = function(reporter) {
1860 | reporters.push(reporter);
1861 | };
1862 |
1863 | return this;
1864 |
1865 | function dispatch(method, args) {
1866 | for (var i = 0; i < reporters.length; i++) {
1867 | var reporter = reporters[i];
1868 | if (reporter[method]) {
1869 | reporter[method].apply(reporter, args);
1870 | }
1871 | }
1872 | }
1873 | }
1874 |
1875 | return ReportDispatcher;
1876 | };
1877 |
1878 |
1879 | getJasmineRequireObj().SpyRegistry = function(j$) {
1880 |
1881 | function SpyRegistry(options) {
1882 | options = options || {};
1883 | var currentSpies = options.currentSpies || function() { return []; };
1884 |
1885 | this.spyOn = function(obj, methodName) {
1886 | if (j$.util.isUndefined(obj)) {
1887 | throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
1888 | }
1889 |
1890 | if (j$.util.isUndefined(methodName)) {
1891 | throw new Error('No method name supplied');
1892 | }
1893 |
1894 | if (j$.util.isUndefined(obj[methodName])) {
1895 | throw new Error(methodName + '() method does not exist');
1896 | }
1897 |
1898 | if (obj[methodName] && j$.isSpy(obj[methodName])) {
1899 | //TODO?: should this return the current spy? Downside: may cause user confusion about spy state
1900 | throw new Error(methodName + ' has already been spied upon');
1901 | }
1902 |
1903 | var spy = j$.createSpy(methodName, obj[methodName]);
1904 |
1905 | currentSpies().push({
1906 | spy: spy,
1907 | baseObj: obj,
1908 | methodName: methodName,
1909 | originalValue: obj[methodName]
1910 | });
1911 |
1912 | obj[methodName] = spy;
1913 |
1914 | return spy;
1915 | };
1916 |
1917 | this.clearSpies = function() {
1918 | var spies = currentSpies();
1919 | for (var i = 0; i < spies.length; i++) {
1920 | var spyEntry = spies[i];
1921 | spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue;
1922 | }
1923 | };
1924 | }
1925 |
1926 | return SpyRegistry;
1927 | };
1928 |
1929 | getJasmineRequireObj().SpyStrategy = function() {
1930 |
1931 | function SpyStrategy(options) {
1932 | options = options || {};
1933 |
1934 | var identity = options.name || 'unknown',
1935 | originalFn = options.fn || function() {},
1936 | getSpy = options.getSpy || function() {},
1937 | plan = function() {};
1938 |
1939 | this.identity = function() {
1940 | return identity;
1941 | };
1942 |
1943 | this.exec = function() {
1944 | return plan.apply(this, arguments);
1945 | };
1946 |
1947 | this.callThrough = function() {
1948 | plan = originalFn;
1949 | return getSpy();
1950 | };
1951 |
1952 | this.returnValue = function(value) {
1953 | plan = function() {
1954 | return value;
1955 | };
1956 | return getSpy();
1957 | };
1958 |
1959 | this.returnValues = function() {
1960 | var values = Array.prototype.slice.call(arguments);
1961 | plan = function () {
1962 | return values.shift();
1963 | };
1964 | return getSpy();
1965 | };
1966 |
1967 | this.throwError = function(something) {
1968 | var error = (something instanceof Error) ? something : new Error(something);
1969 | plan = function() {
1970 | throw error;
1971 | };
1972 | return getSpy();
1973 | };
1974 |
1975 | this.callFake = function(fn) {
1976 | plan = fn;
1977 | return getSpy();
1978 | };
1979 |
1980 | this.stub = function(fn) {
1981 | plan = function() {};
1982 | return getSpy();
1983 | };
1984 | }
1985 |
1986 | return SpyStrategy;
1987 | };
1988 |
1989 | getJasmineRequireObj().Suite = function(j$) {
1990 | function Suite(attrs) {
1991 | this.env = attrs.env;
1992 | this.id = attrs.id;
1993 | this.parentSuite = attrs.parentSuite;
1994 | this.description = attrs.description;
1995 | this.expectationFactory = attrs.expectationFactory;
1996 | this.expectationResultFactory = attrs.expectationResultFactory;
1997 | this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
1998 |
1999 | this.beforeFns = [];
2000 | this.afterFns = [];
2001 | this.beforeAllFns = [];
2002 | this.afterAllFns = [];
2003 | this.disabled = false;
2004 |
2005 | this.children = [];
2006 |
2007 | this.result = {
2008 | id: this.id,
2009 | description: this.description,
2010 | fullName: this.getFullName(),
2011 | failedExpectations: []
2012 | };
2013 | }
2014 |
2015 | Suite.prototype.expect = function(actual) {
2016 | return this.expectationFactory(actual, this);
2017 | };
2018 |
2019 | Suite.prototype.getFullName = function() {
2020 | var fullName = this.description;
2021 | for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
2022 | if (parentSuite.parentSuite) {
2023 | fullName = parentSuite.description + ' ' + fullName;
2024 | }
2025 | }
2026 | return fullName;
2027 | };
2028 |
2029 | Suite.prototype.disable = function() {
2030 | this.disabled = true;
2031 | };
2032 |
2033 | Suite.prototype.beforeEach = function(fn) {
2034 | this.beforeFns.unshift(fn);
2035 | };
2036 |
2037 | Suite.prototype.beforeAll = function(fn) {
2038 | this.beforeAllFns.push(fn);
2039 | };
2040 |
2041 | Suite.prototype.afterEach = function(fn) {
2042 | this.afterFns.unshift(fn);
2043 | };
2044 |
2045 | Suite.prototype.afterAll = function(fn) {
2046 | this.afterAllFns.push(fn);
2047 | };
2048 |
2049 | Suite.prototype.addChild = function(child) {
2050 | this.children.push(child);
2051 | };
2052 |
2053 | Suite.prototype.status = function() {
2054 | if (this.disabled) {
2055 | return 'disabled';
2056 | }
2057 |
2058 | if (this.result.failedExpectations.length > 0) {
2059 | return 'failed';
2060 | } else {
2061 | return 'finished';
2062 | }
2063 | };
2064 |
2065 | Suite.prototype.isExecutable = function() {
2066 | return !this.disabled;
2067 | };
2068 |
2069 | Suite.prototype.canBeReentered = function() {
2070 | return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
2071 | };
2072 |
2073 | Suite.prototype.getResult = function() {
2074 | this.result.status = this.status();
2075 | return this.result;
2076 | };
2077 |
2078 | Suite.prototype.sharedUserContext = function() {
2079 | if (!this.sharedContext) {
2080 | this.sharedContext = this.parentSuite ? clone(this.parentSuite.sharedUserContext()) : {};
2081 | }
2082 |
2083 | return this.sharedContext;
2084 | };
2085 |
2086 | Suite.prototype.clonedSharedUserContext = function() {
2087 | return clone(this.sharedUserContext());
2088 | };
2089 |
2090 | Suite.prototype.onException = function() {
2091 | if (arguments[0] instanceof j$.errors.ExpectationFailed) {
2092 | return;
2093 | }
2094 |
2095 | if(isAfterAll(this.children)) {
2096 | var data = {
2097 | matcherName: '',
2098 | passed: false,
2099 | expected: '',
2100 | actual: '',
2101 | error: arguments[0]
2102 | };
2103 | this.result.failedExpectations.push(this.expectationResultFactory(data));
2104 | } else {
2105 | for (var i = 0; i < this.children.length; i++) {
2106 | var child = this.children[i];
2107 | child.onException.apply(child, arguments);
2108 | }
2109 | }
2110 | };
2111 |
2112 | Suite.prototype.addExpectationResult = function () {
2113 | if(isAfterAll(this.children) && isFailure(arguments)){
2114 | var data = arguments[1];
2115 | this.result.failedExpectations.push(this.expectationResultFactory(data));
2116 | if(this.throwOnExpectationFailure) {
2117 | throw new j$.errors.ExpectationFailed();
2118 | }
2119 | } else {
2120 | for (var i = 0; i < this.children.length; i++) {
2121 | var child = this.children[i];
2122 | try {
2123 | child.addExpectationResult.apply(child, arguments);
2124 | } catch(e) {
2125 | // keep going
2126 | }
2127 | }
2128 | }
2129 | };
2130 |
2131 | function isAfterAll(children) {
2132 | return children && children[0].result.status;
2133 | }
2134 |
2135 | function isFailure(args) {
2136 | return !args[0];
2137 | }
2138 |
2139 | function clone(obj) {
2140 | var clonedObj = {};
2141 | for (var prop in obj) {
2142 | if (obj.hasOwnProperty(prop)) {
2143 | clonedObj[prop] = obj[prop];
2144 | }
2145 | }
2146 |
2147 | return clonedObj;
2148 | }
2149 |
2150 | return Suite;
2151 | };
2152 |
2153 | if (typeof window == void 0 && typeof exports == 'object') {
2154 | exports.Suite = jasmineRequire.Suite;
2155 | }
2156 |
2157 | getJasmineRequireObj().Timer = function() {
2158 | var defaultNow = (function(Date) {
2159 | return function() { return new Date().getTime(); };
2160 | })(Date);
2161 |
2162 | function Timer(options) {
2163 | options = options || {};
2164 |
2165 | var now = options.now || defaultNow,
2166 | startTime;
2167 |
2168 | this.start = function() {
2169 | startTime = now();
2170 | };
2171 |
2172 | this.elapsed = function() {
2173 | return now() - startTime;
2174 | };
2175 | }
2176 |
2177 | return Timer;
2178 | };
2179 |
2180 | getJasmineRequireObj().TreeProcessor = function() {
2181 | function TreeProcessor(attrs) {
2182 | var tree = attrs.tree,
2183 | runnableIds = attrs.runnableIds,
2184 | queueRunnerFactory = attrs.queueRunnerFactory,
2185 | nodeStart = attrs.nodeStart || function() {},
2186 | nodeComplete = attrs.nodeComplete || function() {},
2187 | stats = { valid: true },
2188 | processed = false,
2189 | defaultMin = Infinity,
2190 | defaultMax = 1 - Infinity;
2191 |
2192 | this.processTree = function() {
2193 | processNode(tree, false);
2194 | processed = true;
2195 | return stats;
2196 | };
2197 |
2198 | this.execute = function(done) {
2199 | if (!processed) {
2200 | this.processTree();
2201 | }
2202 |
2203 | if (!stats.valid) {
2204 | throw 'invalid order';
2205 | }
2206 |
2207 | var childFns = wrapChildren(tree, 0);
2208 |
2209 | queueRunnerFactory({
2210 | queueableFns: childFns,
2211 | userContext: tree.sharedUserContext(),
2212 | onException: function() {
2213 | tree.onException.apply(tree, arguments);
2214 | },
2215 | onComplete: done
2216 | });
2217 | };
2218 |
2219 | function runnableIndex(id) {
2220 | for (var i = 0; i < runnableIds.length; i++) {
2221 | if (runnableIds[i] === id) {
2222 | return i;
2223 | }
2224 | }
2225 | }
2226 |
2227 | function processNode(node, parentEnabled) {
2228 | var executableIndex = runnableIndex(node.id);
2229 |
2230 | if (executableIndex !== undefined) {
2231 | parentEnabled = true;
2232 | }
2233 |
2234 | parentEnabled = parentEnabled && node.isExecutable();
2235 |
2236 | if (!node.children) {
2237 | stats[node.id] = {
2238 | executable: parentEnabled && node.isExecutable(),
2239 | segments: [{
2240 | index: 0,
2241 | owner: node,
2242 | nodes: [node],
2243 | min: startingMin(executableIndex),
2244 | max: startingMax(executableIndex)
2245 | }]
2246 | };
2247 | } else {
2248 | var hasExecutableChild = false;
2249 |
2250 | for (var i = 0; i < node.children.length; i++) {
2251 | var child = node.children[i];
2252 |
2253 | processNode(child, parentEnabled);
2254 |
2255 | if (!stats.valid) {
2256 | return;
2257 | }
2258 |
2259 | var childStats = stats[child.id];
2260 |
2261 | hasExecutableChild = hasExecutableChild || childStats.executable;
2262 | }
2263 |
2264 | stats[node.id] = {
2265 | executable: hasExecutableChild
2266 | };
2267 |
2268 | segmentChildren(node, stats[node.id], executableIndex);
2269 |
2270 | if (!node.canBeReentered() && stats[node.id].segments.length > 1) {
2271 | stats = { valid: false };
2272 | }
2273 | }
2274 | }
2275 |
2276 | function startingMin(executableIndex) {
2277 | return executableIndex === undefined ? defaultMin : executableIndex;
2278 | }
2279 |
2280 | function startingMax(executableIndex) {
2281 | return executableIndex === undefined ? defaultMax : executableIndex;
2282 | }
2283 |
2284 | function segmentChildren(node, nodeStats, executableIndex) {
2285 | var currentSegment = { index: 0, owner: node, nodes: [], min: startingMin(executableIndex), max: startingMax(executableIndex) },
2286 | result = [currentSegment],
2287 | lastMax = defaultMax,
2288 | orderedChildSegments = orderChildSegments(node.children);
2289 |
2290 | function isSegmentBoundary(minIndex) {
2291 | return lastMax !== defaultMax && minIndex !== defaultMin && lastMax < minIndex - 1;
2292 | }
2293 |
2294 | for (var i = 0; i < orderedChildSegments.length; i++) {
2295 | var childSegment = orderedChildSegments[i],
2296 | maxIndex = childSegment.max,
2297 | minIndex = childSegment.min;
2298 |
2299 | if (isSegmentBoundary(minIndex)) {
2300 | currentSegment = {index: result.length, owner: node, nodes: [], min: defaultMin, max: defaultMax};
2301 | result.push(currentSegment);
2302 | }
2303 |
2304 | currentSegment.nodes.push(childSegment);
2305 | currentSegment.min = Math.min(currentSegment.min, minIndex);
2306 | currentSegment.max = Math.max(currentSegment.max, maxIndex);
2307 | lastMax = maxIndex;
2308 | }
2309 |
2310 | nodeStats.segments = result;
2311 | }
2312 |
2313 | function orderChildSegments(children) {
2314 | var specifiedOrder = [],
2315 | unspecifiedOrder = [];
2316 |
2317 | for (var i = 0; i < children.length; i++) {
2318 | var child = children[i],
2319 | segments = stats[child.id].segments;
2320 |
2321 | for (var j = 0; j < segments.length; j++) {
2322 | var seg = segments[j];
2323 |
2324 | if (seg.min === defaultMin) {
2325 | unspecifiedOrder.push(seg);
2326 | } else {
2327 | specifiedOrder.push(seg);
2328 | }
2329 | }
2330 | }
2331 |
2332 | specifiedOrder.sort(function(a, b) {
2333 | return a.min - b.min;
2334 | });
2335 |
2336 | return specifiedOrder.concat(unspecifiedOrder);
2337 | }
2338 |
2339 | function executeNode(node, segmentNumber) {
2340 | if (node.children) {
2341 | return {
2342 | fn: function(done) {
2343 | nodeStart(node);
2344 |
2345 | queueRunnerFactory({
2346 | onComplete: function() {
2347 | nodeComplete(node, node.getResult());
2348 | done();
2349 | },
2350 | queueableFns: wrapChildren(node, segmentNumber),
2351 | userContext: node.sharedUserContext(),
2352 | onException: function() {
2353 | node.onException.apply(node, arguments);
2354 | }
2355 | });
2356 | }
2357 | };
2358 | } else {
2359 | return {
2360 | fn: function(done) { node.execute(done, stats[node.id].executable); }
2361 | };
2362 | }
2363 | }
2364 |
2365 | function wrapChildren(node, segmentNumber) {
2366 | var result = [],
2367 | segmentChildren = stats[node.id].segments[segmentNumber].nodes;
2368 |
2369 | for (var i = 0; i < segmentChildren.length; i++) {
2370 | result.push(executeNode(segmentChildren[i].owner, segmentChildren[i].index));
2371 | }
2372 |
2373 | if (!stats[node.id].executable) {
2374 | return result;
2375 | }
2376 |
2377 | return node.beforeAllFns.concat(result).concat(node.afterAllFns);
2378 | }
2379 | }
2380 |
2381 | return TreeProcessor;
2382 | };
2383 |
2384 | getJasmineRequireObj().Any = function(j$) {
2385 |
2386 | function Any(expectedObject) {
2387 | this.expectedObject = expectedObject;
2388 | }
2389 |
2390 | Any.prototype.asymmetricMatch = function(other) {
2391 | if (this.expectedObject == String) {
2392 | return typeof other == 'string' || other instanceof String;
2393 | }
2394 |
2395 | if (this.expectedObject == Number) {
2396 | return typeof other == 'number' || other instanceof Number;
2397 | }
2398 |
2399 | if (this.expectedObject == Function) {
2400 | return typeof other == 'function' || other instanceof Function;
2401 | }
2402 |
2403 | if (this.expectedObject == Object) {
2404 | return typeof other == 'object';
2405 | }
2406 |
2407 | if (this.expectedObject == Boolean) {
2408 | return typeof other == 'boolean';
2409 | }
2410 |
2411 | return other instanceof this.expectedObject;
2412 | };
2413 |
2414 | Any.prototype.jasmineToString = function() {
2415 | return '';
2416 | };
2417 |
2418 | return Any;
2419 | };
2420 |
2421 | getJasmineRequireObj().Anything = function(j$) {
2422 |
2423 | function Anything() {}
2424 |
2425 | Anything.prototype.asymmetricMatch = function(other) {
2426 | return !j$.util.isUndefined(other) && other !== null;
2427 | };
2428 |
2429 | Anything.prototype.jasmineToString = function() {
2430 | return '';
2431 | };
2432 |
2433 | return Anything;
2434 | };
2435 |
2436 | getJasmineRequireObj().ArrayContaining = function(j$) {
2437 | function ArrayContaining(sample) {
2438 | this.sample = sample;
2439 | }
2440 |
2441 | ArrayContaining.prototype.asymmetricMatch = function(other) {
2442 | var className = Object.prototype.toString.call(this.sample);
2443 | if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); }
2444 |
2445 | for (var i = 0; i < this.sample.length; i++) {
2446 | var item = this.sample[i];
2447 | if (!j$.matchersUtil.contains(other, item)) {
2448 | return false;
2449 | }
2450 | }
2451 |
2452 | return true;
2453 | };
2454 |
2455 | ArrayContaining.prototype.jasmineToString = function () {
2456 | return '';
2457 | };
2458 |
2459 | return ArrayContaining;
2460 | };
2461 |
2462 | getJasmineRequireObj().ObjectContaining = function(j$) {
2463 |
2464 | function ObjectContaining(sample) {
2465 | this.sample = sample;
2466 | }
2467 |
2468 | function getPrototype(obj) {
2469 | if (Object.getPrototypeOf) {
2470 | return Object.getPrototypeOf(obj);
2471 | }
2472 |
2473 | if (obj.constructor.prototype == obj) {
2474 | return null;
2475 | }
2476 |
2477 | return obj.constructor.prototype;
2478 | }
2479 |
2480 | function hasProperty(obj, property) {
2481 | if (!obj) {
2482 | return false;
2483 | }
2484 |
2485 | if (Object.prototype.hasOwnProperty.call(obj, property)) {
2486 | return true;
2487 | }
2488 |
2489 | return hasProperty(getPrototype(obj), property);
2490 | }
2491 |
2492 | ObjectContaining.prototype.asymmetricMatch = function(other) {
2493 | if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
2494 |
2495 | for (var property in this.sample) {
2496 | if (!hasProperty(other, property) ||
2497 | !j$.matchersUtil.equals(this.sample[property], other[property])) {
2498 | return false;
2499 | }
2500 | }
2501 |
2502 | return true;
2503 | };
2504 |
2505 | ObjectContaining.prototype.jasmineToString = function() {
2506 | return '';
2507 | };
2508 |
2509 | return ObjectContaining;
2510 | };
2511 |
2512 | getJasmineRequireObj().StringMatching = function(j$) {
2513 |
2514 | function StringMatching(expected) {
2515 | if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
2516 | throw new Error('Expected is not a String or a RegExp');
2517 | }
2518 |
2519 | this.regexp = new RegExp(expected);
2520 | }
2521 |
2522 | StringMatching.prototype.asymmetricMatch = function(other) {
2523 | return this.regexp.test(other);
2524 | };
2525 |
2526 | StringMatching.prototype.jasmineToString = function() {
2527 | return '';
2528 | };
2529 |
2530 | return StringMatching;
2531 | };
2532 |
2533 | getJasmineRequireObj().errors = function() {
2534 | function ExpectationFailed() {}
2535 |
2536 | ExpectationFailed.prototype = new Error();
2537 | ExpectationFailed.prototype.constructor = ExpectationFailed;
2538 |
2539 | return {
2540 | ExpectationFailed: ExpectationFailed
2541 | };
2542 | };
2543 | getJasmineRequireObj().matchersUtil = function(j$) {
2544 | // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
2545 |
2546 | return {
2547 | equals: function(a, b, customTesters) {
2548 | customTesters = customTesters || [];
2549 |
2550 | return eq(a, b, [], [], customTesters);
2551 | },
2552 |
2553 | contains: function(haystack, needle, customTesters) {
2554 | customTesters = customTesters || [];
2555 |
2556 | if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
2557 | (!!haystack && !haystack.indexOf))
2558 | {
2559 | for (var i = 0; i < haystack.length; i++) {
2560 | if (eq(haystack[i], needle, [], [], customTesters)) {
2561 | return true;
2562 | }
2563 | }
2564 | return false;
2565 | }
2566 |
2567 | return !!haystack && haystack.indexOf(needle) >= 0;
2568 | },
2569 |
2570 | buildFailureMessage: function() {
2571 | var args = Array.prototype.slice.call(arguments, 0),
2572 | matcherName = args[0],
2573 | isNot = args[1],
2574 | actual = args[2],
2575 | expected = args.slice(3),
2576 | englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
2577 |
2578 | var message = 'Expected ' +
2579 | j$.pp(actual) +
2580 | (isNot ? ' not ' : ' ') +
2581 | englishyPredicate;
2582 |
2583 | if (expected.length > 0) {
2584 | for (var i = 0; i < expected.length; i++) {
2585 | if (i > 0) {
2586 | message += ',';
2587 | }
2588 | message += ' ' + j$.pp(expected[i]);
2589 | }
2590 | }
2591 |
2592 | return message + '.';
2593 | }
2594 | };
2595 |
2596 | function isAsymmetric(obj) {
2597 | return obj && j$.isA_('Function', obj.asymmetricMatch);
2598 | }
2599 |
2600 | function asymmetricMatch(a, b) {
2601 | var asymmetricA = isAsymmetric(a),
2602 | asymmetricB = isAsymmetric(b);
2603 |
2604 | if (asymmetricA && asymmetricB) {
2605 | return undefined;
2606 | }
2607 |
2608 | if (asymmetricA) {
2609 | return a.asymmetricMatch(b);
2610 | }
2611 |
2612 | if (asymmetricB) {
2613 | return b.asymmetricMatch(a);
2614 | }
2615 | }
2616 |
2617 | // Equality function lovingly adapted from isEqual in
2618 | // [Underscore](http://underscorejs.org)
2619 | function eq(a, b, aStack, bStack, customTesters) {
2620 | var result = true;
2621 |
2622 | var asymmetricResult = asymmetricMatch(a, b);
2623 | if (!j$.util.isUndefined(asymmetricResult)) {
2624 | return asymmetricResult;
2625 | }
2626 |
2627 | for (var i = 0; i < customTesters.length; i++) {
2628 | var customTesterResult = customTesters[i](a, b);
2629 | if (!j$.util.isUndefined(customTesterResult)) {
2630 | return customTesterResult;
2631 | }
2632 | }
2633 |
2634 | if (a instanceof Error && b instanceof Error) {
2635 | return a.message == b.message;
2636 | }
2637 |
2638 | // Identical objects are equal. `0 === -0`, but they aren't identical.
2639 | // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
2640 | if (a === b) { return a !== 0 || 1 / a == 1 / b; }
2641 | // A strict comparison is necessary because `null == undefined`.
2642 | if (a === null || b === null) { return a === b; }
2643 | var className = Object.prototype.toString.call(a);
2644 | if (className != Object.prototype.toString.call(b)) { return false; }
2645 | switch (className) {
2646 | // Strings, numbers, dates, and booleans are compared by value.
2647 | case '[object String]':
2648 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
2649 | // equivalent to `new String("5")`.
2650 | return a == String(b);
2651 | case '[object Number]':
2652 | // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
2653 | // other numeric values.
2654 | return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b);
2655 | case '[object Date]':
2656 | case '[object Boolean]':
2657 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their
2658 | // millisecond representations. Note that invalid dates with millisecond representations
2659 | // of `NaN` are not equivalent.
2660 | return +a == +b;
2661 | // RegExps are compared by their source patterns and flags.
2662 | case '[object RegExp]':
2663 | return a.source == b.source &&
2664 | a.global == b.global &&
2665 | a.multiline == b.multiline &&
2666 | a.ignoreCase == b.ignoreCase;
2667 | }
2668 | if (typeof a != 'object' || typeof b != 'object') { return false; }
2669 |
2670 | var aIsDomNode = j$.isDomNode(a);
2671 | var bIsDomNode = j$.isDomNode(b);
2672 | if (aIsDomNode && bIsDomNode) {
2673 | // At first try to use DOM3 method isEqualNode
2674 | if (a.isEqualNode) {
2675 | return a.isEqualNode(b);
2676 | }
2677 | // IE8 doesn't support isEqualNode, try to use outerHTML && innerText
2678 | var aIsElement = a instanceof Element;
2679 | var bIsElement = b instanceof Element;
2680 | if (aIsElement && bIsElement) {
2681 | return a.outerHTML == b.outerHTML;
2682 | }
2683 | if (aIsElement || bIsElement) {
2684 | return false;
2685 | }
2686 | return a.innerText == b.innerText && a.textContent == b.textContent;
2687 | }
2688 | if (aIsDomNode || bIsDomNode) {
2689 | return false;
2690 | }
2691 |
2692 | // Assume equality for cyclic structures. The algorithm for detecting cyclic
2693 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
2694 | var length = aStack.length;
2695 | while (length--) {
2696 | // Linear search. Performance is inversely proportional to the number of
2697 | // unique nested structures.
2698 | if (aStack[length] == a) { return bStack[length] == b; }
2699 | }
2700 | // Add the first object to the stack of traversed objects.
2701 | aStack.push(a);
2702 | bStack.push(b);
2703 | var size = 0;
2704 | // Recursively compare objects and arrays.
2705 | // Compare array lengths to determine if a deep comparison is necessary.
2706 | if (className == '[object Array]' && a.length !== b.length) {
2707 | result = false;
2708 | }
2709 |
2710 | if (result) {
2711 | // Objects with different constructors are not equivalent, but `Object`s
2712 | // or `Array`s from different frames are.
2713 | if (className !== '[object Array]') {
2714 | var aCtor = a.constructor, bCtor = b.constructor;
2715 | if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor &&
2716 | isFunction(bCtor) && bCtor instanceof bCtor)) {
2717 | return false;
2718 | }
2719 | }
2720 | // Deep compare objects.
2721 | for (var key in a) {
2722 | if (has(a, key)) {
2723 | // Count the expected number of properties.
2724 | size++;
2725 | // Deep compare each member.
2726 | if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
2727 | }
2728 | }
2729 | // Ensure that both objects contain the same number of properties.
2730 | if (result) {
2731 | for (key in b) {
2732 | if (has(b, key) && !(size--)) { break; }
2733 | }
2734 | result = !size;
2735 | }
2736 | }
2737 | // Remove the first object from the stack of traversed objects.
2738 | aStack.pop();
2739 | bStack.pop();
2740 |
2741 | return result;
2742 |
2743 | function has(obj, key) {
2744 | return Object.prototype.hasOwnProperty.call(obj, key);
2745 | }
2746 |
2747 | function isFunction(obj) {
2748 | return typeof obj === 'function';
2749 | }
2750 | }
2751 | };
2752 |
2753 | getJasmineRequireObj().toBe = function() {
2754 | function toBe() {
2755 | return {
2756 | compare: function(actual, expected) {
2757 | return {
2758 | pass: actual === expected
2759 | };
2760 | }
2761 | };
2762 | }
2763 |
2764 | return toBe;
2765 | };
2766 |
2767 | getJasmineRequireObj().toBeCloseTo = function() {
2768 |
2769 | function toBeCloseTo() {
2770 | return {
2771 | compare: function(actual, expected, precision) {
2772 | if (precision !== 0) {
2773 | precision = precision || 2;
2774 | }
2775 |
2776 | return {
2777 | pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
2778 | };
2779 | }
2780 | };
2781 | }
2782 |
2783 | return toBeCloseTo;
2784 | };
2785 |
2786 | getJasmineRequireObj().toBeDefined = function() {
2787 | function toBeDefined() {
2788 | return {
2789 | compare: function(actual) {
2790 | return {
2791 | pass: (void 0 !== actual)
2792 | };
2793 | }
2794 | };
2795 | }
2796 |
2797 | return toBeDefined;
2798 | };
2799 |
2800 | getJasmineRequireObj().toBeFalsy = function() {
2801 | function toBeFalsy() {
2802 | return {
2803 | compare: function(actual) {
2804 | return {
2805 | pass: !!!actual
2806 | };
2807 | }
2808 | };
2809 | }
2810 |
2811 | return toBeFalsy;
2812 | };
2813 |
2814 | getJasmineRequireObj().toBeGreaterThan = function() {
2815 |
2816 | function toBeGreaterThan() {
2817 | return {
2818 | compare: function(actual, expected) {
2819 | return {
2820 | pass: actual > expected
2821 | };
2822 | }
2823 | };
2824 | }
2825 |
2826 | return toBeGreaterThan;
2827 | };
2828 |
2829 |
2830 | getJasmineRequireObj().toBeLessThan = function() {
2831 | function toBeLessThan() {
2832 | return {
2833 |
2834 | compare: function(actual, expected) {
2835 | return {
2836 | pass: actual < expected
2837 | };
2838 | }
2839 | };
2840 | }
2841 |
2842 | return toBeLessThan;
2843 | };
2844 | getJasmineRequireObj().toBeNaN = function(j$) {
2845 |
2846 | function toBeNaN() {
2847 | return {
2848 | compare: function(actual) {
2849 | var result = {
2850 | pass: (actual !== actual)
2851 | };
2852 |
2853 | if (result.pass) {
2854 | result.message = 'Expected actual not to be NaN.';
2855 | } else {
2856 | result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; };
2857 | }
2858 |
2859 | return result;
2860 | }
2861 | };
2862 | }
2863 |
2864 | return toBeNaN;
2865 | };
2866 |
2867 | getJasmineRequireObj().toBeNull = function() {
2868 |
2869 | function toBeNull() {
2870 | return {
2871 | compare: function(actual) {
2872 | return {
2873 | pass: actual === null
2874 | };
2875 | }
2876 | };
2877 | }
2878 |
2879 | return toBeNull;
2880 | };
2881 |
2882 | getJasmineRequireObj().toBeTruthy = function() {
2883 |
2884 | function toBeTruthy() {
2885 | return {
2886 | compare: function(actual) {
2887 | return {
2888 | pass: !!actual
2889 | };
2890 | }
2891 | };
2892 | }
2893 |
2894 | return toBeTruthy;
2895 | };
2896 |
2897 | getJasmineRequireObj().toBeUndefined = function() {
2898 |
2899 | function toBeUndefined() {
2900 | return {
2901 | compare: function(actual) {
2902 | return {
2903 | pass: void 0 === actual
2904 | };
2905 | }
2906 | };
2907 | }
2908 |
2909 | return toBeUndefined;
2910 | };
2911 |
2912 | getJasmineRequireObj().toContain = function() {
2913 | function toContain(util, customEqualityTesters) {
2914 | customEqualityTesters = customEqualityTesters || [];
2915 |
2916 | return {
2917 | compare: function(actual, expected) {
2918 |
2919 | return {
2920 | pass: util.contains(actual, expected, customEqualityTesters)
2921 | };
2922 | }
2923 | };
2924 | }
2925 |
2926 | return toContain;
2927 | };
2928 |
2929 | getJasmineRequireObj().toEqual = function() {
2930 |
2931 | function toEqual(util, customEqualityTesters) {
2932 | customEqualityTesters = customEqualityTesters || [];
2933 |
2934 | return {
2935 | compare: function(actual, expected) {
2936 | var result = {
2937 | pass: false
2938 | };
2939 |
2940 | result.pass = util.equals(actual, expected, customEqualityTesters);
2941 |
2942 | return result;
2943 | }
2944 | };
2945 | }
2946 |
2947 | return toEqual;
2948 | };
2949 |
2950 | getJasmineRequireObj().toHaveBeenCalled = function(j$) {
2951 |
2952 | function toHaveBeenCalled() {
2953 | return {
2954 | compare: function(actual) {
2955 | var result = {};
2956 |
2957 | if (!j$.isSpy(actual)) {
2958 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2959 | }
2960 |
2961 | if (arguments.length > 1) {
2962 | throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
2963 | }
2964 |
2965 | result.pass = actual.calls.any();
2966 |
2967 | result.message = result.pass ?
2968 | 'Expected spy ' + actual.and.identity() + ' not to have been called.' :
2969 | 'Expected spy ' + actual.and.identity() + ' to have been called.';
2970 |
2971 | return result;
2972 | }
2973 | };
2974 | }
2975 |
2976 | return toHaveBeenCalled;
2977 | };
2978 |
2979 | getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
2980 |
2981 | function toHaveBeenCalledWith(util, customEqualityTesters) {
2982 | return {
2983 | compare: function() {
2984 | var args = Array.prototype.slice.call(arguments, 0),
2985 | actual = args[0],
2986 | expectedArgs = args.slice(1),
2987 | result = { pass: false };
2988 |
2989 | if (!j$.isSpy(actual)) {
2990 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2991 | }
2992 |
2993 | if (!actual.calls.any()) {
2994 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; };
2995 | return result;
2996 | }
2997 |
2998 | if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
2999 | result.pass = true;
3000 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
3001 | } else {
3002 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; };
3003 | }
3004 |
3005 | return result;
3006 | }
3007 | };
3008 | }
3009 |
3010 | return toHaveBeenCalledWith;
3011 | };
3012 |
3013 | getJasmineRequireObj().toMatch = function(j$) {
3014 |
3015 | function toMatch() {
3016 | return {
3017 | compare: function(actual, expected) {
3018 | if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
3019 | throw new Error('Expected is not a String or a RegExp');
3020 | }
3021 |
3022 | var regexp = new RegExp(expected);
3023 |
3024 | return {
3025 | pass: regexp.test(actual)
3026 | };
3027 | }
3028 | };
3029 | }
3030 |
3031 | return toMatch;
3032 | };
3033 |
3034 | getJasmineRequireObj().toThrow = function(j$) {
3035 |
3036 | function toThrow(util) {
3037 | return {
3038 | compare: function(actual, expected) {
3039 | var result = { pass: false },
3040 | threw = false,
3041 | thrown;
3042 |
3043 | if (typeof actual != 'function') {
3044 | throw new Error('Actual is not a Function');
3045 | }
3046 |
3047 | try {
3048 | actual();
3049 | } catch (e) {
3050 | threw = true;
3051 | thrown = e;
3052 | }
3053 |
3054 | if (!threw) {
3055 | result.message = 'Expected function to throw an exception.';
3056 | return result;
3057 | }
3058 |
3059 | if (arguments.length == 1) {
3060 | result.pass = true;
3061 | result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; };
3062 |
3063 | return result;
3064 | }
3065 |
3066 | if (util.equals(thrown, expected)) {
3067 | result.pass = true;
3068 | result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; };
3069 | } else {
3070 | result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; };
3071 | }
3072 |
3073 | return result;
3074 | }
3075 | };
3076 | }
3077 |
3078 | return toThrow;
3079 | };
3080 |
3081 | getJasmineRequireObj().toThrowError = function(j$) {
3082 | function toThrowError (util) {
3083 | return {
3084 | compare: function(actual) {
3085 | var threw = false,
3086 | pass = {pass: true},
3087 | fail = {pass: false},
3088 | thrown;
3089 |
3090 | if (typeof actual != 'function') {
3091 | throw new Error('Actual is not a Function');
3092 | }
3093 |
3094 | var errorMatcher = getMatcher.apply(null, arguments);
3095 |
3096 | try {
3097 | actual();
3098 | } catch (e) {
3099 | threw = true;
3100 | thrown = e;
3101 | }
3102 |
3103 | if (!threw) {
3104 | fail.message = 'Expected function to throw an Error.';
3105 | return fail;
3106 | }
3107 |
3108 | if (!(thrown instanceof Error)) {
3109 | fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; };
3110 | return fail;
3111 | }
3112 |
3113 | if (errorMatcher.hasNoSpecifics()) {
3114 | pass.message = 'Expected function not to throw an Error, but it threw ' + j$.fnNameFor(thrown) + '.';
3115 | return pass;
3116 | }
3117 |
3118 | if (errorMatcher.matches(thrown)) {
3119 | pass.message = function() {
3120 | return 'Expected function not to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + '.';
3121 | };
3122 | return pass;
3123 | } else {
3124 | fail.message = function() {
3125 | return 'Expected function to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() +
3126 | ', but it threw ' + errorMatcher.thrownDescription(thrown) + '.';
3127 | };
3128 | return fail;
3129 | }
3130 | }
3131 | };
3132 |
3133 | function getMatcher() {
3134 | var expected = null,
3135 | errorType = null;
3136 |
3137 | if (arguments.length == 2) {
3138 | expected = arguments[1];
3139 | if (isAnErrorType(expected)) {
3140 | errorType = expected;
3141 | expected = null;
3142 | }
3143 | } else if (arguments.length > 2) {
3144 | errorType = arguments[1];
3145 | expected = arguments[2];
3146 | if (!isAnErrorType(errorType)) {
3147 | throw new Error('Expected error type is not an Error.');
3148 | }
3149 | }
3150 |
3151 | if (expected && !isStringOrRegExp(expected)) {
3152 | if (errorType) {
3153 | throw new Error('Expected error message is not a string or RegExp.');
3154 | } else {
3155 | throw new Error('Expected is not an Error, string, or RegExp.');
3156 | }
3157 | }
3158 |
3159 | function messageMatch(message) {
3160 | if (typeof expected == 'string') {
3161 | return expected == message;
3162 | } else {
3163 | return expected.test(message);
3164 | }
3165 | }
3166 |
3167 | return {
3168 | errorTypeDescription: errorType ? j$.fnNameFor(errorType) : 'an exception',
3169 | thrownDescription: function(thrown) {
3170 | var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception',
3171 | thrownMessage = '';
3172 |
3173 | if (expected) {
3174 | thrownMessage = ' with message ' + j$.pp(thrown.message);
3175 | }
3176 |
3177 | return thrownName + thrownMessage;
3178 | },
3179 | messageDescription: function() {
3180 | if (expected === null) {
3181 | return '';
3182 | } else if (expected instanceof RegExp) {
3183 | return ' with a message matching ' + j$.pp(expected);
3184 | } else {
3185 | return ' with message ' + j$.pp(expected);
3186 | }
3187 | },
3188 | hasNoSpecifics: function() {
3189 | return expected === null && errorType === null;
3190 | },
3191 | matches: function(error) {
3192 | return (errorType === null || error instanceof errorType) &&
3193 | (expected === null || messageMatch(error.message));
3194 | }
3195 | };
3196 | }
3197 |
3198 | function isStringOrRegExp(potential) {
3199 | return potential instanceof RegExp || (typeof potential == 'string');
3200 | }
3201 |
3202 | function isAnErrorType(type) {
3203 | if (typeof type !== 'function') {
3204 | return false;
3205 | }
3206 |
3207 | var Surrogate = function() {};
3208 | Surrogate.prototype = type.prototype;
3209 | return (new Surrogate()) instanceof Error;
3210 | }
3211 | }
3212 |
3213 | return toThrowError;
3214 | };
3215 |
3216 | getJasmineRequireObj().interface = function(jasmine, env) {
3217 | var jasmineInterface = {
3218 | describe: function(description, specDefinitions) {
3219 | return env.describe(description, specDefinitions);
3220 | },
3221 |
3222 | xdescribe: function(description, specDefinitions) {
3223 | return env.xdescribe(description, specDefinitions);
3224 | },
3225 |
3226 | fdescribe: function(description, specDefinitions) {
3227 | return env.fdescribe(description, specDefinitions);
3228 | },
3229 |
3230 | it: function() {
3231 | return env.it.apply(env, arguments);
3232 | },
3233 |
3234 | xit: function() {
3235 | return env.xit.apply(env, arguments);
3236 | },
3237 |
3238 | fit: function() {
3239 | return env.fit.apply(env, arguments);
3240 | },
3241 |
3242 | beforeEach: function() {
3243 | return env.beforeEach.apply(env, arguments);
3244 | },
3245 |
3246 | afterEach: function() {
3247 | return env.afterEach.apply(env, arguments);
3248 | },
3249 |
3250 | beforeAll: function() {
3251 | return env.beforeAll.apply(env, arguments);
3252 | },
3253 |
3254 | afterAll: function() {
3255 | return env.afterAll.apply(env, arguments);
3256 | },
3257 |
3258 | expect: function(actual) {
3259 | return env.expect(actual);
3260 | },
3261 |
3262 | pending: function() {
3263 | return env.pending.apply(env, arguments);
3264 | },
3265 |
3266 | fail: function() {
3267 | return env.fail.apply(env, arguments);
3268 | },
3269 |
3270 | spyOn: function(obj, methodName) {
3271 | return env.spyOn(obj, methodName);
3272 | },
3273 |
3274 | jsApiReporter: new jasmine.JsApiReporter({
3275 | timer: new jasmine.Timer()
3276 | }),
3277 |
3278 | jasmine: jasmine
3279 | };
3280 |
3281 | jasmine.addCustomEqualityTester = function(tester) {
3282 | env.addCustomEqualityTester(tester);
3283 | };
3284 |
3285 | jasmine.addMatchers = function(matchers) {
3286 | return env.addMatchers(matchers);
3287 | };
3288 |
3289 | jasmine.clock = function() {
3290 | return env.clock;
3291 | };
3292 |
3293 | return jasmineInterface;
3294 | };
3295 |
3296 | getJasmineRequireObj().version = function() {
3297 | return '2.3.4';
3298 | };
3299 |
--------------------------------------------------------------------------------
/test/lib/jasmine-2.3.4/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevMountain/javascript-3-afternoon/1585995084f5607df7ec3f1168938004ccbffbc4/test/lib/jasmine-2.3.4/jasmine_favicon.png
--------------------------------------------------------------------------------
/test/spec/classesSpec.js:
--------------------------------------------------------------------------------
1 | // ========================
2 |
3 | describe('Classes', function () {
4 | describe('Employee', function () {
5 | it('exists', function () {
6 | expect(new Employee()).not.toBeNull();
7 | })
8 | it('sets all four properties in the constructor', function () {
9 | let emp = new Employee("Dallin", "Anderson", "Dallin@DallinDallin.com", 25);
10 |
11 | expect(emp.first_name).toEqual("Dallin")
12 | expect(emp.last_name).toEqual("Anderson")
13 | expect(emp.email).toEqual("Dallin@DallinDallin.com")
14 | expect(emp.age).toEqual(25)
15 | })
16 | it('can make a widget', function () {
17 | let emp = new Employee("Dallin", "Anderson", "Dallin@DallinDallin.com", 25)
18 | let result = emp.makeWidget()
19 |
20 | expect(result).toEqual("Dallin Anderson Widget")
21 | })
22 | })
23 |
24 | describe('Manager', function () {
25 | it('exists', function () {
26 | expect(new Manager()).not.toBeNull();
27 | })
28 | it('sets all four properties in the constructor and the report', function () {
29 | let emp = new Manager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25);
30 |
31 | expect(emp.first_name).toEqual("Dallin")
32 | expect(emp.last_name).toEqual("Anderson")
33 | expect(emp.email).toEqual("Dallin@DallinDallin.com")
34 | expect(emp.age).toEqual(25)
35 | expect(emp.reports).not.toBeNull();
36 | expect(emp.reports.length).toEqual(0)
37 | })
38 | it('can hire new employees', function () {
39 | let emp = new Manager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25)
40 | emp.hire(new Employee("Ballin", "BAnderson", "Ballin@BallinBallin.com", 22));
41 |
42 | expect(emp.reports.length).toEqual(1)
43 | expect(emp.reports[0].first_name).toEqual("Ballin")
44 | })
45 | it('can fire new employees', function () {
46 | let emp = new Manager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25)
47 | emp.hire(new Employee("Ballin0", "BAnderson", "Ballin@BallinBallin.com", 22));
48 | emp.hire(new Employee("Ballin1", "BAnderson", "Ballin@BallinBallin.com", 22));
49 | emp.hire(new Employee("Ballin2", "BAnderson", "Ballin@BallinBallin.com", 22));
50 | emp.fire(1);
51 |
52 | expect(emp.reports.length).toEqual(2)
53 | expect(emp.reports[0].first_name).toEqual("Ballin0")
54 | expect(emp.reports[1].first_name).toEqual("Ballin2")
55 | })
56 | })
57 |
58 | describe('ProgressiveManager', function () {
59 | it('exists', function () {
60 | expect(new ProgressiveManager()).not.toBeNull();
61 | })
62 | it('sets all properties in the constructor and title and bonus', function () {
63 | let emp = new ProgressiveManager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25);
64 |
65 |
66 | expect(emp.first_name).toEqual("Dallin")
67 | expect(emp.last_name).toEqual("Anderson")
68 | expect(emp.email).toEqual("Dallin@DallinDallin.com")
69 | expect(emp.age).toEqual(25)
70 | expect(emp.reports).not.toBeNull();
71 | expect(emp.reports.length).toEqual(0)
72 | expect(emp.title).toEqual("Not a manager")
73 | expect(emp.bonus).toEqual(0)
74 | })
75 | it('updates title on hire', function () {
76 | let emp = new ProgressiveManager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25)
77 |
78 | emp.hire(new Employee("Ballin", "BAnderson", "Ballin@BallinBallin.com", 22));
79 | expect(emp.title).toEqual("Barely Manager")
80 |
81 | hireTimes(5, emp);
82 | expect(emp.title).toEqual("Mostly Manager")
83 |
84 | hireTimes(20, emp);
85 | expect(emp.title).toEqual("Manager")
86 |
87 | hireTimes(50, emp);
88 | expect(emp.title).toEqual("Manager Plus")
89 |
90 | hireTimes(50, emp);
91 | expect(emp.title).toEqual("Bestest Manager")
92 | })
93 | it('can fire employees for bonuses', function () {
94 | let emp = new ProgressiveManager("Dallin", "Anderson", "Dallin@DallinDallin.com", 25)
95 | hireTimes(10, emp);
96 | emp.fire(1);
97 | expect(emp.bonus).toEqual(100)
98 |
99 | emp.fire(1);
100 | emp.fire(1);
101 | emp.fire(1);
102 | expect(emp.bonus).toEqual(400)
103 | })
104 |
105 | function hireTimes(times, manager) {
106 | for (var i = 0; i < times; i++) {
107 | manager.hire(new Employee("Ballin", "BAnderson", "Ballin@BallinBallin.com", 22));
108 | }
109 | }
110 | })
111 |
112 |
113 | describe('Machine', function () {
114 | it('exists', function () {
115 | expect(new Machine()).not.toBeNull();
116 | })
117 | it('sets all properties in the constructor and the report', function () {
118 | let machine = new Machine();
119 |
120 | expect(machine.widgets_made_count).toEqual(0)
121 | expect(machine.wear_and_tear_count).toEqual(0)
122 | expect(machine.needs_reboot).toEqual(false)
123 | })
124 | it('can make widgets', function () {
125 | let machine = new Machine();
126 |
127 | machine.makeWidgets(50)
128 | expect(machine.widgets_made_count).toEqual(50)
129 | expect(machine.wear_and_tear_count).toEqual(1)
130 | expect(machine.needs_reboot).toEqual(false)
131 | })
132 | it('updates wear and tear when making widgets', function () {
133 | let machine = new Machine();
134 |
135 | machine.makeWidgets(50);
136 | expect(machine.widgets_made_count).toEqual(50)
137 | expect(machine.wear_and_tear_count).toEqual(1)
138 | expect(machine.needs_reboot).toEqual(false)
139 |
140 | machine.makeWidgets(500);
141 | expect(machine.widgets_made_count).toEqual(550)
142 | expect(machine.wear_and_tear_count).toEqual(11)
143 | expect(machine.needs_reboot).toEqual(false)
144 | })
145 | it('can register fixes', function () {
146 | let machine = new Machine();
147 |
148 | machine.makeWidgets(5000);
149 | machine.fixMachine();
150 |
151 | expect(machine.needs_reboot).toBe(true);
152 | })
153 | it('can update wear and tear after fixes and reboot', function () {
154 | let machine = new Machine();
155 | machine.makeWidgets(5000);
156 | machine.fixMachine();
157 |
158 | let rebootComplete = machine.reboot();
159 | // Ensure the values haven't been changed yet.
160 | expect(machine.wear_and_tear_count).toEqual(100, 'wear_and_tear_count should be 100 until function returned by machine.reboot() is executed.');
161 | expect(machine.needs_reboot).toBe(true, 'needs_reboot should be true until function returned by machine.reboot() is executed.');
162 |
163 | rebootComplete();
164 | expect(machine.wear_and_tear_count).toEqual(90);
165 | expect(machine.needs_reboot).toBe(false);
166 | })
167 | })
168 | })
169 |
--------------------------------------------------------------------------------
/test/spec/destructuringSpec.js:
--------------------------------------------------------------------------------
1 | // ========================
2 |
3 | describe('Object destructuring for new variables', function () {
4 | describe('color', function () {
5 | it('should exist', function () {
6 | expect(color).toBeDefined();
7 | })
8 | it('should have the correct value', function () {
9 | expect(color).toBe('red');
10 | })
11 | })
12 |
13 | describe('model', function () {
14 | it('should exist', function () {
15 | expect(model).toBeDefined();
16 | })
17 | it('should have the correct value', function () {
18 | expect(model).toBe('tacoma');
19 | })
20 | })
21 |
22 | describe('make', function () {
23 | it('should exist', function () {
24 | expect(make).toBeDefined();
25 | })
26 | it('should have the correct value', function () {
27 | expect(make).toBe('toyota');
28 | })
29 | })
30 |
31 | describe('year', function () {
32 | it('should exist', function () {
33 | expect(year).toBeDefined();
34 | })
35 | it('should have the correct value', function () {
36 | expect(year).toBe(1994);
37 | })
38 | })
39 | })
40 |
41 |
42 | // ========================
43 |
44 |
45 | describe('greeting', function () {
46 | it('should exist', function () {
47 | expect(greeting).toBeDefined();
48 | })
49 | it('should return the correct value', function () {
50 | expect(greeting({firstName: 'Henry', lastName: 'Von Eckleberry', title: 'Sir'})).toBe('Hello, Sir Henry Von Eckleberry!');
51 | expect(greeting({firstName: 'Betty', lastName: 'LeJavascript', title: 'Queen'})).toBe('Hello, Queen Betty LeJavascript!');
52 | })
53 | })
54 |
55 |
56 | // ========================
57 |
58 |
59 | describe('totalPopulation', function () {
60 | it('should exist', function () {
61 | expect(totalPopulation).toBeDefined();
62 | })
63 | it('should return the correct value', function () {
64 | expect(totalPopulation({utah: 10, california: 29087, texas: 82937, arizona: 28347})).toBe(140381);
65 | expect(totalPopulation({utah: 1045, california: 987, texas: 192937, arizona: 347})).toBe(195316);
66 | })
67 | })
68 |
69 |
70 | // ========================
71 |
72 |
73 | describe('ingredients', function () {
74 | it('should exist', function () {
75 | expect(ingredients).toBeDefined();
76 | })
77 | it('should return the correct value', function () {
78 | expect(ingredients({carb: 'flour', fat: 'butter', protein: 'eggs'}).sort()).toEqual([ 'flour', 'butter', 'eggs' ].sort());
79 | expect(ingredients({carb: 'rice', fat: 'bacon grease', protein: 'chicken'}).sort()).toEqual([ 'rice', 'bacon grease', 'chicken' ].sort());
80 | })
81 | })
82 |
83 |
84 | // ========================
85 |
86 |
87 | describe('largeNumbers', function () {
88 | it('should exist', function () {
89 | expect(largeNumbers).toBeDefined();
90 | })
91 | it('should return the correct value', function () {
92 | expect(largeNumbers({first: 10, second: 2, third: 90})).toBe(2);
93 | expect(largeNumbers({first: 1, second: 2, third: 80})).toBe(1);
94 | })
95 | })
96 |
97 |
98 | // ========================
99 |
100 |
101 | describe('numberGroups', function () {
102 | it('should exist', function () {
103 | expect(numberGroups).toBeDefined();
104 | })
105 | it('should return the correct value', function () {
106 | expect(numberGroups({a:[1, 2, 3], b:[1], c:[1, 2, 3, 4, 5]})).toEqual([ 1, 2, 3, 4, 5 ]);
107 | expect(numberGroups({a:[1, 2, 3], b:[1, 2, 3, 4], c:[1, 2, 3]})).toEqual([ 1, 2, 3, 4 ]);
108 | })
109 | })
110 |
--------------------------------------------------------------------------------
/test/spec/for-in-delete-spec.js:
--------------------------------------------------------------------------------
1 | describe('showValues', function () {
2 | it('should exist', function () {
3 | expect(showValues).toBeDefined();
4 | })
5 | it('should return the correct value', function () {
6 | expect(showValues({one: 'These', two: ' are', three: ' the', four: ' property', five: ' values.'})).toBe('These are the property values.');
7 | expect(showValues({one: 'Conquer', two: ' the', three: ' world', four: ' as a', five: ' javascript ninja!'})).toBe('Conquer the world as a javascript ninja!');
8 | })
9 | })
10 |
11 | // ========================
12 |
13 | describe('greaterThan10', function () {
14 | it('should exist', function () {
15 | expect(greaterThan10).toBeDefined();
16 | })
17 | it('should return the correct value', function () {
18 | expect(greaterThan10({one: 1, two: 2, three: 11, four: 44, five: 5})).toEqual({ one: 1, two: 2, three: 0, four: 0, five: 5 });
19 | expect(greaterThan10({one: 10, two: 20, three: 11, four: 4, five: 335})).toEqual({ one: 10, two: 0, three: 0, four: 4, five: 0 });
20 | })
21 | })
22 |
23 | // ========================
24 |
25 |
26 | describe('double', function () {
27 | it('should exist', function () {
28 | expect(double).toBeDefined();
29 | })
30 | it('should return the correct value', function () {
31 | expect(double({one: 1, two: 2, three: 3})).toEqual({ one: 2, two: 4, three: 6 });
32 | expect(double({one: 177, two: 2234, three: 23})).toEqual({ one: 354, two: 4468, three: 46 });
33 | })
34 | })
35 |
36 |
37 | // ========================
38 |
39 |
40 | describe('secrets', function () {
41 | it('should exist', function () {
42 | expect(secrets).toBeDefined();
43 | })
44 | it('should return the correct value', function () {
45 | expect(secrets({shhh: 'I really', one: 'this is no secret', shake: ', really love ', shed: 'javascript!', two: 'this also does not belong'})).toBe('I really, really love javascript!');
46 |
47 | expect(secrets({sh: 'Cheese', sally: 'this is no secret', shake: ' is', shed: ' disgusting :(', sue: 'this also does not belong', s: 'nope!'})).toBe('Cheese is disgusting :(');
48 | })
49 | })
50 |
51 |
52 | // ========================
53 |
54 |
55 | describe('removePassword', function () {
56 | it('should exist', function () {
57 | expect(removePassword).toBeDefined();
58 | })
59 | it('should return the correct value', function () {
60 | expect(removePassword({username: 'happyCow23', password: '123jumptheMoon'})).toEqual({ username: 'happyCow23' });
61 | expect(removePassword({username: 'JSQueen', password: 'es6RulesTheWorld'})).toEqual({ username: 'JSQueen' });
62 | })
63 | })
64 |
65 |
66 | // ========================
67 |
68 |
69 | describe('deleteTheBigNumbers', function () {
70 | it('should exist', function () {
71 | expect(deleteTheBigNumbers).toBeDefined();
72 | })
73 | it('properties should be deleted in the for in loop', function () {
74 | expect(deleteTheBigNumbers).toEqual({first: 10, second: 20});
75 | })
76 | })
77 |
78 |
79 | // ========================
80 |
81 |
82 | describe('startsWithK', function () {
83 | it('should exist', function () {
84 | expect(startsWithK).toBeDefined();
85 | })
86 | it('should return the correct value', function () {
87 | expect(startsWithK({kitty: 2, dog: 3, cat: 4})).toEqual({ dog: 3, cat: 4 });
88 | expect(startsWithK({snake: 2, cougar: 3, kangaroo: 4})).toEqual({ snake: 2, cougar: 3 });
89 | })
90 | })
91 |
92 |
93 | // ========================
94 |
95 |
96 | describe('hiddenTreasure', function () {
97 | it('should exist', function () {
98 | expect(hiddenTreasure).toBeDefined();
99 | })
100 | it('should return the correct value', function () {
101 | expect(hiddenTreasure({one: 'this has none', two: 'big treasure!', three: 'only disappointment'})).toEqual({ two: 'big treasure!' });
102 | expect(hiddenTreasure({one: 'happiness but no money', two: 'puppies are always a treasure', three: 'rocks, lots of rocks'})).toEqual({ two: 'puppies are always a treasure' });
103 | })
104 | })
--------------------------------------------------------------------------------
/test/spec/higher-order-spec.js:
--------------------------------------------------------------------------------
1 | describe('filters1', ()=>{
2 | describe('evenNumbers', ()=>{
3 | it('should exist', ()=>{
4 | expect(evenNumbers).toBeDefined();
5 | })
6 | it('should be an array', ()=>{
7 | expect(evenNumbers.length).toBeDefined();
8 | })
9 | it('should have 8 elements', ()=>{
10 | expect(evenNumbers.length).toBe(8);
11 | })
12 | it('should have the correct elements', ()=>{
13 | expect(evenNumbers.sort().toString()).toBe([6, 2, 6, 8, 4, 2, 8, 4].sort().toString());
14 | })
15 | })
16 | })
17 |
18 | describe('map1', ()=>{
19 | describe('postTaxPrices', ()=>{
20 | it('should exist', ()=>{
21 | expect(postTaxPrices).toBeDefined();
22 | })
23 | it('should be an array', ()=>{
24 | expect(postTaxPrices.length).toBeDefined();
25 | })
26 | it('should have 9 elements', ()=>{
27 | expect(postTaxPrices.length).toBe(9);
28 | })
29 | it('should have the correct prices', ()=>{
30 | let incorrect = [16.05, 24.610000000000003, 83.46000000000001, 36.38,
31 | 12.84, 92.02000000000001, 12.84, 84.53, 34.24].reduce(
32 | (p, e, i)=>p||(Math.abs(e-postTaxPrices[i])>.02), false)
33 | expect(incorrect).toBe(false);
34 | })
35 | })
36 | })
37 |
38 | describe('reduce1', ()=>{
39 | describe('totalPopulation', ()=>{
40 | it('should exist', ()=>{
41 | expect(totalPopulation).toBeDefined();
42 | })
43 | it('should have the correct total', ()=>{
44 | expect(totalPopulation).toBe(16763615);
45 | })
46 | })
47 | })
48 |
49 | describe('filters2', ()=>{
50 | describe('myStrongest', ()=>{
51 | it('should exist', ()=>{
52 | expect(myStrongest).toBeDefined();
53 | })
54 | it('should be an array', ()=>{
55 | expect(myStrongest.length).toBeDefined();
56 | })
57 | it('should have 9 elements', ()=>{
58 | expect(myStrongest.length).toBe(9);
59 | })
60 | it('should have the correct monsters', ()=>{
61 | expect(myStrongest.map(e=>e.monster).sort().toString())
62 | .toEqual(monstersInYourPocket.filter(e=>e.CP>200).map(e=>e.monster).sort().toString());
63 | expect(myStrongest.map(e=>e.CP).sort().toString())
64 | .toEqual(monstersInYourPocket.filter(e=>e.CP>200).map(e=>e.CP).sort().toString());
65 | })
66 | })
67 | })
68 |
69 | describe('map2', ()=>{
70 | describe('orderTotals', ()=>{
71 | it('should exist', ()=>{
72 | expect(orderTotals).toBeDefined();
73 | })
74 | it('should be an array', ()=>{
75 | expect(orderTotals.length).toBeDefined();
76 | })
77 | it('should have 10 elements', ()=>{
78 | expect(orderTotals.length).toBe(10);
79 | })
80 | it('should have the correct prices', ()=>{
81 | for (let i = 0; i < orders.length; i++) {
82 | const answer = orders[i].price * (1 + orders[i].tax);
83 | expect(orderTotals[i]).toBe(answer, `Expected orderTotals index ${i} to be ${answer}, got ${orderTotals[i]}`)
84 | if (orderTotals[i] != answer) {
85 | break;
86 | }
87 | }
88 | })
89 | })
90 | })
91 |
92 | describe('reduce2', ()=>{
93 | describe('bobsTotal', ()=>{
94 | it('should exist', ()=>{
95 | expect(bobsTotal).toBeDefined();
96 | })
97 | it('should have the correct total', ()=>{
98 | expect(bobsTotal).toBe(891);
99 | })
100 | })
101 | })
102 |
103 | // describe('fns-and-scope', function () {
104 | //
105 | //
106 | // describe('isTyler', function () {
107 | // it('should exist', function () {
108 | // expect(isTyler).toBeDefined();
109 | // })
110 | // it('should return true if passed "Tyler"', function () {
111 | // expect(isTyler('Tyler')).toBe(true);
112 | // })
113 | // it('should return false if passed something other than "Tyler"', function () {
114 | // expect(isTyler('Stan')).toBe(false);
115 | // })
116 | // })
117 | //
118 | // describe('getName', function () {
119 | // beforeEach(function () {
120 | // // var prompt = function () {
121 | // // return true;
122 | // // }
123 | //
124 | // spyOn(window, 'prompt').and.returnValue('My Name');
125 | //
126 | // })
127 | // it('should exist', function () {
128 | // expect(getName).toBeDefined();
129 | // })
130 | // it('should invoke prompt()', function () {
131 | // getName();
132 | // expect(window.prompt).toHaveBeenCalled();
133 | // })
134 | // it('should return the name input from the prompt', function () {
135 | // var name = getName();
136 | // expect(name).toBe('My Name');
137 | // })
138 | // })
139 | //
140 | // describe('welcome', function () {
141 | // beforeEach(function () {
142 | // spyOn(window, 'prompt').and.returnValue('Rockstar');
143 | // spyOn(window, 'alert').and.returnValue('Welcome ' + prompt());
144 | // spyOn(window, 'getName').and.returnValue('Rockstar');
145 | // // var getName = jasmine.createSpy().and.returnValue('Rockstar');
146 | // })
147 | // it('should exist', function () {
148 | // expect(welcome).toBeDefined();
149 | // })
150 | // it('should invoke getName()', function () {
151 | // welcome();
152 | // expect(getName).toHaveBeenCalled();
153 | // })
154 | // it('should invoke alert()', function () {
155 | // welcome();
156 | // expect(alert).toHaveBeenCalled();
157 | // })
158 | // it('should alert "Welcome, " plus the name', function () {
159 | // welcome();
160 | // expect(alert).toHaveBeenCalledWith('Welcome, Rockstar')
161 | // })
162 | // })
163 | //
164 | // describe('myName', function () {
165 | // it('should exist', function () {
166 | // expect(myName).toBeDefined();
167 | // })
168 | // it('should return a string', function () {
169 | // var name = myName();
170 | // expect(name).toEqual(jasmine.any(String));
171 | // })
172 | // })
173 | //
174 | // describe('newMyName', function () {
175 | // it('should exist', function () {
176 | // expect(newMyName).toBeDefined();
177 | // })
178 | // it('should be a function', function () {
179 | // expect(newMyName).toEqual(jasmine.any(Function));
180 | // })
181 | // })
182 | //
183 | // describe('outerFn', function () {
184 | // it('should exist', function () {
185 | // expect(outerFn).toBeDefined();
186 | // })
187 | // it('should return a function', function () {
188 | // var fn = outerFn();
189 | // expect(fn).toEqual(jasmine.any(Function));
190 | // })
191 | // it('should return a function that returns a string', function () {
192 | // var fn = outerFn();
193 | // var str = fn();
194 | // expect(str).toEqual(jasmine.any(String));
195 | // })
196 | // })
197 | //
198 | // describe('innerFn', function () {
199 | // it('should exist', function () {
200 | // expect(innerFn).toBeDefined();
201 | // })
202 | // it('should be a function', function () {
203 | // expect(innerFn).toEqual(jasmine.any(Function));
204 | // })
205 | // it('should return a string', function () {
206 | // var str = innerFn();
207 | // expect(str).toEqual(jasmine.any(String));
208 | // })
209 | // })
210 | //
211 | // })
212 |
--------------------------------------------------------------------------------
/test/spec/nestingSpec.js:
--------------------------------------------------------------------------------
1 | describe('Update Employee Info', function() {
2 | var returnedArr;
3 | it('Theo Trill object should be removed', function() {
4 | returnedArr = employeeUpdater();
5 | var flag = true;
6 | returnedArr.map(function(employee) {
7 | if (employee.firstName === 'Theo') flag = false;
8 | })
9 | expect(flag).toEqual(true);
10 | })
11 |
12 | it('Lorie should be in HR department', function() {
13 | var flag = true;
14 | var lorie = returnedArr.filter(e => e.firstName === 'Lorie')
15 | expect(lorie[0].department).toEqual('HR');
16 | })
17 | })
18 |
19 | describe('Workplace accidents', function() {
20 | it('removeDuplicates function should exist', function() {
21 | expect(removeDuplicates).toEqual(jasmine.any(Function));
22 | })
23 | it('removeDuplicates should return the array of workplace accidents', function() {
24 | returnedArr = removeDuplicates([12, 56, 44, 3, 29, 56, 56, 3, 7, 12])
25 | expect(returnedArr).toEqual(jasmine.any(Array));
26 | })
27 | it ('Should remove all duplicate entries', function() {
28 | var returnedArr = removeDuplicates([12, 56, 44, 3, 29, 56, 56, 3, 7, 12]).sort(function(a,b) {
29 | return a - b;
30 | });
31 | expect(returnedArr).toEqual(jasmine.any(Array));
32 | var answer = [3,7,12,29,44,56];
33 | var flag = true;
34 | returnedArr.map( (n,i) => {
35 | if( n[i] !== answer[i]) flag = false;
36 | })
37 | expect(returnedArr.length).toEqual(6);
38 | })
39 | })
40 |
41 | describe('Fluffy & friends', function() {
42 |
43 | it('grumpyActivity value should be \'eat food\'', function() {
44 | expect(grumpyActivity).toEqual('eat food')
45 | })
46 | it('fluffy2ndFriend should be "Lazy Bones"', function() {
47 | expect(fluffy2ndFriend).toEqual('Lazy Bones');
48 | })
49 | })
50 |
51 | describe('Driving record', function() {
52 | it('recordCleaner should exist', function() {
53 | expect(recordCleaner).toEqual(jasmine.any(Function));
54 | })
55 | it('No longer at fault for accidents', function() {
56 | recordCleaner();
57 | console.log(myCar)
58 | var flag = true;
59 | myCar.accidents.map(function(accident) {
60 | if (accident.atFaultForAccident) {
61 | flag = false;
62 | }
63 | })
64 | expect(flag).toEqual(true);
65 | })
66 | })
67 |
68 | describe('Looper', function() {
69 | it('looper should exist', function() {
70 | expect(looper).toEqual(jasmine.any(Function));
71 | })
72 | it('Array should be filled with "odd" and "even" instead of numbers', function() {
73 | var answer = [ [ 'odd', 'even', 'odd', 'even' ], [ 'odd', 'even' ],[ 'odd', 'even', 'odd', 'even', 'odd' ] ]
74 | var userAnswer = looper();
75 | var flag = true;
76 | for (var i = 0; i < answer.length; i++) {
77 | for(var j = 0; j < answer[i].length; j++) {
78 | if (answer[i][j] !== userAnswer[i][j]) {
79 | flag = false;
80 | }
81 | }
82 | }
83 | expect(flag).toEqual(true);
84 | })
85 |
86 | })
--------------------------------------------------------------------------------