├── README.md
├── SOLUTION.md
├── css
├── icomoon.css
├── normalize.css
└── style.css
├── fonts
├── icomoon.eot
├── icomoon.svg
├── icomoon.ttf
└── icomoon.woff
├── index.html
├── jasmine
├── lib
│ └── jasmine-2.1.2
│ │ ├── boot.js
│ │ ├── console.js
│ │ ├── jasmine-html.js
│ │ ├── jasmine.css
│ │ ├── jasmine.js
│ │ └── jasmine_favicon.png
└── spec
│ └── feedreader.js
└── js
└── app.js
/README.md:
--------------------------------------------------------------------------------
1 | # Udacity Feed Reader
2 | A web-based application that reads RSS feeds and allows users to read them.
3 |
4 | ## Solution
5 | I've written a guide for this project, it's the SOLUTION.md file. Check it out if you're in trouble. Star this repo if it helped, it'll mean a lot! It will show me It actually helped someone.
6 |
7 | ## How to use
8 | Click any link to read feed.
9 | Use the menu to switch between feed sources.
10 | If you want to modify the file, clone this repository and add functionality as you see please. Unit testing should be done in the feedreader.js file using the Jasmine framework.
11 |
12 | ## Main functions
13 | ### loadFeed()
14 | the `loadFeed` function loads feeds from a selected source from the `allFeeds` array, namely the `id` parameter, like so:
15 | `loadFeed(0)`.
16 | The function `cd` parameter is a callback function that will be executed once the function completes its task.
17 |
18 | ## Dependencies
19 | This application uses:
20 | - jQuery (duh!)
21 | - Jasmine for unit testing
22 | - Handlebars JS for templating
23 |
24 | License
25 | ----
26 | MIT
--------------------------------------------------------------------------------
/SOLUTION.md:
--------------------------------------------------------------------------------
1 | # Udacity Feed Reader Guide
2 | This here is the feed reader project rundown. It was made after I banged my head again and again against the nearest wall, submitted the project thrice and drank loads of coffee, and decided somthing was broken here.
3 | ## Part 1
4 | ### First test
5 | ```sh
6 | /* TODO: Write a test that loops through each feed
7 | * in the allFeeds object and ensures it has a URL defined
8 | * and that the URL is not empty.
9 | */
10 | ```
11 | Here we're asked to loop through the allFeeds array and check if all the feeds have a URL defined.
12 | Seems pretty easy when we have the forEach method.
13 | Now we just need to look at the allFeeds array and figure it out.
14 | ### hint
15 | Try logging the allFeeds array in the console and see it's porperties before looping through them.
16 | ### Second test
17 |
18 | ```sh
19 | /* TODO: Write a test that loops through each feed
20 | * in the allFeeds object and ensures it has a name defined
21 | * and that the name is not empty.
22 | */
23 | ```
24 | Same thing only this time with the feed's name this time.
25 |
26 | ### Solution
27 | When logging the allFeeds array we see that it's comprised by objects, each object having 3 properties: name (string), url (string) and id (integer). We can use the id to loop through the array since it is an integer starting at 0 and increments with each object. However there's no real need for that since the forEach method takes care of the looping with very little syntax.
28 |
29 | ```sh
30 | describe('RSS Feeds', () => {
31 | /* Tests to make sure that the allFeeds variable has
32 | * been defined and that it is not empty.*/
33 | it('are defined', () => {
34 | expect(allFeeds).toBeDefined();
35 | expect(allFeeds.length).not.toBe(0);
36 | });
37 |
38 | /* Test that loops through each feed
39 | * in the allFeeds object and ensures it has a URL defined
40 | * and that the URL is not empty.*/
41 | it('have a valid url', () => {
42 | allFeeds.forEach((feed) => {
43 | expect(feed.url).toBeDefined();
44 | expect(feed.url.length).toBeGreaterThan(0);
45 | });
46 | });
47 |
48 | /* Test that loops through each feed
49 | * in the allFeeds object and ensures it has a name defined
50 | * and that the name is not empty.*/
51 | it('have a valid name', () => {
52 | allFeeds.forEach((feed) => {
53 | expect(feed.name).toBeDefined();
54 | expect(feed.name.length).toBeGreaterThan(0);
55 | });
56 | });
57 | });
58 | ```
59 |
60 | ## Part 2
61 | ### First test
62 | ```sh
63 | /* TODO: Write a new test suite named "The menu" */
64 |
65 | /* TODO: Write a test that ensures the menu element is
66 | * hidden by default. You'll have to analyze the HTML and
67 | * the CSS to determine how we're performing the
68 | * hiding/showing of the menu element.
69 | */
70 | ```
71 | Alright, so let's see the HTML. Aha! it looks like the body tag has a `.menu-hidden` class by default - this must be what hides the menu. Try and remove it in the developers tools.
72 | A short glance at the app.js file and we can find the menu button functionality which assuers the assumption.
73 | I think you got this one, try and solve it.
74 | ### Second test
75 | ```sh
76 | /* TODO: Write a test that ensures the menu changes
77 | * visibility when the menu icon is clicked. This test
78 | * should have two expectations: does the menu display when
79 | * clicked and does it hide when clicked again.
80 | */
81 | ```
82 | A bit trickier. A short google reveals we can trigger a click on an element. Try and google it.
83 |
84 | ### Solution
85 | The first test is pretty easy. All we need to do is see if the `body` element has the `menu-hidden` class, and then wrap it in the `expect()` functions with hopes it'll be `true`.
86 | And there's the `click()` method which we can invoke on any elemnt to simulate a click event. So we invoke it once, expecting the `menu-hidden` class to be removed, and then click again expecting it to return.
87 | ```sh
88 | /* Test suite that checks menu functionality */
89 | describe('The menu', () => {
90 |
91 | /* Test that ensures the menu element is
92 | * hidden by default.*/
93 | it('hides the menu by default', () => {
94 | expect($('body').hasClass('menu-hidden')).toBe(true);
95 | });
96 |
97 | /* Test that ensures the menu changes
98 | * visibility when the menu icon is clicked.*/
99 | it('visibility is toggled upon click on menu icon', () => {
100 |
101 | $('.menu-icon-link').click();
102 | expect($('body').hasClass('menu-hidden')).toBe(false);
103 |
104 | $('.menu-icon-link').click();
105 | expect($('body').hasClass('menu-hidden')).toBe(true);
106 | });
107 | });
108 | ```
109 |
110 | ## part 3
111 |
112 | ```sh
113 | /* TODO: Write a new test suite named "Initial Entries" */
114 |
115 | /* TODO: Write a test that ensures when the loadFeed
116 | * function is called and completes its work, there is at least
117 | * a single .entry element within the .feed container.
118 | * Remember, loadFeed() is asynchronous so this test will require
119 | * the use of Jasmine's beforeEach and asynchronous done() function.
120 | */
121 | ```
122 | Oh no, async! I tried this one and failed several times.
123 | Here's what I know about async:
124 | It's code that runs at the end of the code-run, when the "stack" is empty. When I see async code I know it'll run last. So now all we need to do is use Jasmine's `beforeEach()` function to make sure we test it the async way.
125 | One more thing, I encourage you to look at the loadFeed function. Look at its parameters and try to learn how it works on the large scale (not the specifics).
126 |
127 | ### hint 01
128 | cb = callback
129 |
130 | ### hint 02
131 | Go back to the unit test lesson and watch the Correcting our Async Test video 2-3 times. It really helps.
132 |
133 | ### Solution
134 | Alrighty then, this one was quite difficult for me and took me several tries.
135 | First the structure of the test is the same as in the lesson's video, it's simply how the function works. Second, I realized that the loadFeed function has a `cb` parameter which is short for callback. loadFeed runs the function you enter as the callback and that's how and when I can assign a varialbe the value I need, which in this case is the length of and entries in the feed. Btw, the varialbe should be at the test scope since we want to access it later on.
136 |
137 | ### extra
138 | When you implement this, or your own solution, I encourage you to add breakpoints at every line in this test when using the developer tools. You actually see the way the browser skips async functions and goes back to them later on.
139 |
140 | ```sh
141 | /* Test suite that checks the loadFeed functionality*/
142 | describe('Initial Entries', () => {
143 |
144 | /* Test that ensures when the loadFeed
145 | * function is called and completes its work, there is at least
146 | * a single .entry element within the .feed container.*/
147 | let feedLength;
148 | beforeEach((done) => {
149 | loadFeed(0, () => {
150 | feedLength = $('.feed .entry').length;
151 | done();
152 | });
153 | });
154 |
155 | it('has at least one entry', (done) => {
156 | expect(feedLength).toBeGreaterThan(0);
157 | done();
158 | });
159 | });
160 | ```
161 |
162 | ## part 4
163 |
164 | ```sh
165 | /* TODO: Write a new test suite named "New Feed Selection" */
166 |
167 | /* TODO: Write a test that ensures when a new feed is loaded
168 | * by the loadFeed function that the content actually changes.
169 | * Remember, loadFeed() is asynchronous.
170 | */
171 | ```
172 | Pretty tough right? My reviewer actually helped me out. My initial solution gave the desired result, and was in its essence correct, however was sritten so horribly and returned different values. So I thought I passed the test in flying colors but my reviewer soon grounded me, with encouraging words, and helped me big time.
173 | Let's start with understanding what is required:
174 | 1. load a feed
175 | 2. store its value
176 | 3. load a *different* feed
177 | 4. store its value
178 | 5. compare
179 |
180 | After the last test this should be, if not easy, at least manageable. I believe you can do it! So give it an hour or so, take a tea break and back again.
181 |
182 | ### hint 01
183 | Be careful where you place your `done()` function, you want it to run and return to the test at the right moment when the second loadFeed is actually done.
184 |
185 | ### hint 02
186 | Look up how to assign an elements *content* to a variable.
187 |
188 | ### Solution
189 | Our 5 stages from before can be read like pseudo-code right?
190 | So first we know we need to have two function-scope variables to hold the different content: feedA and feedB.
191 | We then place the two loadFeed functions inside the beforeEach function since they're async.
192 | At the callback we can assign the feed's content to the relevant variable.
193 | At the end of the second loadFeed function we can run the `done()` function and return to the test, where we compare the two variables.
194 |
195 | ```sh
196 | /* Test suite that checks the feed functionality*/
197 | describe('New Feed Selection', () => {
198 |
199 | /* Test that ensures when a new feed is loaded
200 | * by the loadFeed function that the content actually changes.*/
201 | let feedA,
202 | feedB;
203 |
204 | beforeEach((done) => {
205 | loadFeed(0, () => {
206 | feedA = document.querySelector('.feed').innerHTML;
207 | });
208 |
209 | loadFeed(1, () => {
210 | feedB = document.querySelector('.feed').innerHTML;
211 | done();
212 | });
213 | });
214 |
215 | /* Check if feeds have been added to the feedList*/
216 | it('loads new feeds', (done) => {
217 | expect(feedB !== feedA).toBe(true);
218 | done();
219 | });
220 | });
221 | ```
222 | Coolio! You made it! Pour yourself a hot cup of tea with some lemon and honey, kick back and try to figure out what does that cloud look like 😎💭☁️
--------------------------------------------------------------------------------
/css/icomoon.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'icomoon';
3 | src:url('../fonts/icomoon.eot?efsk18');
4 | src:url('../fonts/icomoon.eot?#iefixefsk18') format('embedded-opentype'),
5 | url('../fonts/icomoon.woff?efsk18') format('woff'),
6 | url('../fonts/icomoon.ttf?efsk18') format('truetype'),
7 | url('../fonts/icomoon.svg?efsk18#icomoon') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | [class^="icon-"], [class*=" icon-"] {
13 | font-family: 'icomoon';
14 | speak: none;
15 | font-style: normal;
16 | font-weight: normal;
17 | font-variant: normal;
18 | text-transform: none;
19 | line-height: 1;
20 |
21 | /* Better Font Rendering =========== */
22 | -webkit-font-smoothing: antialiased;
23 | -moz-osx-font-smoothing: grayscale;
24 | }
25 |
26 | .icon-list:before {
27 | content: "\e600";
28 | }
29 |
--------------------------------------------------------------------------------
/css/normalize.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2 |
3 | /**
4 | * 1. Set default font family to sans-serif.
5 | * 2. Prevent iOS text size adjust after orientation change, without disabling
6 | * user zoom.
7 | */
8 |
9 | html {
10 | font-family: sans-serif; /* 1 */
11 | -ms-text-size-adjust: 100%; /* 2 */
12 | -webkit-text-size-adjust: 100%; /* 2 */
13 | }
14 |
15 | /**
16 | * Remove default margin.
17 | */
18 |
19 | body {
20 | margin: 0;
21 | }
22 |
23 | /* HTML5 display definitions
24 | ========================================================================== */
25 |
26 | /**
27 | * Correct `block` display not defined for any HTML5 element in IE 8/9.
28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11
29 | * and Firefox.
30 | * Correct `block` display not defined for `main` in IE 11.
31 | */
32 |
33 | article,
34 | aside,
35 | details,
36 | figcaption,
37 | figure,
38 | footer,
39 | header,
40 | hgroup,
41 | main,
42 | menu,
43 | nav,
44 | section,
45 | summary {
46 | display: block;
47 | }
48 |
49 | /**
50 | * 1. Correct `inline-block` display not defined in IE 8/9.
51 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
52 | */
53 |
54 | audio,
55 | canvas,
56 | progress,
57 | video {
58 | display: inline-block; /* 1 */
59 | vertical-align: baseline; /* 2 */
60 | }
61 |
62 | /**
63 | * Prevent modern browsers from displaying `audio` without controls.
64 | * Remove excess height in iOS 5 devices.
65 | */
66 |
67 | audio:not([controls]) {
68 | display: none;
69 | height: 0;
70 | }
71 |
72 | /**
73 | * Address `[hidden]` styling not present in IE 8/9/10.
74 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
75 | */
76 |
77 | [hidden],
78 | template {
79 | display: none;
80 | }
81 |
82 | /* Links
83 | ========================================================================== */
84 |
85 | /**
86 | * Remove the gray background color from active links in IE 10.
87 | */
88 |
89 | a {
90 | background-color: transparent;
91 | }
92 |
93 | /**
94 | * Improve readability when focused and also mouse hovered in all browsers.
95 | */
96 |
97 | a:active,
98 | a:hover {
99 | outline: 0;
100 | }
101 |
102 | /* Text-level semantics
103 | ========================================================================== */
104 |
105 | /**
106 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
107 | */
108 |
109 | abbr[title] {
110 | border-bottom: 1px dotted;
111 | }
112 |
113 | /**
114 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
115 | */
116 |
117 | b,
118 | strong {
119 | font-weight: bold;
120 | }
121 |
122 | /**
123 | * Address styling not present in Safari and Chrome.
124 | */
125 |
126 | dfn {
127 | font-style: italic;
128 | }
129 |
130 | /**
131 | * Address variable `h1` font-size and margin within `section` and `article`
132 | * contexts in Firefox 4+, Safari, and Chrome.
133 | */
134 |
135 | h1 {
136 | font-size: 2em;
137 | margin: 0.67em 0;
138 | }
139 |
140 | /**
141 | * Address styling not present in IE 8/9.
142 | */
143 |
144 | mark {
145 | background: #ff0;
146 | color: #000;
147 | }
148 |
149 | /**
150 | * Address inconsistent and variable font size in all browsers.
151 | */
152 |
153 | small {
154 | font-size: 80%;
155 | }
156 |
157 | /**
158 | * Prevent `sub` and `sup` affecting `line-height` in all browsers.
159 | */
160 |
161 | sub,
162 | sup {
163 | font-size: 75%;
164 | line-height: 0;
165 | position: relative;
166 | vertical-align: baseline;
167 | }
168 |
169 | sup {
170 | top: -0.5em;
171 | }
172 |
173 | sub {
174 | bottom: -0.25em;
175 | }
176 |
177 | /* Embedded content
178 | ========================================================================== */
179 |
180 | /**
181 | * Remove border when inside `a` element in IE 8/9/10.
182 | */
183 |
184 | img {
185 | border: 0;
186 | }
187 |
188 | /**
189 | * Correct overflow not hidden in IE 9/10/11.
190 | */
191 |
192 | svg:not(:root) {
193 | overflow: hidden;
194 | }
195 |
196 | /* Grouping content
197 | ========================================================================== */
198 |
199 | /**
200 | * Address margin not present in IE 8/9 and Safari.
201 | */
202 |
203 | figure {
204 | margin: 1em 40px;
205 | }
206 |
207 | /**
208 | * Address differences between Firefox and other browsers.
209 | */
210 |
211 | hr {
212 | -moz-box-sizing: content-box;
213 | box-sizing: content-box;
214 | height: 0;
215 | }
216 |
217 | /**
218 | * Contain overflow in all browsers.
219 | */
220 |
221 | pre {
222 | overflow: auto;
223 | }
224 |
225 | /**
226 | * Address odd `em`-unit font size rendering in all browsers.
227 | */
228 |
229 | code,
230 | kbd,
231 | pre,
232 | samp {
233 | font-family: monospace, monospace;
234 | font-size: 1em;
235 | }
236 |
237 | /* Forms
238 | ========================================================================== */
239 |
240 | /**
241 | * Known limitation: by default, Chrome and Safari on OS X allow very limited
242 | * styling of `select`, unless a `border` property is set.
243 | */
244 |
245 | /**
246 | * 1. Correct color not being inherited.
247 | * Known issue: affects color of disabled elements.
248 | * 2. Correct font properties not being inherited.
249 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
250 | */
251 |
252 | button,
253 | input,
254 | optgroup,
255 | select,
256 | textarea {
257 | color: inherit; /* 1 */
258 | font: inherit; /* 2 */
259 | margin: 0; /* 3 */
260 | }
261 |
262 | /**
263 | * Address `overflow` set to `hidden` in IE 8/9/10/11.
264 | */
265 |
266 | button {
267 | overflow: visible;
268 | }
269 |
270 | /**
271 | * Address inconsistent `text-transform` inheritance for `button` and `select`.
272 | * All other form control elements do not inherit `text-transform` values.
273 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
274 | * Correct `select` style inheritance in Firefox.
275 | */
276 |
277 | button,
278 | select {
279 | text-transform: none;
280 | }
281 |
282 | /**
283 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
284 | * and `video` controls.
285 | * 2. Correct inability to style clickable `input` types in iOS.
286 | * 3. Improve usability and consistency of cursor style between image-type
287 | * `input` and others.
288 | */
289 |
290 | button,
291 | html input[type="button"], /* 1 */
292 | input[type="reset"],
293 | input[type="submit"] {
294 | -webkit-appearance: button; /* 2 */
295 | cursor: pointer; /* 3 */
296 | }
297 |
298 | /**
299 | * Re-set default cursor for disabled elements.
300 | */
301 |
302 | button[disabled],
303 | html input[disabled] {
304 | cursor: default;
305 | }
306 |
307 | /**
308 | * Remove inner padding and border in Firefox 4+.
309 | */
310 |
311 | button::-moz-focus-inner,
312 | input::-moz-focus-inner {
313 | border: 0;
314 | padding: 0;
315 | }
316 |
317 | /**
318 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in
319 | * the UA stylesheet.
320 | */
321 |
322 | input {
323 | line-height: normal;
324 | }
325 |
326 | /**
327 | * It's recommended that you don't attempt to style these elements.
328 | * Firefox's implementation doesn't respect box-sizing, padding, or width.
329 | *
330 | * 1. Address box sizing set to `content-box` in IE 8/9/10.
331 | * 2. Remove excess padding in IE 8/9/10.
332 | */
333 |
334 | input[type="checkbox"],
335 | input[type="radio"] {
336 | box-sizing: border-box; /* 1 */
337 | padding: 0; /* 2 */
338 | }
339 |
340 | /**
341 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain
342 | * `font-size` values of the `input`, it causes the cursor style of the
343 | * decrement button to change from `default` to `text`.
344 | */
345 |
346 | input[type="number"]::-webkit-inner-spin-button,
347 | input[type="number"]::-webkit-outer-spin-button {
348 | height: auto;
349 | }
350 |
351 | /**
352 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
353 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
354 | * (include `-moz` to future-proof).
355 | */
356 |
357 | input[type="search"] {
358 | -webkit-appearance: textfield; /* 1 */
359 | -moz-box-sizing: content-box;
360 | -webkit-box-sizing: content-box; /* 2 */
361 | box-sizing: content-box;
362 | }
363 |
364 | /**
365 | * Remove inner padding and search cancel button in Safari and Chrome on OS X.
366 | * Safari (but not Chrome) clips the cancel button when the search input has
367 | * padding (and `textfield` appearance).
368 | */
369 |
370 | input[type="search"]::-webkit-search-cancel-button,
371 | input[type="search"]::-webkit-search-decoration {
372 | -webkit-appearance: none;
373 | }
374 |
375 | /**
376 | * Define consistent border, margin, and padding.
377 | */
378 |
379 | fieldset {
380 | border: 1px solid #c0c0c0;
381 | margin: 0 2px;
382 | padding: 0.35em 0.625em 0.75em;
383 | }
384 |
385 | /**
386 | * 1. Correct `color` not being inherited in IE 8/9/10/11.
387 | * 2. Remove padding so people aren't caught out if they zero out fieldsets.
388 | */
389 |
390 | legend {
391 | border: 0; /* 1 */
392 | padding: 0; /* 2 */
393 | }
394 |
395 | /**
396 | * Remove default vertical scrollbar in IE 8/9/10/11.
397 | */
398 |
399 | textarea {
400 | overflow: auto;
401 | }
402 |
403 | /**
404 | * Don't inherit the `font-weight` (applied by a rule above).
405 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
406 | */
407 |
408 | optgroup {
409 | font-weight: bold;
410 | }
411 |
412 | /* Tables
413 | ========================================================================== */
414 |
415 | /**
416 | * Remove most spacing between table cells.
417 | */
418 |
419 | table {
420 | border-collapse: collapse;
421 | border-spacing: 0;
422 | }
423 |
424 | td,
425 | th {
426 | padding: 0;
427 | }
428 |
--------------------------------------------------------------------------------
/css/style.css:
--------------------------------------------------------------------------------
1 | *,
2 | *:after,
3 | *:before: {
4 | box-sizing: inherit;
5 | }
6 |
7 | html {
8 | box-sizing: border-box;
9 | }
10 |
11 | body {
12 | color: #111;
13 | font-family: 'Roboto', sans-serif;
14 | font-weight: 300;
15 | margin: 0;
16 | }
17 |
18 | a {
19 | text-decoration: none;
20 | color: #111;
21 | }
22 |
23 | a:hover h2 {
24 | text-decoration: underline;
25 | }
26 |
27 | h1 {
28 | display: inline-block;
29 | font-weight: 100;
30 | margin: 0 0 0 0.5em;
31 | }
32 |
33 | h2 {
34 | font-weight: 400;
35 | margin: 0;
36 | }
37 |
38 | .header {
39 | background: #4caf50;
40 | color: #fff;
41 | position: fixed;
42 | top: 0;
43 | width: 100%;
44 | padding: 0.5em 1em;
45 | }
46 |
47 | .icon-list {
48 | font-size: 1.5em;
49 | color: #FFF;
50 | }
51 |
52 | .slide-menu {
53 | position: absolute;
54 | top: 3.5em;
55 | padding: 1em;
56 | background: #4caf50;
57 | height: 100%;
58 | width: 10em;
59 | transform: translate3d(0, 0, 0);
60 | transition: transform 0.2s;
61 | }
62 |
63 | .slide-menu ul {
64 | list-style: none;
65 | margin: 0;
66 | padding: 0;
67 | }
68 |
69 | .slide-menu li {
70 | padding: 0;
71 | }
72 |
73 | .slide-menu li a {
74 | color: #fff;
75 | display: block;
76 | padding: 0.5em 0;
77 | }
78 |
79 | .menu-hidden .slide-menu {
80 | transform: translate3d(-12em, 0, 0);
81 | transition: transform 0.2s;
82 | }
83 |
84 | .feed {
85 | margin: 4em 0 0;
86 | }
87 |
88 | .entry {
89 | border-bottom: 1px solid #ddd;
90 | padding: 1em;
91 | margin: 0.5em 0;
92 | }
93 |
--------------------------------------------------------------------------------
/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VitskyDs/fend-feedreader/a3fb8b51d735f75a5bdeaceb4f82b5248d7c5ad6/fonts/icomoon.eot
--------------------------------------------------------------------------------
/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Generated by IcoMoon
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VitskyDs/fend-feedreader/a3fb8b51d735f75a5bdeaceb4f82b5248d7c5ad6/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VitskyDs/fend-feedreader/a3fb8b51d735f75a5bdeaceb4f82b5248d7c5ad6/fonts/icomoon.woff
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | UdaciFeeds
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
30 |
31 |
34 |
35 |
36 |
37 |
45 |
46 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/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 proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
39 | */
40 | if (typeof window == "undefined" && typeof exports == "object") {
41 | extend(exports, jasmineInterface);
42 | } else {
43 | extend(window, jasmineInterface);
44 | }
45 |
46 | /**
47 | * ## Runner Parameters
48 | *
49 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
50 | */
51 |
52 | var queryString = new jasmine.QueryString({
53 | getWindowLocation: function() { return window.location; }
54 | });
55 |
56 | var catchingExceptions = queryString.getParam("catch");
57 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
58 |
59 | /**
60 | * ## Reporters
61 | * 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).
62 | */
63 | var htmlReporter = new jasmine.HtmlReporter({
64 | env: env,
65 | onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
66 | getContainer: function() { return document.body; },
67 | createElement: function() { return document.createElement.apply(document, arguments); },
68 | createTextNode: function() { return document.createTextNode.apply(document, arguments); },
69 | timer: new jasmine.Timer()
70 | });
71 |
72 | /**
73 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
74 | */
75 | env.addReporter(jasmineInterface.jsApiReporter);
76 | env.addReporter(htmlReporter);
77 |
78 | /**
79 | * Filter which specs will be run by matching the start of the full name against the `spec` query param.
80 | */
81 | var specFilter = new jasmine.HtmlSpecFilter({
82 | filterString: function() { return queryString.getParam("spec"); }
83 | });
84 |
85 | env.specFilter = function(spec) {
86 | return specFilter.matches(spec.getFullName());
87 | };
88 |
89 | /**
90 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
91 | */
92 | window.setTimeout = window.setTimeout;
93 | window.setInterval = window.setInterval;
94 | window.clearTimeout = window.clearTimeout;
95 | window.clearInterval = window.clearInterval;
96 |
97 | /**
98 | * ## Execution
99 | *
100 | * 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.
101 | */
102 | var currentWindowOnload = window.onload;
103 |
104 | window.onload = function() {
105 | if (currentWindowOnload) {
106 | currentWindowOnload();
107 | }
108 | htmlReporter.initialize();
109 | env.execute();
110 | };
111 |
112 | /**
113 | * Helper function for readability above.
114 | */
115 | function extend(destination, source) {
116 | for (var property in source) destination[property] = source[property];
117 | return destination;
118 | }
119 |
120 | }());
121 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/console.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2014 Pivotal Labs
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining
5 | a copy of this software and associated documentation files (the
6 | "Software"), to deal in the Software without restriction, including
7 | without limitation the rights to use, copy, modify, merge, publish,
8 | distribute, sublicense, and/or sell copies of the Software, and to
9 | permit persons to whom the Software is furnished to do so, subject to
10 | the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 | function getJasmineRequireObj() {
24 | if (typeof module !== 'undefined' && module.exports) {
25 | return exports;
26 | } else {
27 | window.jasmineRequire = window.jasmineRequire || {};
28 | return window.jasmineRequire;
29 | }
30 | }
31 |
32 | getJasmineRequireObj().console = function(jRequire, j$) {
33 | j$.ConsoleReporter = jRequire.ConsoleReporter();
34 | };
35 |
36 | getJasmineRequireObj().ConsoleReporter = function() {
37 |
38 | var noopTimer = {
39 | start: function(){},
40 | elapsed: function(){ return 0; }
41 | };
42 |
43 | function ConsoleReporter(options) {
44 | var print = options.print,
45 | showColors = options.showColors || false,
46 | onComplete = options.onComplete || function() {},
47 | timer = options.timer || noopTimer,
48 | specCount,
49 | failureCount,
50 | failedSpecs = [],
51 | pendingCount,
52 | ansi = {
53 | green: '\x1B[32m',
54 | red: '\x1B[31m',
55 | yellow: '\x1B[33m',
56 | none: '\x1B[0m'
57 | },
58 | failedSuites = [];
59 |
60 | print('ConsoleReporter is deprecated and will be removed in a future version.');
61 |
62 | this.jasmineStarted = function() {
63 | specCount = 0;
64 | failureCount = 0;
65 | pendingCount = 0;
66 | print('Started');
67 | printNewline();
68 | timer.start();
69 | };
70 |
71 | this.jasmineDone = function() {
72 | printNewline();
73 | for (var i = 0; i < failedSpecs.length; i++) {
74 | specFailureDetails(failedSpecs[i]);
75 | }
76 |
77 | if(specCount > 0) {
78 | printNewline();
79 |
80 | var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
81 | failureCount + ' ' + plural('failure', failureCount);
82 |
83 | if (pendingCount) {
84 | specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
85 | }
86 |
87 | print(specCounts);
88 | } else {
89 | print('No specs found');
90 | }
91 |
92 | printNewline();
93 | var seconds = timer.elapsed() / 1000;
94 | print('Finished in ' + seconds + ' ' + plural('second', seconds));
95 | printNewline();
96 |
97 | for(i = 0; i < failedSuites.length; i++) {
98 | suiteFailureDetails(failedSuites[i]);
99 | }
100 |
101 | onComplete(failureCount === 0);
102 | };
103 |
104 | this.specDone = function(result) {
105 | specCount++;
106 |
107 | if (result.status == 'pending') {
108 | pendingCount++;
109 | print(colored('yellow', '*'));
110 | return;
111 | }
112 |
113 | if (result.status == 'passed') {
114 | print(colored('green', '.'));
115 | return;
116 | }
117 |
118 | if (result.status == 'failed') {
119 | failureCount++;
120 | failedSpecs.push(result);
121 | print(colored('red', 'F'));
122 | }
123 | };
124 |
125 | this.suiteDone = function(result) {
126 | if (result.failedExpectations && result.failedExpectations.length > 0) {
127 | failureCount++;
128 | failedSuites.push(result);
129 | }
130 | };
131 |
132 | return this;
133 |
134 | function printNewline() {
135 | print('\n');
136 | }
137 |
138 | function colored(color, str) {
139 | return showColors ? (ansi[color] + str + ansi.none) : str;
140 | }
141 |
142 | function plural(str, count) {
143 | return count == 1 ? str : str + 's';
144 | }
145 |
146 | function repeat(thing, times) {
147 | var arr = [];
148 | for (var i = 0; i < times; i++) {
149 | arr.push(thing);
150 | }
151 | return arr;
152 | }
153 |
154 | function indent(str, spaces) {
155 | var lines = (str || '').split('\n');
156 | var newArr = [];
157 | for (var i = 0; i < lines.length; i++) {
158 | newArr.push(repeat(' ', spaces).join('') + lines[i]);
159 | }
160 | return newArr.join('\n');
161 | }
162 |
163 | function specFailureDetails(result) {
164 | printNewline();
165 | print(result.fullName);
166 |
167 | for (var i = 0; i < result.failedExpectations.length; i++) {
168 | var failedExpectation = result.failedExpectations[i];
169 | printNewline();
170 | print(indent(failedExpectation.message, 2));
171 | print(indent(failedExpectation.stack, 2));
172 | }
173 |
174 | printNewline();
175 | }
176 |
177 | function suiteFailureDetails(result) {
178 | for (var i = 0; i < result.failedExpectations.length; i++) {
179 | printNewline();
180 | print(colored('red', 'An error was thrown in an afterAll'));
181 | printNewline();
182 | print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
183 |
184 | }
185 | printNewline();
186 | }
187 | }
188 |
189 | return ConsoleReporter;
190 | };
191 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/jasmine-html.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2014 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 | timer = options.timer || noopTimer,
44 | results = [],
45 | specsExecuted = 0,
46 | failureCount = 0,
47 | pendingSpecCount = 0,
48 | htmlReporterMain,
49 | symbols,
50 | failedSuites = [];
51 |
52 | this.initialize = function() {
53 | clearPrior();
54 | htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
55 | createDom('div', {className: 'banner'},
56 | createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
57 | createDom('span', {className: 'version'}, j$.version)
58 | ),
59 | createDom('ul', {className: 'symbol-summary'}),
60 | createDom('div', {className: 'alert'}),
61 | createDom('div', {className: 'results'},
62 | createDom('div', {className: 'failures'})
63 | )
64 | );
65 | getContainer().appendChild(htmlReporterMain);
66 |
67 | symbols = find('.symbol-summary');
68 | };
69 |
70 | var totalSpecsDefined;
71 | this.jasmineStarted = function(options) {
72 | totalSpecsDefined = options.totalSpecsDefined || 0;
73 | timer.start();
74 | };
75 |
76 | var summary = createDom('div', {className: 'summary'});
77 |
78 | var topResults = new j$.ResultsNode({}, '', null),
79 | currentParent = topResults;
80 |
81 | this.suiteStarted = function(result) {
82 | currentParent.addChild(result, 'suite');
83 | currentParent = currentParent.last();
84 | };
85 |
86 | this.suiteDone = function(result) {
87 | if (result.status == 'failed') {
88 | failedSuites.push(result);
89 | }
90 |
91 | if (currentParent == topResults) {
92 | return;
93 | }
94 |
95 | currentParent = currentParent.parent;
96 | };
97 |
98 | this.specStarted = function(result) {
99 | currentParent.addChild(result, 'spec');
100 | };
101 |
102 | var failures = [];
103 | this.specDone = function(result) {
104 | if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
105 | console.error('Spec \'' + result.fullName + '\' has no expectations.');
106 | }
107 |
108 | if (result.status != 'disabled') {
109 | specsExecuted++;
110 | }
111 |
112 | symbols.appendChild(createDom('li', {
113 | className: noExpectations(result) ? 'empty' : result.status,
114 | id: 'spec_' + result.id,
115 | title: result.fullName
116 | }
117 | ));
118 |
119 | if (result.status == 'failed') {
120 | failureCount++;
121 |
122 | var failure =
123 | createDom('div', {className: 'spec-detail failed'},
124 | createDom('div', {className: 'description'},
125 | createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
126 | ),
127 | createDom('div', {className: 'messages'})
128 | );
129 | var messages = failure.childNodes[1];
130 |
131 | for (var i = 0; i < result.failedExpectations.length; i++) {
132 | var expectation = result.failedExpectations[i];
133 | messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
134 | messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
135 | }
136 |
137 | failures.push(failure);
138 | }
139 |
140 | if (result.status == 'pending') {
141 | pendingSpecCount++;
142 | }
143 | };
144 |
145 | this.jasmineDone = function() {
146 | var banner = find('.banner');
147 | banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
148 |
149 | var alert = find('.alert');
150 |
151 | alert.appendChild(createDom('span', { className: 'exceptions' },
152 | createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
153 | createDom('input', {
154 | className: 'raise',
155 | id: 'raise-exceptions',
156 | type: 'checkbox'
157 | })
158 | ));
159 | var checkbox = find('#raise-exceptions');
160 |
161 | checkbox.checked = !env.catchingExceptions();
162 | checkbox.onclick = onRaiseExceptionsClick;
163 |
164 | if (specsExecuted < totalSpecsDefined) {
165 | var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
166 | alert.appendChild(
167 | createDom('span', {className: 'bar skipped'},
168 | createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
169 | )
170 | );
171 | }
172 | var statusBarMessage = '';
173 | var statusBarClassName = 'bar ';
174 |
175 | if (totalSpecsDefined > 0) {
176 | statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
177 | if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
178 | statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
179 | } else {
180 | statusBarClassName += 'skipped';
181 | statusBarMessage += 'No specs found';
182 | }
183 |
184 | alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
185 |
186 | for(i = 0; i < failedSuites.length; i++) {
187 | var failedSuite = failedSuites[i];
188 | for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
189 | var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
190 | var errorBarClassName = 'bar errored';
191 | alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
192 | }
193 | }
194 |
195 | var results = find('.results');
196 | results.appendChild(summary);
197 |
198 | summaryList(topResults, summary);
199 |
200 | function summaryList(resultsTree, domParent) {
201 | var specListNode;
202 | for (var i = 0; i < resultsTree.children.length; i++) {
203 | var resultNode = resultsTree.children[i];
204 | if (resultNode.type == 'suite') {
205 | var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
206 | createDom('li', {className: 'suite-detail'},
207 | createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
208 | )
209 | );
210 |
211 | summaryList(resultNode, suiteListNode);
212 | domParent.appendChild(suiteListNode);
213 | }
214 | if (resultNode.type == 'spec') {
215 | if (domParent.getAttribute('class') != 'specs') {
216 | specListNode = createDom('ul', {className: 'specs'});
217 | domParent.appendChild(specListNode);
218 | }
219 | var specDescription = resultNode.result.description;
220 | if(noExpectations(resultNode.result)) {
221 | specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
222 | }
223 | specListNode.appendChild(
224 | createDom('li', {
225 | className: resultNode.result.status,
226 | id: 'spec-' + resultNode.result.id
227 | },
228 | createDom('a', {href: specHref(resultNode.result)}, specDescription)
229 | )
230 | );
231 | }
232 | }
233 | }
234 |
235 | if (failures.length) {
236 | alert.appendChild(
237 | createDom('span', {className: 'menu bar spec-list'},
238 | createDom('span', {}, 'Spec List | '),
239 | createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
240 | alert.appendChild(
241 | createDom('span', {className: 'menu bar failure-list'},
242 | createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
243 | createDom('span', {}, ' | Failures ')));
244 |
245 | find('.failures-menu').onclick = function() {
246 | setMenuModeTo('failure-list');
247 | };
248 | find('.spec-list-menu').onclick = function() {
249 | setMenuModeTo('spec-list');
250 | };
251 |
252 | setMenuModeTo('failure-list');
253 |
254 | var failureNode = find('.failures');
255 | for (var i = 0; i < failures.length; i++) {
256 | failureNode.appendChild(failures[i]);
257 | }
258 | }
259 | };
260 |
261 | return this;
262 |
263 | function find(selector) {
264 | return getContainer().querySelector('.jasmine_html-reporter ' + selector);
265 | }
266 |
267 | function clearPrior() {
268 | // return the reporter
269 | var oldReporter = find('');
270 |
271 | if(oldReporter) {
272 | getContainer().removeChild(oldReporter);
273 | }
274 | }
275 |
276 | function createDom(type, attrs, childrenVarArgs) {
277 | var el = createElement(type);
278 |
279 | for (var i = 2; i < arguments.length; i++) {
280 | var child = arguments[i];
281 |
282 | if (typeof child === 'string') {
283 | el.appendChild(createTextNode(child));
284 | } else {
285 | if (child) {
286 | el.appendChild(child);
287 | }
288 | }
289 | }
290 |
291 | for (var attr in attrs) {
292 | if (attr == 'className') {
293 | el[attr] = attrs[attr];
294 | } else {
295 | el.setAttribute(attr, attrs[attr]);
296 | }
297 | }
298 |
299 | return el;
300 | }
301 |
302 | function pluralize(singular, count) {
303 | var word = (count == 1 ? singular : singular + 's');
304 |
305 | return '' + count + ' ' + word;
306 | }
307 |
308 | function specHref(result) {
309 | return '?spec=' + encodeURIComponent(result.fullName);
310 | }
311 |
312 | function setMenuModeTo(mode) {
313 | htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
314 | }
315 |
316 | function noExpectations(result) {
317 | return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
318 | result.status === 'passed';
319 | }
320 | }
321 |
322 | return HtmlReporter;
323 | };
324 |
325 | jasmineRequire.HtmlSpecFilter = function() {
326 | function HtmlSpecFilter(options) {
327 | var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
328 | var filterPattern = new RegExp(filterString);
329 |
330 | this.matches = function(specName) {
331 | return filterPattern.test(specName);
332 | };
333 | }
334 |
335 | return HtmlSpecFilter;
336 | };
337 |
338 | jasmineRequire.ResultsNode = function() {
339 | function ResultsNode(result, type, parent) {
340 | this.result = result;
341 | this.type = type;
342 | this.parent = parent;
343 |
344 | this.children = [];
345 |
346 | this.addChild = function(result, type) {
347 | this.children.push(new ResultsNode(result, type, this));
348 | };
349 |
350 | this.last = function() {
351 | return this.children[this.children.length - 1];
352 | };
353 | }
354 |
355 | return ResultsNode;
356 | };
357 |
358 | jasmineRequire.QueryString = function() {
359 | function QueryString(options) {
360 |
361 | this.setParam = function(key, value) {
362 | var paramMap = queryStringToParamMap();
363 | paramMap[key] = value;
364 | options.getWindowLocation().search = toQueryString(paramMap);
365 | };
366 |
367 | this.getParam = function(key) {
368 | return queryStringToParamMap()[key];
369 | };
370 |
371 | return this;
372 |
373 | function toQueryString(paramMap) {
374 | var qStrPairs = [];
375 | for (var prop in paramMap) {
376 | qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
377 | }
378 | return '?' + qStrPairs.join('&');
379 | }
380 |
381 | function queryStringToParamMap() {
382 | var paramStr = options.getWindowLocation().search.substring(1),
383 | params = [],
384 | paramMap = {};
385 |
386 | if (paramStr.length > 0) {
387 | params = paramStr.split('&');
388 | for (var i = 0; i < params.length; i++) {
389 | var p = params[i].split('=');
390 | var value = decodeURIComponent(p[1]);
391 | if (value === 'true' || value === 'false') {
392 | value = JSON.parse(value);
393 | }
394 | paramMap[decodeURIComponent(p[0])] = value;
395 | }
396 | }
397 |
398 | return paramMap;
399 | }
400 |
401 | }
402 |
403 | return QueryString;
404 | };
405 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/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+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPI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m9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0iTSA2MDcuNDY1LDkwMy40NDUgNDk4Ljg1NSwxMDUyLjk3IDUyOS4zMiwxMDc1LjEgNjM3LjkzLDkyNS41NjYgNjA3LjQ2NSw5MDMuNDQ1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDM4MC42ODgsNjIyLjEyOSAtMTEuNjI2LDM1LjgwMSAxNzUuNzU4LDU3LjA5IDExLjYyMSwtMzUuODAxIC0xNzUuNzUzLC01Ny4wOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDU0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+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 .banner .duration { position: absolute; right: 14px; top: 6px; }
12 | .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; }
13 | .jasmine_html-reporter .version { color: #aaa; }
14 | .jasmine_html-reporter .banner { margin-top: 14px; }
15 | .jasmine_html-reporter .duration { color: #aaa; float: right; }
16 | .jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
17 | .jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
18 | .jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; }
19 | .jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; }
20 | .jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; }
21 | .jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
22 | .jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; }
23 | .jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
24 | .jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; }
25 | .jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
26 | .jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; }
27 | .jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; }
28 | .jasmine_html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
29 | .jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
30 | .jasmine_html-reporter .bar.failed { background-color: #ca3a11; }
31 | .jasmine_html-reporter .bar.passed { background-color: #007069; }
32 | .jasmine_html-reporter .bar.skipped { background-color: #bababa; }
33 | .jasmine_html-reporter .bar.errored { background-color: #ca3a11; }
34 | .jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaa; }
35 | .jasmine_html-reporter .bar.menu a { color: #333; }
36 | .jasmine_html-reporter .bar a { color: white; }
37 | .jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; }
38 | .jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; }
39 | .jasmine_html-reporter .running-alert { background-color: #666; }
40 | .jasmine_html-reporter .results { margin-top: 14px; }
41 | .jasmine_html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
42 | .jasmine_html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
43 | .jasmine_html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
44 | .jasmine_html-reporter.showDetails .summary { display: none; }
45 | .jasmine_html-reporter.showDetails #details { display: block; }
46 | .jasmine_html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
47 | .jasmine_html-reporter .summary { margin-top: 14px; }
48 | .jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
49 | .jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
50 | .jasmine_html-reporter .summary li.passed a { color: #007069; }
51 | .jasmine_html-reporter .summary li.failed a { color: #ca3a11; }
52 | .jasmine_html-reporter .summary li.empty a { color: #ba9d37; }
53 | .jasmine_html-reporter .summary li.pending a { color: #ba9d37; }
54 | .jasmine_html-reporter .description + .suite { margin-top: 0; }
55 | .jasmine_html-reporter .suite { margin-top: 14px; }
56 | .jasmine_html-reporter .suite a { color: #333; }
57 | .jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; }
58 | .jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; }
59 | .jasmine_html-reporter .failures .spec-detail .description a { color: white; }
60 | .jasmine_html-reporter .result-message { padding-top: 14px; color: #333; white-space: pre; }
61 | .jasmine_html-reporter .result-message span.result { display: block; }
62 | .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; }
63 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/jasmine.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2008-2014 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 | getJasmineRequireObj = (function (jasmineGlobal) {
24 | var jasmineRequire;
25 |
26 | if (typeof module !== 'undefined' && module.exports) {
27 | jasmineGlobal = global;
28 | jasmineRequire = exports;
29 | } else {
30 | jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {};
31 | }
32 |
33 | function getJasmineRequire() {
34 | return jasmineRequire;
35 | }
36 |
37 | getJasmineRequire().core = function(jRequire) {
38 | var j$ = {};
39 |
40 | jRequire.base(j$, jasmineGlobal);
41 | j$.util = jRequire.util();
42 | j$.Any = jRequire.Any();
43 | j$.CallTracker = jRequire.CallTracker();
44 | j$.MockDate = jRequire.MockDate();
45 | j$.Clock = jRequire.Clock();
46 | j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
47 | j$.Env = jRequire.Env(j$);
48 | j$.ExceptionFormatter = jRequire.ExceptionFormatter();
49 | j$.Expectation = jRequire.Expectation();
50 | j$.buildExpectationResult = jRequire.buildExpectationResult();
51 | j$.JsApiReporter = jRequire.JsApiReporter();
52 | j$.matchersUtil = jRequire.matchersUtil(j$);
53 | j$.ObjectContaining = jRequire.ObjectContaining(j$);
54 | j$.pp = jRequire.pp(j$);
55 | j$.QueueRunner = jRequire.QueueRunner(j$);
56 | j$.ReportDispatcher = jRequire.ReportDispatcher();
57 | j$.Spec = jRequire.Spec(j$);
58 | j$.SpyRegistry = jRequire.SpyRegistry(j$);
59 | j$.SpyStrategy = jRequire.SpyStrategy();
60 | j$.Suite = jRequire.Suite();
61 | j$.Timer = jRequire.Timer();
62 | j$.version = jRequire.version();
63 |
64 | j$.matchers = jRequire.requireMatchers(jRequire, j$);
65 |
66 | return j$;
67 | };
68 |
69 | return getJasmineRequire;
70 | })(this);
71 |
72 | getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
73 | var availableMatchers = [
74 | 'toBe',
75 | 'toBeCloseTo',
76 | 'toBeDefined',
77 | 'toBeFalsy',
78 | 'toBeGreaterThan',
79 | 'toBeLessThan',
80 | 'toBeNaN',
81 | 'toBeNull',
82 | 'toBeTruthy',
83 | 'toBeUndefined',
84 | 'toContain',
85 | 'toEqual',
86 | 'toHaveBeenCalled',
87 | 'toHaveBeenCalledWith',
88 | 'toMatch',
89 | 'toThrow',
90 | 'toThrowError'
91 | ],
92 | matchers = {};
93 |
94 | for (var i = 0; i < availableMatchers.length; i++) {
95 | var name = availableMatchers[i];
96 | matchers[name] = jRequire[name](j$);
97 | }
98 |
99 | return matchers;
100 | };
101 |
102 | getJasmineRequireObj().base = function(j$, jasmineGlobal) {
103 | j$.unimplementedMethod_ = function() {
104 | throw new Error('unimplemented method');
105 | };
106 |
107 | j$.MAX_PRETTY_PRINT_DEPTH = 40;
108 | j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100;
109 | j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
110 |
111 | j$.getGlobal = function() {
112 | return jasmineGlobal;
113 | };
114 |
115 | j$.getEnv = function(options) {
116 | var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
117 | //jasmine. singletons in here (setTimeout blah blah).
118 | return env;
119 | };
120 |
121 | j$.isArray_ = function(value) {
122 | return j$.isA_('Array', value);
123 | };
124 |
125 | j$.isString_ = function(value) {
126 | return j$.isA_('String', value);
127 | };
128 |
129 | j$.isNumber_ = function(value) {
130 | return j$.isA_('Number', value);
131 | };
132 |
133 | j$.isA_ = function(typeName, value) {
134 | return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
135 | };
136 |
137 | j$.isDomNode = function(obj) {
138 | return obj.nodeType > 0;
139 | };
140 |
141 | j$.any = function(clazz) {
142 | return new j$.Any(clazz);
143 | };
144 |
145 | j$.objectContaining = function(sample) {
146 | return new j$.ObjectContaining(sample);
147 | };
148 |
149 | j$.createSpy = function(name, originalFn) {
150 |
151 | var spyStrategy = new j$.SpyStrategy({
152 | name: name,
153 | fn: originalFn,
154 | getSpy: function() { return spy; }
155 | }),
156 | callTracker = new j$.CallTracker(),
157 | spy = function() {
158 | var callData = {
159 | object: this,
160 | args: Array.prototype.slice.apply(arguments)
161 | };
162 |
163 | callTracker.track(callData);
164 | var returnValue = spyStrategy.exec.apply(this, arguments);
165 | callData.returnValue = returnValue;
166 |
167 | return returnValue;
168 | };
169 |
170 | for (var prop in originalFn) {
171 | if (prop === 'and' || prop === 'calls') {
172 | throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon');
173 | }
174 |
175 | spy[prop] = originalFn[prop];
176 | }
177 |
178 | spy.and = spyStrategy;
179 | spy.calls = callTracker;
180 |
181 | return spy;
182 | };
183 |
184 | j$.isSpy = function(putativeSpy) {
185 | if (!putativeSpy) {
186 | return false;
187 | }
188 | return putativeSpy.and instanceof j$.SpyStrategy &&
189 | putativeSpy.calls instanceof j$.CallTracker;
190 | };
191 |
192 | j$.createSpyObj = function(baseName, methodNames) {
193 | if (!j$.isArray_(methodNames) || methodNames.length === 0) {
194 | throw 'createSpyObj requires a non-empty array of method names to create spies for';
195 | }
196 | var obj = {};
197 | for (var i = 0; i < methodNames.length; i++) {
198 | obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
199 | }
200 | return obj;
201 | };
202 | };
203 |
204 | getJasmineRequireObj().util = function() {
205 |
206 | var util = {};
207 |
208 | util.inherit = function(childClass, parentClass) {
209 | var Subclass = function() {
210 | };
211 | Subclass.prototype = parentClass.prototype;
212 | childClass.prototype = new Subclass();
213 | };
214 |
215 | util.htmlEscape = function(str) {
216 | if (!str) {
217 | return str;
218 | }
219 | return str.replace(/&/g, '&')
220 | .replace(//g, '>');
222 | };
223 |
224 | util.argsToArray = function(args) {
225 | var arrayOfArgs = [];
226 | for (var i = 0; i < args.length; i++) {
227 | arrayOfArgs.push(args[i]);
228 | }
229 | return arrayOfArgs;
230 | };
231 |
232 | util.isUndefined = function(obj) {
233 | return obj === void 0;
234 | };
235 |
236 | util.arrayContains = function(array, search) {
237 | var i = array.length;
238 | while (i--) {
239 | if (array[i] === search) {
240 | return true;
241 | }
242 | }
243 | return false;
244 | };
245 |
246 | util.clone = function(obj) {
247 | if (Object.prototype.toString.apply(obj) === '[object Array]') {
248 | return obj.slice();
249 | }
250 |
251 | var cloned = {};
252 | for (var prop in obj) {
253 | if (obj.hasOwnProperty(prop)) {
254 | cloned[prop] = obj[prop];
255 | }
256 | }
257 |
258 | return cloned;
259 | };
260 |
261 | return util;
262 | };
263 |
264 | getJasmineRequireObj().Spec = function(j$) {
265 | function Spec(attrs) {
266 | this.expectationFactory = attrs.expectationFactory;
267 | this.resultCallback = attrs.resultCallback || function() {};
268 | this.id = attrs.id;
269 | this.description = attrs.description || '';
270 | this.queueableFn = attrs.queueableFn;
271 | this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; };
272 | this.userContext = attrs.userContext || function() { return {}; };
273 | this.onStart = attrs.onStart || function() {};
274 | this.getSpecName = attrs.getSpecName || function() { return ''; };
275 | this.expectationResultFactory = attrs.expectationResultFactory || function() { };
276 | this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
277 | this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
278 |
279 | if (!this.queueableFn.fn) {
280 | this.pend();
281 | }
282 |
283 | this.result = {
284 | id: this.id,
285 | description: this.description,
286 | fullName: this.getFullName(),
287 | failedExpectations: [],
288 | passedExpectations: []
289 | };
290 | }
291 |
292 | Spec.prototype.addExpectationResult = function(passed, data) {
293 | var expectationResult = this.expectationResultFactory(data);
294 | if (passed) {
295 | this.result.passedExpectations.push(expectationResult);
296 | } else {
297 | this.result.failedExpectations.push(expectationResult);
298 | }
299 | };
300 |
301 | Spec.prototype.expect = function(actual) {
302 | return this.expectationFactory(actual, this);
303 | };
304 |
305 | Spec.prototype.execute = function(onComplete) {
306 | var self = this;
307 |
308 | this.onStart(this);
309 |
310 | if (this.markedPending || this.disabled) {
311 | complete();
312 | return;
313 | }
314 |
315 | var fns = this.beforeAndAfterFns();
316 | var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters);
317 |
318 | this.queueRunnerFactory({
319 | queueableFns: allFns,
320 | onException: function() { self.onException.apply(self, arguments); },
321 | onComplete: complete,
322 | userContext: this.userContext()
323 | });
324 |
325 | function complete() {
326 | self.result.status = self.status();
327 | self.resultCallback(self.result);
328 |
329 | if (onComplete) {
330 | onComplete();
331 | }
332 | }
333 | };
334 |
335 | Spec.prototype.onException = function onException(e) {
336 | if (Spec.isPendingSpecException(e)) {
337 | this.pend();
338 | return;
339 | }
340 |
341 | this.addExpectationResult(false, {
342 | matcherName: '',
343 | passed: false,
344 | expected: '',
345 | actual: '',
346 | error: e
347 | });
348 | };
349 |
350 | Spec.prototype.disable = function() {
351 | this.disabled = true;
352 | };
353 |
354 | Spec.prototype.pend = function() {
355 | this.markedPending = true;
356 | };
357 |
358 | Spec.prototype.status = function() {
359 | if (this.disabled) {
360 | return 'disabled';
361 | }
362 |
363 | if (this.markedPending) {
364 | return 'pending';
365 | }
366 |
367 | if (this.result.failedExpectations.length > 0) {
368 | return 'failed';
369 | } else {
370 | return 'passed';
371 | }
372 | };
373 |
374 | Spec.prototype.isExecutable = function() {
375 | return !this.disabled && !this.markedPending;
376 | };
377 |
378 | Spec.prototype.getFullName = function() {
379 | return this.getSpecName(this);
380 | };
381 |
382 | Spec.pendingSpecExceptionMessage = '=> marked Pending';
383 |
384 | Spec.isPendingSpecException = function(e) {
385 | return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1);
386 | };
387 |
388 | return Spec;
389 | };
390 |
391 | if (typeof window == void 0 && typeof exports == 'object') {
392 | exports.Spec = jasmineRequire.Spec;
393 | }
394 |
395 | getJasmineRequireObj().Env = function(j$) {
396 | function Env(options) {
397 | options = options || {};
398 |
399 | var self = this;
400 | var global = options.global || j$.getGlobal();
401 |
402 | var totalSpecsDefined = 0;
403 |
404 | var catchExceptions = true;
405 |
406 | var realSetTimeout = j$.getGlobal().setTimeout;
407 | var realClearTimeout = j$.getGlobal().clearTimeout;
408 | this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler(), new j$.MockDate(global));
409 |
410 | var runnableLookupTable = {};
411 | var runnableResources = {};
412 |
413 | var currentSpec = null;
414 | var currentlyExecutingSuites = [];
415 | var currentDeclarationSuite = null;
416 |
417 | var currentSuite = function() {
418 | return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
419 | };
420 |
421 | var currentRunnable = function() {
422 | return currentSpec || currentSuite();
423 | };
424 |
425 | var reporter = new j$.ReportDispatcher([
426 | 'jasmineStarted',
427 | 'jasmineDone',
428 | 'suiteStarted',
429 | 'suiteDone',
430 | 'specStarted',
431 | 'specDone'
432 | ]);
433 |
434 | this.specFilter = function() {
435 | return true;
436 | };
437 |
438 | this.addCustomEqualityTester = function(tester) {
439 | if(!currentRunnable()) {
440 | throw new Error('Custom Equalities must be added in a before function or a spec');
441 | }
442 | runnableResources[currentRunnable().id].customEqualityTesters.push(tester);
443 | };
444 |
445 | this.addMatchers = function(matchersToAdd) {
446 | if(!currentRunnable()) {
447 | throw new Error('Matchers must be added in a before function or a spec');
448 | }
449 | var customMatchers = runnableResources[currentRunnable().id].customMatchers;
450 | for (var matcherName in matchersToAdd) {
451 | customMatchers[matcherName] = matchersToAdd[matcherName];
452 | }
453 | };
454 |
455 | j$.Expectation.addCoreMatchers(j$.matchers);
456 |
457 | var nextSpecId = 0;
458 | var getNextSpecId = function() {
459 | return 'spec' + nextSpecId++;
460 | };
461 |
462 | var nextSuiteId = 0;
463 | var getNextSuiteId = function() {
464 | return 'suite' + nextSuiteId++;
465 | };
466 |
467 | var expectationFactory = function(actual, spec) {
468 | return j$.Expectation.Factory({
469 | util: j$.matchersUtil,
470 | customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
471 | customMatchers: runnableResources[spec.id].customMatchers,
472 | actual: actual,
473 | addExpectationResult: addExpectationResult
474 | });
475 |
476 | function addExpectationResult(passed, result) {
477 | return spec.addExpectationResult(passed, result);
478 | }
479 | };
480 |
481 | var defaultResourcesForRunnable = function(id, parentRunnableId) {
482 | var resources = {spies: [], customEqualityTesters: [], customMatchers: {}};
483 |
484 | if(runnableResources[parentRunnableId]){
485 | resources.customEqualityTesters = j$.util.clone(runnableResources[parentRunnableId].customEqualityTesters);
486 | resources.customMatchers = j$.util.clone(runnableResources[parentRunnableId].customMatchers);
487 | }
488 |
489 | runnableResources[id] = resources;
490 | };
491 |
492 | var clearResourcesForRunnable = function(id) {
493 | spyRegistry.clearSpies();
494 | delete runnableResources[id];
495 | };
496 |
497 | var beforeAndAfterFns = function(suite, runnablesExplictlySet) {
498 | return function() {
499 | var befores = [],
500 | afters = [],
501 | beforeAlls = [],
502 | afterAlls = [];
503 |
504 | while(suite) {
505 | befores = befores.concat(suite.beforeFns);
506 | afters = afters.concat(suite.afterFns);
507 |
508 | if (runnablesExplictlySet()) {
509 | beforeAlls = beforeAlls.concat(suite.beforeAllFns);
510 | afterAlls = afterAlls.concat(suite.afterAllFns);
511 | }
512 |
513 | suite = suite.parentSuite;
514 | }
515 | return {
516 | befores: beforeAlls.reverse().concat(befores.reverse()),
517 | afters: afters.concat(afterAlls)
518 | };
519 | };
520 | };
521 |
522 | var getSpecName = function(spec, suite) {
523 | return suite.getFullName() + ' ' + spec.description;
524 | };
525 |
526 | // TODO: we may just be able to pass in the fn instead of wrapping here
527 | var buildExpectationResult = j$.buildExpectationResult,
528 | exceptionFormatter = new j$.ExceptionFormatter(),
529 | expectationResultFactory = function(attrs) {
530 | attrs.messageFormatter = exceptionFormatter.message;
531 | attrs.stackFormatter = exceptionFormatter.stack;
532 |
533 | return buildExpectationResult(attrs);
534 | };
535 |
536 | // TODO: fix this naming, and here's where the value comes in
537 | this.catchExceptions = function(value) {
538 | catchExceptions = !!value;
539 | return catchExceptions;
540 | };
541 |
542 | this.catchingExceptions = function() {
543 | return catchExceptions;
544 | };
545 |
546 | var maximumSpecCallbackDepth = 20;
547 | var currentSpecCallbackDepth = 0;
548 |
549 | function clearStack(fn) {
550 | currentSpecCallbackDepth++;
551 | if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) {
552 | currentSpecCallbackDepth = 0;
553 | realSetTimeout(fn, 0);
554 | } else {
555 | fn();
556 | }
557 | }
558 |
559 | var catchException = function(e) {
560 | return j$.Spec.isPendingSpecException(e) || catchExceptions;
561 | };
562 |
563 | var queueRunnerFactory = function(options) {
564 | options.catchException = catchException;
565 | options.clearStack = options.clearStack || clearStack;
566 | options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
567 | options.fail = self.fail;
568 |
569 | new j$.QueueRunner(options).execute();
570 | };
571 |
572 | var topSuite = new j$.Suite({
573 | env: this,
574 | id: getNextSuiteId(),
575 | description: 'Jasmine__TopLevel__Suite',
576 | queueRunner: queueRunnerFactory,
577 | onStart: function(suite) {
578 | reporter.suiteStarted(suite.result);
579 | },
580 | resultCallback: function(attrs) {
581 | reporter.suiteDone(attrs);
582 | }
583 | });
584 | runnableLookupTable[topSuite.id] = topSuite;
585 | defaultResourcesForRunnable(topSuite.id);
586 | currentDeclarationSuite = topSuite;
587 |
588 | this.topSuite = function() {
589 | return topSuite;
590 | };
591 |
592 | this.execute = function(runnablesToRun) {
593 | if(runnablesToRun) {
594 | runnablesExplictlySet = true;
595 | } else if (focusedRunnables.length) {
596 | runnablesExplictlySet = true;
597 | runnablesToRun = focusedRunnables;
598 | } else {
599 | runnablesToRun = [topSuite.id];
600 | }
601 |
602 | var allFns = [];
603 | for(var i = 0; i < runnablesToRun.length; i++) {
604 | var runnable = runnableLookupTable[runnablesToRun[i]];
605 | allFns.push((function(runnable) { return { fn: function(done) { runnable.execute(done); } }; })(runnable));
606 | }
607 |
608 | reporter.jasmineStarted({
609 | totalSpecsDefined: totalSpecsDefined
610 | });
611 |
612 | queueRunnerFactory({queueableFns: allFns, onComplete: reporter.jasmineDone});
613 | };
614 |
615 | this.addReporter = function(reporterToAdd) {
616 | reporter.addReporter(reporterToAdd);
617 | };
618 |
619 | var spyRegistry = new j$.SpyRegistry({currentSpies: function() {
620 | if(!currentRunnable()) {
621 | throw new Error('Spies must be created in a before function or a spec');
622 | }
623 | return runnableResources[currentRunnable().id].spies;
624 | }});
625 |
626 | this.spyOn = function() {
627 | return spyRegistry.spyOn.apply(spyRegistry, arguments);
628 | };
629 |
630 | var suiteFactory = function(description) {
631 | var suite = new j$.Suite({
632 | env: self,
633 | id: getNextSuiteId(),
634 | description: description,
635 | parentSuite: currentDeclarationSuite,
636 | queueRunner: queueRunnerFactory,
637 | onStart: suiteStarted,
638 | expectationFactory: expectationFactory,
639 | expectationResultFactory: expectationResultFactory,
640 | resultCallback: function(attrs) {
641 | if (!suite.disabled) {
642 | clearResourcesForRunnable(suite.id);
643 | currentlyExecutingSuites.pop();
644 | }
645 | reporter.suiteDone(attrs);
646 | }
647 | });
648 |
649 | runnableLookupTable[suite.id] = suite;
650 | return suite;
651 |
652 | function suiteStarted(suite) {
653 | currentlyExecutingSuites.push(suite);
654 | defaultResourcesForRunnable(suite.id, suite.parentSuite.id);
655 | reporter.suiteStarted(suite.result);
656 | }
657 | };
658 |
659 | this.describe = function(description, specDefinitions) {
660 | var suite = suiteFactory(description);
661 | addSpecsToSuite(suite, specDefinitions);
662 | return suite;
663 | };
664 |
665 | this.xdescribe = function(description, specDefinitions) {
666 | var suite = this.describe(description, specDefinitions);
667 | suite.disable();
668 | return suite;
669 | };
670 |
671 | var focusedRunnables = [];
672 |
673 | this.fdescribe = function(description, specDefinitions) {
674 | var suite = suiteFactory(description);
675 | suite.isFocused = true;
676 |
677 | focusedRunnables.push(suite.id);
678 | unfocusAncestor();
679 | addSpecsToSuite(suite, specDefinitions);
680 |
681 | return suite;
682 | };
683 |
684 | function addSpecsToSuite(suite, specDefinitions) {
685 | var parentSuite = currentDeclarationSuite;
686 | parentSuite.addChild(suite);
687 | currentDeclarationSuite = suite;
688 |
689 | var declarationError = null;
690 | try {
691 | specDefinitions.call(suite);
692 | } catch (e) {
693 | declarationError = e;
694 | }
695 |
696 | if (declarationError) {
697 | self.it('encountered a declaration exception', function() {
698 | throw declarationError;
699 | });
700 | }
701 |
702 | currentDeclarationSuite = parentSuite;
703 | }
704 |
705 | function findFocusedAncestor(suite) {
706 | while (suite) {
707 | if (suite.isFocused) {
708 | return suite.id;
709 | }
710 | suite = suite.parentSuite;
711 | }
712 |
713 | return null;
714 | }
715 |
716 | function unfocusAncestor() {
717 | var focusedAncestor = findFocusedAncestor(currentDeclarationSuite);
718 | if (focusedAncestor) {
719 | for (var i = 0; i < focusedRunnables.length; i++) {
720 | if (focusedRunnables[i] === focusedAncestor) {
721 | focusedRunnables.splice(i, 1);
722 | break;
723 | }
724 | }
725 | }
726 | }
727 |
728 | var runnablesExplictlySet = false;
729 |
730 | var runnablesExplictlySetGetter = function(){
731 | return runnablesExplictlySet;
732 | };
733 |
734 | var specFactory = function(description, fn, suite, timeout) {
735 | totalSpecsDefined++;
736 | var spec = new j$.Spec({
737 | id: getNextSpecId(),
738 | beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter),
739 | expectationFactory: expectationFactory,
740 | resultCallback: specResultCallback,
741 | getSpecName: function(spec) {
742 | return getSpecName(spec, suite);
743 | },
744 | onStart: specStarted,
745 | description: description,
746 | expectationResultFactory: expectationResultFactory,
747 | queueRunnerFactory: queueRunnerFactory,
748 | userContext: function() { return suite.clonedSharedUserContext(); },
749 | queueableFn: {
750 | fn: fn,
751 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
752 | }
753 | });
754 |
755 | runnableLookupTable[spec.id] = spec;
756 |
757 | if (!self.specFilter(spec)) {
758 | spec.disable();
759 | }
760 |
761 | return spec;
762 |
763 | function specResultCallback(result) {
764 | clearResourcesForRunnable(spec.id);
765 | currentSpec = null;
766 | reporter.specDone(result);
767 | }
768 |
769 | function specStarted(spec) {
770 | currentSpec = spec;
771 | defaultResourcesForRunnable(spec.id, suite.id);
772 | reporter.specStarted(spec.result);
773 | }
774 | };
775 |
776 | this.it = function(description, fn, timeout) {
777 | var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
778 | currentDeclarationSuite.addChild(spec);
779 | return spec;
780 | };
781 |
782 | this.xit = function() {
783 | var spec = this.it.apply(this, arguments);
784 | spec.pend();
785 | return spec;
786 | };
787 |
788 | this.fit = function(){
789 | var spec = this.it.apply(this, arguments);
790 |
791 | focusedRunnables.push(spec.id);
792 | unfocusAncestor();
793 | return spec;
794 | };
795 |
796 | this.expect = function(actual) {
797 | if (!currentRunnable()) {
798 | throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out');
799 | }
800 |
801 | return currentRunnable().expect(actual);
802 | };
803 |
804 | this.beforeEach = function(beforeEachFunction, timeout) {
805 | currentDeclarationSuite.beforeEach({
806 | fn: beforeEachFunction,
807 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
808 | });
809 | };
810 |
811 | this.beforeAll = function(beforeAllFunction, timeout) {
812 | currentDeclarationSuite.beforeAll({
813 | fn: beforeAllFunction,
814 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
815 | });
816 | };
817 |
818 | this.afterEach = function(afterEachFunction, timeout) {
819 | currentDeclarationSuite.afterEach({
820 | fn: afterEachFunction,
821 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
822 | });
823 | };
824 |
825 | this.afterAll = function(afterAllFunction, timeout) {
826 | currentDeclarationSuite.afterAll({
827 | fn: afterAllFunction,
828 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
829 | });
830 | };
831 |
832 | this.pending = function() {
833 | throw j$.Spec.pendingSpecExceptionMessage;
834 | };
835 |
836 | this.fail = function(error) {
837 | var message = 'Failed';
838 | if (error) {
839 | message += ': ';
840 | message += error.message || error;
841 | }
842 |
843 | currentRunnable().addExpectationResult(false, {
844 | matcherName: '',
845 | passed: false,
846 | expected: '',
847 | actual: '',
848 | message: message
849 | });
850 | };
851 | }
852 |
853 | return Env;
854 | };
855 |
856 | getJasmineRequireObj().JsApiReporter = function() {
857 |
858 | var noopTimer = {
859 | start: function(){},
860 | elapsed: function(){ return 0; }
861 | };
862 |
863 | function JsApiReporter(options) {
864 | var timer = options.timer || noopTimer,
865 | status = 'loaded';
866 |
867 | this.started = false;
868 | this.finished = false;
869 |
870 | this.jasmineStarted = function() {
871 | this.started = true;
872 | status = 'started';
873 | timer.start();
874 | };
875 |
876 | var executionTime;
877 |
878 | this.jasmineDone = function() {
879 | this.finished = true;
880 | executionTime = timer.elapsed();
881 | status = 'done';
882 | };
883 |
884 | this.status = function() {
885 | return status;
886 | };
887 |
888 | var suites = [],
889 | suites_hash = {};
890 |
891 | this.suiteStarted = function(result) {
892 | suites_hash[result.id] = result;
893 | };
894 |
895 | this.suiteDone = function(result) {
896 | storeSuite(result);
897 | };
898 |
899 | this.suiteResults = function(index, length) {
900 | return suites.slice(index, index + length);
901 | };
902 |
903 | function storeSuite(result) {
904 | suites.push(result);
905 | suites_hash[result.id] = result;
906 | }
907 |
908 | this.suites = function() {
909 | return suites_hash;
910 | };
911 |
912 | var specs = [];
913 |
914 | this.specDone = function(result) {
915 | specs.push(result);
916 | };
917 |
918 | this.specResults = function(index, length) {
919 | return specs.slice(index, index + length);
920 | };
921 |
922 | this.specs = function() {
923 | return specs;
924 | };
925 |
926 | this.executionTime = function() {
927 | return executionTime;
928 | };
929 |
930 | }
931 |
932 | return JsApiReporter;
933 | };
934 |
935 | getJasmineRequireObj().Any = function() {
936 |
937 | function Any(expectedObject) {
938 | this.expectedObject = expectedObject;
939 | }
940 |
941 | Any.prototype.jasmineMatches = function(other) {
942 | if (this.expectedObject == String) {
943 | return typeof other == 'string' || other instanceof String;
944 | }
945 |
946 | if (this.expectedObject == Number) {
947 | return typeof other == 'number' || other instanceof Number;
948 | }
949 |
950 | if (this.expectedObject == Function) {
951 | return typeof other == 'function' || other instanceof Function;
952 | }
953 |
954 | if (this.expectedObject == Object) {
955 | return typeof other == 'object';
956 | }
957 |
958 | if (this.expectedObject == Boolean) {
959 | return typeof other == 'boolean';
960 | }
961 |
962 | return other instanceof this.expectedObject;
963 | };
964 |
965 | Any.prototype.jasmineToString = function() {
966 | return '';
967 | };
968 |
969 | return Any;
970 | };
971 |
972 | getJasmineRequireObj().CallTracker = function() {
973 |
974 | function CallTracker() {
975 | var calls = [];
976 |
977 | this.track = function(context) {
978 | calls.push(context);
979 | };
980 |
981 | this.any = function() {
982 | return !!calls.length;
983 | };
984 |
985 | this.count = function() {
986 | return calls.length;
987 | };
988 |
989 | this.argsFor = function(index) {
990 | var call = calls[index];
991 | return call ? call.args : [];
992 | };
993 |
994 | this.all = function() {
995 | return calls;
996 | };
997 |
998 | this.allArgs = function() {
999 | var callArgs = [];
1000 | for(var i = 0; i < calls.length; i++){
1001 | callArgs.push(calls[i].args);
1002 | }
1003 |
1004 | return callArgs;
1005 | };
1006 |
1007 | this.first = function() {
1008 | return calls[0];
1009 | };
1010 |
1011 | this.mostRecent = function() {
1012 | return calls[calls.length - 1];
1013 | };
1014 |
1015 | this.reset = function() {
1016 | calls = [];
1017 | };
1018 | }
1019 |
1020 | return CallTracker;
1021 | };
1022 |
1023 | getJasmineRequireObj().Clock = function() {
1024 | function Clock(global, delayedFunctionScheduler, mockDate) {
1025 | var self = this,
1026 | realTimingFunctions = {
1027 | setTimeout: global.setTimeout,
1028 | clearTimeout: global.clearTimeout,
1029 | setInterval: global.setInterval,
1030 | clearInterval: global.clearInterval
1031 | },
1032 | fakeTimingFunctions = {
1033 | setTimeout: setTimeout,
1034 | clearTimeout: clearTimeout,
1035 | setInterval: setInterval,
1036 | clearInterval: clearInterval
1037 | },
1038 | installed = false,
1039 | timer;
1040 |
1041 |
1042 | self.install = function() {
1043 | replace(global, fakeTimingFunctions);
1044 | timer = fakeTimingFunctions;
1045 | installed = true;
1046 |
1047 | return self;
1048 | };
1049 |
1050 | self.uninstall = function() {
1051 | delayedFunctionScheduler.reset();
1052 | mockDate.uninstall();
1053 | replace(global, realTimingFunctions);
1054 |
1055 | timer = realTimingFunctions;
1056 | installed = false;
1057 | };
1058 |
1059 | self.mockDate = function(initialDate) {
1060 | mockDate.install(initialDate);
1061 | };
1062 |
1063 | self.setTimeout = function(fn, delay, params) {
1064 | if (legacyIE()) {
1065 | if (arguments.length > 2) {
1066 | throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill');
1067 | }
1068 | return timer.setTimeout(fn, delay);
1069 | }
1070 | return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]);
1071 | };
1072 |
1073 | self.setInterval = function(fn, delay, params) {
1074 | if (legacyIE()) {
1075 | if (arguments.length > 2) {
1076 | throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill');
1077 | }
1078 | return timer.setInterval(fn, delay);
1079 | }
1080 | return Function.prototype.apply.apply(timer.setInterval, [global, arguments]);
1081 | };
1082 |
1083 | self.clearTimeout = function(id) {
1084 | return Function.prototype.call.apply(timer.clearTimeout, [global, id]);
1085 | };
1086 |
1087 | self.clearInterval = function(id) {
1088 | return Function.prototype.call.apply(timer.clearInterval, [global, id]);
1089 | };
1090 |
1091 | self.tick = function(millis) {
1092 | if (installed) {
1093 | mockDate.tick(millis);
1094 | delayedFunctionScheduler.tick(millis);
1095 | } else {
1096 | throw new Error('Mock clock is not installed, use jasmine.clock().install()');
1097 | }
1098 | };
1099 |
1100 | return self;
1101 |
1102 | function legacyIE() {
1103 | //if these methods are polyfilled, apply will be present
1104 | return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
1105 | }
1106 |
1107 | function replace(dest, source) {
1108 | for (var prop in source) {
1109 | dest[prop] = source[prop];
1110 | }
1111 | }
1112 |
1113 | function setTimeout(fn, delay) {
1114 | return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
1115 | }
1116 |
1117 | function clearTimeout(id) {
1118 | return delayedFunctionScheduler.removeFunctionWithId(id);
1119 | }
1120 |
1121 | function setInterval(fn, interval) {
1122 | return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
1123 | }
1124 |
1125 | function clearInterval(id) {
1126 | return delayedFunctionScheduler.removeFunctionWithId(id);
1127 | }
1128 |
1129 | function argSlice(argsObj, n) {
1130 | return Array.prototype.slice.call(argsObj, n);
1131 | }
1132 | }
1133 |
1134 | return Clock;
1135 | };
1136 |
1137 | getJasmineRequireObj().DelayedFunctionScheduler = function() {
1138 | function DelayedFunctionScheduler() {
1139 | var self = this;
1140 | var scheduledLookup = [];
1141 | var scheduledFunctions = {};
1142 | var currentTime = 0;
1143 | var delayedFnCount = 0;
1144 |
1145 | self.tick = function(millis) {
1146 | millis = millis || 0;
1147 | var endTime = currentTime + millis;
1148 |
1149 | runScheduledFunctions(endTime);
1150 | currentTime = endTime;
1151 | };
1152 |
1153 | self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
1154 | var f;
1155 | if (typeof(funcToCall) === 'string') {
1156 | /* jshint evil: true */
1157 | f = function() { return eval(funcToCall); };
1158 | /* jshint evil: false */
1159 | } else {
1160 | f = funcToCall;
1161 | }
1162 |
1163 | millis = millis || 0;
1164 | timeoutKey = timeoutKey || ++delayedFnCount;
1165 | runAtMillis = runAtMillis || (currentTime + millis);
1166 |
1167 | var funcToSchedule = {
1168 | runAtMillis: runAtMillis,
1169 | funcToCall: f,
1170 | recurring: recurring,
1171 | params: params,
1172 | timeoutKey: timeoutKey,
1173 | millis: millis
1174 | };
1175 |
1176 | if (runAtMillis in scheduledFunctions) {
1177 | scheduledFunctions[runAtMillis].push(funcToSchedule);
1178 | } else {
1179 | scheduledFunctions[runAtMillis] = [funcToSchedule];
1180 | scheduledLookup.push(runAtMillis);
1181 | scheduledLookup.sort(function (a, b) {
1182 | return a - b;
1183 | });
1184 | }
1185 |
1186 | return timeoutKey;
1187 | };
1188 |
1189 | self.removeFunctionWithId = function(timeoutKey) {
1190 | for (var runAtMillis in scheduledFunctions) {
1191 | var funcs = scheduledFunctions[runAtMillis];
1192 | var i = indexOfFirstToPass(funcs, function (func) {
1193 | return func.timeoutKey === timeoutKey;
1194 | });
1195 |
1196 | if (i > -1) {
1197 | if (funcs.length === 1) {
1198 | delete scheduledFunctions[runAtMillis];
1199 | deleteFromLookup(runAtMillis);
1200 | } else {
1201 | funcs.splice(i, 1);
1202 | }
1203 |
1204 | // intervals get rescheduled when executed, so there's never more
1205 | // than a single scheduled function with a given timeoutKey
1206 | break;
1207 | }
1208 | }
1209 | };
1210 |
1211 | self.reset = function() {
1212 | currentTime = 0;
1213 | scheduledLookup = [];
1214 | scheduledFunctions = {};
1215 | delayedFnCount = 0;
1216 | };
1217 |
1218 | return self;
1219 |
1220 | function indexOfFirstToPass(array, testFn) {
1221 | var index = -1;
1222 |
1223 | for (var i = 0; i < array.length; ++i) {
1224 | if (testFn(array[i])) {
1225 | index = i;
1226 | break;
1227 | }
1228 | }
1229 |
1230 | return index;
1231 | }
1232 |
1233 | function deleteFromLookup(key) {
1234 | var value = Number(key);
1235 | var i = indexOfFirstToPass(scheduledLookup, function (millis) {
1236 | return millis === value;
1237 | });
1238 |
1239 | if (i > -1) {
1240 | scheduledLookup.splice(i, 1);
1241 | }
1242 | }
1243 |
1244 | function reschedule(scheduledFn) {
1245 | self.scheduleFunction(scheduledFn.funcToCall,
1246 | scheduledFn.millis,
1247 | scheduledFn.params,
1248 | true,
1249 | scheduledFn.timeoutKey,
1250 | scheduledFn.runAtMillis + scheduledFn.millis);
1251 | }
1252 |
1253 | function runScheduledFunctions(endTime) {
1254 | if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
1255 | return;
1256 | }
1257 |
1258 | do {
1259 | currentTime = scheduledLookup.shift();
1260 |
1261 | var funcsToRun = scheduledFunctions[currentTime];
1262 | delete scheduledFunctions[currentTime];
1263 |
1264 | for (var i = 0; i < funcsToRun.length; ++i) {
1265 | var funcToRun = funcsToRun[i];
1266 |
1267 | if (funcToRun.recurring) {
1268 | reschedule(funcToRun);
1269 | }
1270 |
1271 | funcToRun.funcToCall.apply(null, funcToRun.params || []);
1272 | }
1273 | } while (scheduledLookup.length > 0 &&
1274 | // checking first if we're out of time prevents setTimeout(0)
1275 | // scheduled in a funcToRun from forcing an extra iteration
1276 | currentTime !== endTime &&
1277 | scheduledLookup[0] <= endTime);
1278 | }
1279 | }
1280 |
1281 | return DelayedFunctionScheduler;
1282 | };
1283 |
1284 | getJasmineRequireObj().ExceptionFormatter = function() {
1285 | function ExceptionFormatter() {
1286 | this.message = function(error) {
1287 | var message = '';
1288 |
1289 | if (error.name && error.message) {
1290 | message += error.name + ': ' + error.message;
1291 | } else {
1292 | message += error.toString() + ' thrown';
1293 | }
1294 |
1295 | if (error.fileName || error.sourceURL) {
1296 | message += ' in ' + (error.fileName || error.sourceURL);
1297 | }
1298 |
1299 | if (error.line || error.lineNumber) {
1300 | message += ' (line ' + (error.line || error.lineNumber) + ')';
1301 | }
1302 |
1303 | return message;
1304 | };
1305 |
1306 | this.stack = function(error) {
1307 | return error ? error.stack : null;
1308 | };
1309 | }
1310 |
1311 | return ExceptionFormatter;
1312 | };
1313 |
1314 | getJasmineRequireObj().Expectation = function() {
1315 |
1316 | function Expectation(options) {
1317 | this.util = options.util || { buildFailureMessage: function() {} };
1318 | this.customEqualityTesters = options.customEqualityTesters || [];
1319 | this.actual = options.actual;
1320 | this.addExpectationResult = options.addExpectationResult || function(){};
1321 | this.isNot = options.isNot;
1322 |
1323 | var customMatchers = options.customMatchers || {};
1324 | for (var matcherName in customMatchers) {
1325 | this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]);
1326 | }
1327 | }
1328 |
1329 | Expectation.prototype.wrapCompare = function(name, matcherFactory) {
1330 | return function() {
1331 | var args = Array.prototype.slice.call(arguments, 0),
1332 | expected = args.slice(0),
1333 | message = '';
1334 |
1335 | args.unshift(this.actual);
1336 |
1337 | var matcher = matcherFactory(this.util, this.customEqualityTesters),
1338 | matcherCompare = matcher.compare;
1339 |
1340 | function defaultNegativeCompare() {
1341 | var result = matcher.compare.apply(null, args);
1342 | result.pass = !result.pass;
1343 | return result;
1344 | }
1345 |
1346 | if (this.isNot) {
1347 | matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
1348 | }
1349 |
1350 | var result = matcherCompare.apply(null, args);
1351 |
1352 | if (!result.pass) {
1353 | if (!result.message) {
1354 | args.unshift(this.isNot);
1355 | args.unshift(name);
1356 | message = this.util.buildFailureMessage.apply(null, args);
1357 | } else {
1358 | if (Object.prototype.toString.apply(result.message) === '[object Function]') {
1359 | message = result.message();
1360 | } else {
1361 | message = result.message;
1362 | }
1363 | }
1364 | }
1365 |
1366 | if (expected.length == 1) {
1367 | expected = expected[0];
1368 | }
1369 |
1370 | // TODO: how many of these params are needed?
1371 | this.addExpectationResult(
1372 | result.pass,
1373 | {
1374 | matcherName: name,
1375 | passed: result.pass,
1376 | message: message,
1377 | actual: this.actual,
1378 | expected: expected // TODO: this may need to be arrayified/sliced
1379 | }
1380 | );
1381 | };
1382 | };
1383 |
1384 | Expectation.addCoreMatchers = function(matchers) {
1385 | var prototype = Expectation.prototype;
1386 | for (var matcherName in matchers) {
1387 | var matcher = matchers[matcherName];
1388 | prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
1389 | }
1390 | };
1391 |
1392 | Expectation.Factory = function(options) {
1393 | options = options || {};
1394 |
1395 | var expect = new Expectation(options);
1396 |
1397 | // TODO: this would be nice as its own Object - NegativeExpectation
1398 | // TODO: copy instead of mutate options
1399 | options.isNot = true;
1400 | expect.not = new Expectation(options);
1401 |
1402 | return expect;
1403 | };
1404 |
1405 | return Expectation;
1406 | };
1407 |
1408 | //TODO: expectation result may make more sense as a presentation of an expectation.
1409 | getJasmineRequireObj().buildExpectationResult = function() {
1410 | function buildExpectationResult(options) {
1411 | var messageFormatter = options.messageFormatter || function() {},
1412 | stackFormatter = options.stackFormatter || function() {};
1413 |
1414 | return {
1415 | matcherName: options.matcherName,
1416 | expected: options.expected,
1417 | actual: options.actual,
1418 | message: message(),
1419 | stack: stack(),
1420 | passed: options.passed
1421 | };
1422 |
1423 | function message() {
1424 | if (options.passed) {
1425 | return 'Passed.';
1426 | } else if (options.message) {
1427 | return options.message;
1428 | } else if (options.error) {
1429 | return messageFormatter(options.error);
1430 | }
1431 | return '';
1432 | }
1433 |
1434 | function stack() {
1435 | if (options.passed) {
1436 | return '';
1437 | }
1438 |
1439 | var error = options.error;
1440 | if (!error) {
1441 | try {
1442 | throw new Error(message());
1443 | } catch (e) {
1444 | error = e;
1445 | }
1446 | }
1447 | return stackFormatter(error);
1448 | }
1449 | }
1450 |
1451 | return buildExpectationResult;
1452 | };
1453 |
1454 | getJasmineRequireObj().MockDate = function() {
1455 | function MockDate(global) {
1456 | var self = this;
1457 | var currentTime = 0;
1458 |
1459 | if (!global || !global.Date) {
1460 | self.install = function() {};
1461 | self.tick = function() {};
1462 | self.uninstall = function() {};
1463 | return self;
1464 | }
1465 |
1466 | var GlobalDate = global.Date;
1467 |
1468 | self.install = function(mockDate) {
1469 | if (mockDate instanceof GlobalDate) {
1470 | currentTime = mockDate.getTime();
1471 | } else {
1472 | currentTime = new GlobalDate().getTime();
1473 | }
1474 |
1475 | global.Date = FakeDate;
1476 | };
1477 |
1478 | self.tick = function(millis) {
1479 | millis = millis || 0;
1480 | currentTime = currentTime + millis;
1481 | };
1482 |
1483 | self.uninstall = function() {
1484 | currentTime = 0;
1485 | global.Date = GlobalDate;
1486 | };
1487 |
1488 | createDateProperties();
1489 |
1490 | return self;
1491 |
1492 | function FakeDate() {
1493 | switch(arguments.length) {
1494 | case 0:
1495 | return new GlobalDate(currentTime);
1496 | case 1:
1497 | return new GlobalDate(arguments[0]);
1498 | case 2:
1499 | return new GlobalDate(arguments[0], arguments[1]);
1500 | case 3:
1501 | return new GlobalDate(arguments[0], arguments[1], arguments[2]);
1502 | case 4:
1503 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]);
1504 | case 5:
1505 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1506 | arguments[4]);
1507 | case 6:
1508 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1509 | arguments[4], arguments[5]);
1510 | case 7:
1511 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3],
1512 | arguments[4], arguments[5], arguments[6]);
1513 | }
1514 | }
1515 |
1516 | function createDateProperties() {
1517 | FakeDate.prototype = GlobalDate.prototype;
1518 |
1519 | FakeDate.now = function() {
1520 | if (GlobalDate.now) {
1521 | return currentTime;
1522 | } else {
1523 | throw new Error('Browser does not support Date.now()');
1524 | }
1525 | };
1526 |
1527 | FakeDate.toSource = GlobalDate.toSource;
1528 | FakeDate.toString = GlobalDate.toString;
1529 | FakeDate.parse = GlobalDate.parse;
1530 | FakeDate.UTC = GlobalDate.UTC;
1531 | }
1532 | }
1533 |
1534 | return MockDate;
1535 | };
1536 |
1537 | getJasmineRequireObj().ObjectContaining = function(j$) {
1538 |
1539 | function ObjectContaining(sample) {
1540 | this.sample = sample;
1541 | }
1542 |
1543 | ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
1544 | if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
1545 |
1546 | mismatchKeys = mismatchKeys || [];
1547 | mismatchValues = mismatchValues || [];
1548 |
1549 | var hasKey = function(obj, keyName) {
1550 | return obj !== null && !j$.util.isUndefined(obj[keyName]);
1551 | };
1552 |
1553 | for (var property in this.sample) {
1554 | if (!hasKey(other, property) && hasKey(this.sample, property)) {
1555 | mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.');
1556 | }
1557 | else if (!j$.matchersUtil.equals(other[property], this.sample[property])) {
1558 | mismatchValues.push('\'' + property + '\' was \'' + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + '\' in actual, but was \'' + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + '\' in expected.');
1559 | }
1560 | }
1561 |
1562 | return (mismatchKeys.length === 0 && mismatchValues.length === 0);
1563 | };
1564 |
1565 | ObjectContaining.prototype.jasmineToString = function() {
1566 | return '';
1567 | };
1568 |
1569 | return ObjectContaining;
1570 | };
1571 |
1572 | getJasmineRequireObj().pp = function(j$) {
1573 |
1574 | function PrettyPrinter() {
1575 | this.ppNestLevel_ = 0;
1576 | this.seen = [];
1577 | }
1578 |
1579 | PrettyPrinter.prototype.format = function(value) {
1580 | this.ppNestLevel_++;
1581 | try {
1582 | if (j$.util.isUndefined(value)) {
1583 | this.emitScalar('undefined');
1584 | } else if (value === null) {
1585 | this.emitScalar('null');
1586 | } else if (value === 0 && 1/value === -Infinity) {
1587 | this.emitScalar('-0');
1588 | } else if (value === j$.getGlobal()) {
1589 | this.emitScalar('');
1590 | } else if (value.jasmineToString) {
1591 | this.emitScalar(value.jasmineToString());
1592 | } else if (typeof value === 'string') {
1593 | this.emitString(value);
1594 | } else if (j$.isSpy(value)) {
1595 | this.emitScalar('spy on ' + value.and.identity());
1596 | } else if (value instanceof RegExp) {
1597 | this.emitScalar(value.toString());
1598 | } else if (typeof value === 'function') {
1599 | this.emitScalar('Function');
1600 | } else if (typeof value.nodeType === 'number') {
1601 | this.emitScalar('HTMLNode');
1602 | } else if (value instanceof Date) {
1603 | this.emitScalar('Date(' + value + ')');
1604 | } else if (j$.util.arrayContains(this.seen, value)) {
1605 | this.emitScalar('');
1606 | } else if (j$.isArray_(value) || j$.isA_('Object', value)) {
1607 | this.seen.push(value);
1608 | if (j$.isArray_(value)) {
1609 | this.emitArray(value);
1610 | } else {
1611 | this.emitObject(value);
1612 | }
1613 | this.seen.pop();
1614 | } else {
1615 | this.emitScalar(value.toString());
1616 | }
1617 | } finally {
1618 | this.ppNestLevel_--;
1619 | }
1620 | };
1621 |
1622 | PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1623 | for (var property in obj) {
1624 | if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; }
1625 | fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1626 | obj.__lookupGetter__(property) !== null) : false);
1627 | }
1628 | };
1629 |
1630 | PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
1631 | PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
1632 | PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
1633 | PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
1634 |
1635 | function StringPrettyPrinter() {
1636 | PrettyPrinter.call(this);
1637 |
1638 | this.string = '';
1639 | }
1640 |
1641 | j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
1642 |
1643 | StringPrettyPrinter.prototype.emitScalar = function(value) {
1644 | this.append(value);
1645 | };
1646 |
1647 | StringPrettyPrinter.prototype.emitString = function(value) {
1648 | this.append('\'' + value + '\'');
1649 | };
1650 |
1651 | StringPrettyPrinter.prototype.emitArray = function(array) {
1652 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1653 | this.append('Array');
1654 | return;
1655 | }
1656 | var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH);
1657 | this.append('[ ');
1658 | for (var i = 0; i < length; i++) {
1659 | if (i > 0) {
1660 | this.append(', ');
1661 | }
1662 | this.format(array[i]);
1663 | }
1664 | if(array.length > length){
1665 | this.append(', ...');
1666 | }
1667 | this.append(' ]');
1668 | };
1669 |
1670 | StringPrettyPrinter.prototype.emitObject = function(obj) {
1671 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1672 | this.append('Object');
1673 | return;
1674 | }
1675 |
1676 | var self = this;
1677 | this.append('{ ');
1678 | var first = true;
1679 |
1680 | this.iterateObject(obj, function(property, isGetter) {
1681 | if (first) {
1682 | first = false;
1683 | } else {
1684 | self.append(', ');
1685 | }
1686 |
1687 | self.append(property);
1688 | self.append(': ');
1689 | if (isGetter) {
1690 | self.append('');
1691 | } else {
1692 | self.format(obj[property]);
1693 | }
1694 | });
1695 |
1696 | this.append(' }');
1697 | };
1698 |
1699 | StringPrettyPrinter.prototype.append = function(value) {
1700 | this.string += value;
1701 | };
1702 |
1703 | return function(value) {
1704 | var stringPrettyPrinter = new StringPrettyPrinter();
1705 | stringPrettyPrinter.format(value);
1706 | return stringPrettyPrinter.string;
1707 | };
1708 | };
1709 |
1710 | getJasmineRequireObj().QueueRunner = function(j$) {
1711 |
1712 | function once(fn) {
1713 | var called = false;
1714 | return function() {
1715 | if (!called) {
1716 | called = true;
1717 | fn();
1718 | }
1719 | };
1720 | }
1721 |
1722 | function QueueRunner(attrs) {
1723 | this.queueableFns = attrs.queueableFns || [];
1724 | this.onComplete = attrs.onComplete || function() {};
1725 | this.clearStack = attrs.clearStack || function(fn) {fn();};
1726 | this.onException = attrs.onException || function() {};
1727 | this.catchException = attrs.catchException || function() { return true; };
1728 | this.userContext = attrs.userContext || {};
1729 | this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
1730 | this.fail = attrs.fail || function() {};
1731 | }
1732 |
1733 | QueueRunner.prototype.execute = function() {
1734 | this.run(this.queueableFns, 0);
1735 | };
1736 |
1737 | QueueRunner.prototype.run = function(queueableFns, recursiveIndex) {
1738 | var length = queueableFns.length,
1739 | self = this,
1740 | iterativeIndex;
1741 |
1742 |
1743 | for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
1744 | var queueableFn = queueableFns[iterativeIndex];
1745 | if (queueableFn.fn.length > 0) {
1746 | return attemptAsync(queueableFn);
1747 | } else {
1748 | attemptSync(queueableFn);
1749 | }
1750 | }
1751 |
1752 | var runnerDone = iterativeIndex >= length;
1753 |
1754 | if (runnerDone) {
1755 | this.clearStack(this.onComplete);
1756 | }
1757 |
1758 | function attemptSync(queueableFn) {
1759 | try {
1760 | queueableFn.fn.call(self.userContext);
1761 | } catch (e) {
1762 | handleException(e, queueableFn);
1763 | }
1764 | }
1765 |
1766 | function attemptAsync(queueableFn) {
1767 | var clearTimeout = function () {
1768 | Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]);
1769 | },
1770 | next = once(function () {
1771 | clearTimeout(timeoutId);
1772 | self.run(queueableFns, iterativeIndex + 1);
1773 | }),
1774 | timeoutId;
1775 |
1776 | next.fail = function() {
1777 | self.fail.apply(null, arguments);
1778 | next();
1779 | };
1780 |
1781 | if (queueableFn.timeout) {
1782 | timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
1783 | var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
1784 | onException(error, queueableFn);
1785 | next();
1786 | }, queueableFn.timeout()]]);
1787 | }
1788 |
1789 | try {
1790 | queueableFn.fn.call(self.userContext, next);
1791 | } catch (e) {
1792 | handleException(e, queueableFn);
1793 | next();
1794 | }
1795 | }
1796 |
1797 | function onException(e, queueableFn) {
1798 | self.onException(e);
1799 | }
1800 |
1801 | function handleException(e, queueableFn) {
1802 | onException(e, queueableFn);
1803 | if (!self.catchException(e)) {
1804 | //TODO: set a var when we catch an exception and
1805 | //use a finally block to close the loop in a nice way..
1806 | throw e;
1807 | }
1808 | }
1809 | };
1810 |
1811 | return QueueRunner;
1812 | };
1813 |
1814 | getJasmineRequireObj().ReportDispatcher = function() {
1815 | function ReportDispatcher(methods) {
1816 |
1817 | var dispatchedMethods = methods || [];
1818 |
1819 | for (var i = 0; i < dispatchedMethods.length; i++) {
1820 | var method = dispatchedMethods[i];
1821 | this[method] = (function(m) {
1822 | return function() {
1823 | dispatch(m, arguments);
1824 | };
1825 | }(method));
1826 | }
1827 |
1828 | var reporters = [];
1829 |
1830 | this.addReporter = function(reporter) {
1831 | reporters.push(reporter);
1832 | };
1833 |
1834 | return this;
1835 |
1836 | function dispatch(method, args) {
1837 | for (var i = 0; i < reporters.length; i++) {
1838 | var reporter = reporters[i];
1839 | if (reporter[method]) {
1840 | reporter[method].apply(reporter, args);
1841 | }
1842 | }
1843 | }
1844 | }
1845 |
1846 | return ReportDispatcher;
1847 | };
1848 |
1849 |
1850 | getJasmineRequireObj().SpyRegistry = function(j$) {
1851 |
1852 | function SpyRegistry(options) {
1853 | options = options || {};
1854 | var currentSpies = options.currentSpies || function() { return []; };
1855 |
1856 | this.spyOn = function(obj, methodName) {
1857 | if (j$.util.isUndefined(obj)) {
1858 | throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
1859 | }
1860 |
1861 | if (j$.util.isUndefined(obj[methodName])) {
1862 | throw new Error(methodName + '() method does not exist');
1863 | }
1864 |
1865 | if (obj[methodName] && j$.isSpy(obj[methodName])) {
1866 | //TODO?: should this return the current spy? Downside: may cause user confusion about spy state
1867 | throw new Error(methodName + ' has already been spied upon');
1868 | }
1869 |
1870 | var spy = j$.createSpy(methodName, obj[methodName]);
1871 |
1872 | currentSpies().push({
1873 | spy: spy,
1874 | baseObj: obj,
1875 | methodName: methodName,
1876 | originalValue: obj[methodName]
1877 | });
1878 |
1879 | obj[methodName] = spy;
1880 |
1881 | return spy;
1882 | };
1883 |
1884 | this.clearSpies = function() {
1885 | var spies = currentSpies();
1886 | for (var i = 0; i < spies.length; i++) {
1887 | var spyEntry = spies[i];
1888 | spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue;
1889 | }
1890 | };
1891 | }
1892 |
1893 | return SpyRegistry;
1894 | };
1895 |
1896 | getJasmineRequireObj().SpyStrategy = function() {
1897 |
1898 | function SpyStrategy(options) {
1899 | options = options || {};
1900 |
1901 | var identity = options.name || 'unknown',
1902 | originalFn = options.fn || function() {},
1903 | getSpy = options.getSpy || function() {},
1904 | plan = function() {};
1905 |
1906 | this.identity = function() {
1907 | return identity;
1908 | };
1909 |
1910 | this.exec = function() {
1911 | return plan.apply(this, arguments);
1912 | };
1913 |
1914 | this.callThrough = function() {
1915 | plan = originalFn;
1916 | return getSpy();
1917 | };
1918 |
1919 | this.returnValue = function(value) {
1920 | plan = function() {
1921 | return value;
1922 | };
1923 | return getSpy();
1924 | };
1925 |
1926 | this.returnValues = function() {
1927 | var values = Array.prototype.slice.call(arguments);
1928 | plan = function () {
1929 | return values.shift();
1930 | };
1931 | return getSpy();
1932 | };
1933 |
1934 | this.throwError = function(something) {
1935 | var error = (something instanceof Error) ? something : new Error(something);
1936 | plan = function() {
1937 | throw error;
1938 | };
1939 | return getSpy();
1940 | };
1941 |
1942 | this.callFake = function(fn) {
1943 | plan = fn;
1944 | return getSpy();
1945 | };
1946 |
1947 | this.stub = function(fn) {
1948 | plan = function() {};
1949 | return getSpy();
1950 | };
1951 | }
1952 |
1953 | return SpyStrategy;
1954 | };
1955 |
1956 | getJasmineRequireObj().Suite = function() {
1957 | function Suite(attrs) {
1958 | this.env = attrs.env;
1959 | this.id = attrs.id;
1960 | this.parentSuite = attrs.parentSuite;
1961 | this.description = attrs.description;
1962 | this.onStart = attrs.onStart || function() {};
1963 | this.resultCallback = attrs.resultCallback || function() {};
1964 | this.clearStack = attrs.clearStack || function(fn) {fn();};
1965 | this.expectationFactory = attrs.expectationFactory;
1966 | this.expectationResultFactory = attrs.expectationResultFactory;
1967 |
1968 | this.beforeFns = [];
1969 | this.afterFns = [];
1970 | this.beforeAllFns = [];
1971 | this.afterAllFns = [];
1972 | this.queueRunner = attrs.queueRunner || function() {};
1973 | this.disabled = false;
1974 |
1975 | this.children = [];
1976 |
1977 | this.result = {
1978 | id: this.id,
1979 | description: this.description,
1980 | fullName: this.getFullName(),
1981 | failedExpectations: []
1982 | };
1983 | }
1984 |
1985 | Suite.prototype.expect = function(actual) {
1986 | return this.expectationFactory(actual, this);
1987 | };
1988 |
1989 | Suite.prototype.getFullName = function() {
1990 | var fullName = this.description;
1991 | for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
1992 | if (parentSuite.parentSuite) {
1993 | fullName = parentSuite.description + ' ' + fullName;
1994 | }
1995 | }
1996 | return fullName;
1997 | };
1998 |
1999 | Suite.prototype.disable = function() {
2000 | this.disabled = true;
2001 | };
2002 |
2003 | Suite.prototype.beforeEach = function(fn) {
2004 | this.beforeFns.unshift(fn);
2005 | };
2006 |
2007 | Suite.prototype.beforeAll = function(fn) {
2008 | this.beforeAllFns.push(fn);
2009 | };
2010 |
2011 | Suite.prototype.afterEach = function(fn) {
2012 | this.afterFns.unshift(fn);
2013 | };
2014 |
2015 | Suite.prototype.afterAll = function(fn) {
2016 | this.afterAllFns.push(fn);
2017 | };
2018 |
2019 | Suite.prototype.addChild = function(child) {
2020 | this.children.push(child);
2021 | };
2022 |
2023 | Suite.prototype.status = function() {
2024 | if (this.disabled) {
2025 | return 'disabled';
2026 | }
2027 |
2028 | if (this.result.failedExpectations.length > 0) {
2029 | return 'failed';
2030 | } else {
2031 | return 'finished';
2032 | }
2033 | };
2034 |
2035 | Suite.prototype.execute = function(onComplete) {
2036 | var self = this;
2037 |
2038 | this.onStart(this);
2039 |
2040 | if (this.disabled) {
2041 | complete();
2042 | return;
2043 | }
2044 |
2045 | var allFns = [];
2046 |
2047 | for (var i = 0; i < this.children.length; i++) {
2048 | allFns.push(wrapChildAsAsync(this.children[i]));
2049 | }
2050 |
2051 | if (this.isExecutable()) {
2052 | allFns = this.beforeAllFns.concat(allFns);
2053 | allFns = allFns.concat(this.afterAllFns);
2054 | }
2055 |
2056 | this.queueRunner({
2057 | queueableFns: allFns,
2058 | onComplete: complete,
2059 | userContext: this.sharedUserContext(),
2060 | onException: function() { self.onException.apply(self, arguments); }
2061 | });
2062 |
2063 | function complete() {
2064 | self.result.status = self.status();
2065 | self.resultCallback(self.result);
2066 |
2067 | if (onComplete) {
2068 | onComplete();
2069 | }
2070 | }
2071 |
2072 | function wrapChildAsAsync(child) {
2073 | return { fn: function(done) { child.execute(done); } };
2074 | }
2075 | };
2076 |
2077 | Suite.prototype.isExecutable = function() {
2078 | var foundActive = false;
2079 | for(var i = 0; i < this.children.length; i++) {
2080 | if(this.children[i].isExecutable()) {
2081 | foundActive = true;
2082 | break;
2083 | }
2084 | }
2085 | return foundActive;
2086 | };
2087 |
2088 | Suite.prototype.sharedUserContext = function() {
2089 | if (!this.sharedContext) {
2090 | this.sharedContext = this.parentSuite ? clone(this.parentSuite.sharedUserContext()) : {};
2091 | }
2092 |
2093 | return this.sharedContext;
2094 | };
2095 |
2096 | Suite.prototype.clonedSharedUserContext = function() {
2097 | return clone(this.sharedUserContext());
2098 | };
2099 |
2100 | Suite.prototype.onException = function() {
2101 | if(isAfterAll(this.children)) {
2102 | var data = {
2103 | matcherName: '',
2104 | passed: false,
2105 | expected: '',
2106 | actual: '',
2107 | error: arguments[0]
2108 | };
2109 | this.result.failedExpectations.push(this.expectationResultFactory(data));
2110 | } else {
2111 | for (var i = 0; i < this.children.length; i++) {
2112 | var child = this.children[i];
2113 | child.onException.apply(child, arguments);
2114 | }
2115 | }
2116 | };
2117 |
2118 | Suite.prototype.addExpectationResult = function () {
2119 | if(isAfterAll(this.children) && isFailure(arguments)){
2120 | var data = arguments[1];
2121 | this.result.failedExpectations.push(this.expectationResultFactory(data));
2122 | } else {
2123 | for (var i = 0; i < this.children.length; i++) {
2124 | var child = this.children[i];
2125 | child.addExpectationResult.apply(child, arguments);
2126 | }
2127 | }
2128 | };
2129 |
2130 | function isAfterAll(children) {
2131 | return children && children[0].result.status;
2132 | }
2133 |
2134 | function isFailure(args) {
2135 | return !args[0];
2136 | }
2137 |
2138 | function clone(obj) {
2139 | var clonedObj = {};
2140 | for (var prop in obj) {
2141 | if (obj.hasOwnProperty(prop)) {
2142 | clonedObj[prop] = obj[prop];
2143 | }
2144 | }
2145 |
2146 | return clonedObj;
2147 | }
2148 |
2149 | return Suite;
2150 | };
2151 |
2152 | if (typeof window == void 0 && typeof exports == 'object') {
2153 | exports.Suite = jasmineRequire.Suite;
2154 | }
2155 |
2156 | getJasmineRequireObj().Timer = function() {
2157 | var defaultNow = (function(Date) {
2158 | return function() { return new Date().getTime(); };
2159 | })(Date);
2160 |
2161 | function Timer(options) {
2162 | options = options || {};
2163 |
2164 | var now = options.now || defaultNow,
2165 | startTime;
2166 |
2167 | this.start = function() {
2168 | startTime = now();
2169 | };
2170 |
2171 | this.elapsed = function() {
2172 | return now() - startTime;
2173 | };
2174 | }
2175 |
2176 | return Timer;
2177 | };
2178 |
2179 | getJasmineRequireObj().matchersUtil = function(j$) {
2180 | // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
2181 |
2182 | return {
2183 | equals: function(a, b, customTesters) {
2184 | customTesters = customTesters || [];
2185 |
2186 | return eq(a, b, [], [], customTesters);
2187 | },
2188 |
2189 | contains: function(haystack, needle, customTesters) {
2190 | customTesters = customTesters || [];
2191 |
2192 | if ((Object.prototype.toString.apply(haystack) === '[object Array]') ||
2193 | (!!haystack && !haystack.indexOf))
2194 | {
2195 | for (var i = 0; i < haystack.length; i++) {
2196 | if (eq(haystack[i], needle, [], [], customTesters)) {
2197 | return true;
2198 | }
2199 | }
2200 | return false;
2201 | }
2202 |
2203 | return !!haystack && haystack.indexOf(needle) >= 0;
2204 | },
2205 |
2206 | buildFailureMessage: function() {
2207 | var args = Array.prototype.slice.call(arguments, 0),
2208 | matcherName = args[0],
2209 | isNot = args[1],
2210 | actual = args[2],
2211 | expected = args.slice(3),
2212 | englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
2213 |
2214 | var message = 'Expected ' +
2215 | j$.pp(actual) +
2216 | (isNot ? ' not ' : ' ') +
2217 | englishyPredicate;
2218 |
2219 | if (expected.length > 0) {
2220 | for (var i = 0; i < expected.length; i++) {
2221 | if (i > 0) {
2222 | message += ',';
2223 | }
2224 | message += ' ' + j$.pp(expected[i]);
2225 | }
2226 | }
2227 |
2228 | return message + '.';
2229 | }
2230 | };
2231 |
2232 | // Equality function lovingly adapted from isEqual in
2233 | // [Underscore](http://underscorejs.org)
2234 | function eq(a, b, aStack, bStack, customTesters) {
2235 | var result = true;
2236 |
2237 | for (var i = 0; i < customTesters.length; i++) {
2238 | var customTesterResult = customTesters[i](a, b);
2239 | if (!j$.util.isUndefined(customTesterResult)) {
2240 | return customTesterResult;
2241 | }
2242 | }
2243 |
2244 | if (a instanceof j$.Any) {
2245 | result = a.jasmineMatches(b);
2246 | if (result) {
2247 | return true;
2248 | }
2249 | }
2250 |
2251 | if (b instanceof j$.Any) {
2252 | result = b.jasmineMatches(a);
2253 | if (result) {
2254 | return true;
2255 | }
2256 | }
2257 |
2258 | if (b instanceof j$.ObjectContaining) {
2259 | result = b.jasmineMatches(a);
2260 | if (result) {
2261 | return true;
2262 | }
2263 | }
2264 |
2265 | if (a instanceof Error && b instanceof Error) {
2266 | return a.message == b.message;
2267 | }
2268 |
2269 | // Identical objects are equal. `0 === -0`, but they aren't identical.
2270 | // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
2271 | if (a === b) { return a !== 0 || 1 / a == 1 / b; }
2272 | // A strict comparison is necessary because `null == undefined`.
2273 | if (a === null || b === null) { return a === b; }
2274 | var className = Object.prototype.toString.call(a);
2275 | if (className != Object.prototype.toString.call(b)) { return false; }
2276 | switch (className) {
2277 | // Strings, numbers, dates, and booleans are compared by value.
2278 | case '[object String]':
2279 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
2280 | // equivalent to `new String("5")`.
2281 | return a == String(b);
2282 | case '[object Number]':
2283 | // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
2284 | // other numeric values.
2285 | return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b);
2286 | case '[object Date]':
2287 | case '[object Boolean]':
2288 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their
2289 | // millisecond representations. Note that invalid dates with millisecond representations
2290 | // of `NaN` are not equivalent.
2291 | return +a == +b;
2292 | // RegExps are compared by their source patterns and flags.
2293 | case '[object RegExp]':
2294 | return a.source == b.source &&
2295 | a.global == b.global &&
2296 | a.multiline == b.multiline &&
2297 | a.ignoreCase == b.ignoreCase;
2298 | }
2299 | if (typeof a != 'object' || typeof b != 'object') { return false; }
2300 | // Assume equality for cyclic structures. The algorithm for detecting cyclic
2301 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
2302 | var length = aStack.length;
2303 | while (length--) {
2304 | // Linear search. Performance is inversely proportional to the number of
2305 | // unique nested structures.
2306 | if (aStack[length] == a) { return bStack[length] == b; }
2307 | }
2308 | // Add the first object to the stack of traversed objects.
2309 | aStack.push(a);
2310 | bStack.push(b);
2311 | var size = 0;
2312 | // Recursively compare objects and arrays.
2313 | if (className == '[object Array]') {
2314 | // Compare array lengths to determine if a deep comparison is necessary.
2315 | size = a.length;
2316 | result = size == b.length;
2317 | if (result) {
2318 | // Deep compare the contents, ignoring non-numeric properties.
2319 | while (size--) {
2320 | if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
2321 | }
2322 | }
2323 | } else {
2324 | // Objects with different constructors are not equivalent, but `Object`s
2325 | // from different frames are.
2326 | var aCtor = a.constructor, bCtor = b.constructor;
2327 | if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) &&
2328 | isFunction(bCtor) && (bCtor instanceof bCtor))) {
2329 | return false;
2330 | }
2331 | // Deep compare objects.
2332 | for (var key in a) {
2333 | if (has(a, key)) {
2334 | // Count the expected number of properties.
2335 | size++;
2336 | // Deep compare each member.
2337 | if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
2338 | }
2339 | }
2340 | // Ensure that both objects contain the same number of properties.
2341 | if (result) {
2342 | for (key in b) {
2343 | if (has(b, key) && !(size--)) { break; }
2344 | }
2345 | result = !size;
2346 | }
2347 | }
2348 | // Remove the first object from the stack of traversed objects.
2349 | aStack.pop();
2350 | bStack.pop();
2351 |
2352 | return result;
2353 |
2354 | function has(obj, key) {
2355 | return obj.hasOwnProperty(key);
2356 | }
2357 |
2358 | function isFunction(obj) {
2359 | return typeof obj === 'function';
2360 | }
2361 | }
2362 | };
2363 |
2364 | getJasmineRequireObj().toBe = function() {
2365 | function toBe() {
2366 | return {
2367 | compare: function(actual, expected) {
2368 | return {
2369 | pass: actual === expected
2370 | };
2371 | }
2372 | };
2373 | }
2374 |
2375 | return toBe;
2376 | };
2377 |
2378 | getJasmineRequireObj().toBeCloseTo = function() {
2379 |
2380 | function toBeCloseTo() {
2381 | return {
2382 | compare: function(actual, expected, precision) {
2383 | if (precision !== 0) {
2384 | precision = precision || 2;
2385 | }
2386 |
2387 | return {
2388 | pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
2389 | };
2390 | }
2391 | };
2392 | }
2393 |
2394 | return toBeCloseTo;
2395 | };
2396 |
2397 | getJasmineRequireObj().toBeDefined = function() {
2398 | function toBeDefined() {
2399 | return {
2400 | compare: function(actual) {
2401 | return {
2402 | pass: (void 0 !== actual)
2403 | };
2404 | }
2405 | };
2406 | }
2407 |
2408 | return toBeDefined;
2409 | };
2410 |
2411 | getJasmineRequireObj().toBeFalsy = function() {
2412 | function toBeFalsy() {
2413 | return {
2414 | compare: function(actual) {
2415 | return {
2416 | pass: !!!actual
2417 | };
2418 | }
2419 | };
2420 | }
2421 |
2422 | return toBeFalsy;
2423 | };
2424 |
2425 | getJasmineRequireObj().toBeGreaterThan = function() {
2426 |
2427 | function toBeGreaterThan() {
2428 | return {
2429 | compare: function(actual, expected) {
2430 | return {
2431 | pass: actual > expected
2432 | };
2433 | }
2434 | };
2435 | }
2436 |
2437 | return toBeGreaterThan;
2438 | };
2439 |
2440 |
2441 | getJasmineRequireObj().toBeLessThan = function() {
2442 | function toBeLessThan() {
2443 | return {
2444 |
2445 | compare: function(actual, expected) {
2446 | return {
2447 | pass: actual < expected
2448 | };
2449 | }
2450 | };
2451 | }
2452 |
2453 | return toBeLessThan;
2454 | };
2455 | getJasmineRequireObj().toBeNaN = function(j$) {
2456 |
2457 | function toBeNaN() {
2458 | return {
2459 | compare: function(actual) {
2460 | var result = {
2461 | pass: (actual !== actual)
2462 | };
2463 |
2464 | if (result.pass) {
2465 | result.message = 'Expected actual not to be NaN.';
2466 | } else {
2467 | result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; };
2468 | }
2469 |
2470 | return result;
2471 | }
2472 | };
2473 | }
2474 |
2475 | return toBeNaN;
2476 | };
2477 |
2478 | getJasmineRequireObj().toBeNull = function() {
2479 |
2480 | function toBeNull() {
2481 | return {
2482 | compare: function(actual) {
2483 | return {
2484 | pass: actual === null
2485 | };
2486 | }
2487 | };
2488 | }
2489 |
2490 | return toBeNull;
2491 | };
2492 |
2493 | getJasmineRequireObj().toBeTruthy = function() {
2494 |
2495 | function toBeTruthy() {
2496 | return {
2497 | compare: function(actual) {
2498 | return {
2499 | pass: !!actual
2500 | };
2501 | }
2502 | };
2503 | }
2504 |
2505 | return toBeTruthy;
2506 | };
2507 |
2508 | getJasmineRequireObj().toBeUndefined = function() {
2509 |
2510 | function toBeUndefined() {
2511 | return {
2512 | compare: function(actual) {
2513 | return {
2514 | pass: void 0 === actual
2515 | };
2516 | }
2517 | };
2518 | }
2519 |
2520 | return toBeUndefined;
2521 | };
2522 |
2523 | getJasmineRequireObj().toContain = function() {
2524 | function toContain(util, customEqualityTesters) {
2525 | customEqualityTesters = customEqualityTesters || [];
2526 |
2527 | return {
2528 | compare: function(actual, expected) {
2529 |
2530 | return {
2531 | pass: util.contains(actual, expected, customEqualityTesters)
2532 | };
2533 | }
2534 | };
2535 | }
2536 |
2537 | return toContain;
2538 | };
2539 |
2540 | getJasmineRequireObj().toEqual = function() {
2541 |
2542 | function toEqual(util, customEqualityTesters) {
2543 | customEqualityTesters = customEqualityTesters || [];
2544 |
2545 | return {
2546 | compare: function(actual, expected) {
2547 | var result = {
2548 | pass: false
2549 | };
2550 |
2551 | result.pass = util.equals(actual, expected, customEqualityTesters);
2552 |
2553 | return result;
2554 | }
2555 | };
2556 | }
2557 |
2558 | return toEqual;
2559 | };
2560 |
2561 | getJasmineRequireObj().toHaveBeenCalled = function(j$) {
2562 |
2563 | function toHaveBeenCalled() {
2564 | return {
2565 | compare: function(actual) {
2566 | var result = {};
2567 |
2568 | if (!j$.isSpy(actual)) {
2569 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2570 | }
2571 |
2572 | if (arguments.length > 1) {
2573 | throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
2574 | }
2575 |
2576 | result.pass = actual.calls.any();
2577 |
2578 | result.message = result.pass ?
2579 | 'Expected spy ' + actual.and.identity() + ' not to have been called.' :
2580 | 'Expected spy ' + actual.and.identity() + ' to have been called.';
2581 |
2582 | return result;
2583 | }
2584 | };
2585 | }
2586 |
2587 | return toHaveBeenCalled;
2588 | };
2589 |
2590 | getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
2591 |
2592 | function toHaveBeenCalledWith(util, customEqualityTesters) {
2593 | return {
2594 | compare: function() {
2595 | var args = Array.prototype.slice.call(arguments, 0),
2596 | actual = args[0],
2597 | expectedArgs = args.slice(1),
2598 | result = { pass: false };
2599 |
2600 | if (!j$.isSpy(actual)) {
2601 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2602 | }
2603 |
2604 | if (!actual.calls.any()) {
2605 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; };
2606 | return result;
2607 | }
2608 |
2609 | if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
2610 | result.pass = true;
2611 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
2612 | } else {
2613 | 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, '') + '.'; };
2614 | }
2615 |
2616 | return result;
2617 | }
2618 | };
2619 | }
2620 |
2621 | return toHaveBeenCalledWith;
2622 | };
2623 |
2624 | getJasmineRequireObj().toMatch = function() {
2625 |
2626 | function toMatch() {
2627 | return {
2628 | compare: function(actual, expected) {
2629 | var regexp = new RegExp(expected);
2630 |
2631 | return {
2632 | pass: regexp.test(actual)
2633 | };
2634 | }
2635 | };
2636 | }
2637 |
2638 | return toMatch;
2639 | };
2640 |
2641 | getJasmineRequireObj().toThrow = function(j$) {
2642 |
2643 | function toThrow(util) {
2644 | return {
2645 | compare: function(actual, expected) {
2646 | var result = { pass: false },
2647 | threw = false,
2648 | thrown;
2649 |
2650 | if (typeof actual != 'function') {
2651 | throw new Error('Actual is not a Function');
2652 | }
2653 |
2654 | try {
2655 | actual();
2656 | } catch (e) {
2657 | threw = true;
2658 | thrown = e;
2659 | }
2660 |
2661 | if (!threw) {
2662 | result.message = 'Expected function to throw an exception.';
2663 | return result;
2664 | }
2665 |
2666 | if (arguments.length == 1) {
2667 | result.pass = true;
2668 | result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; };
2669 |
2670 | return result;
2671 | }
2672 |
2673 | if (util.equals(thrown, expected)) {
2674 | result.pass = true;
2675 | result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; };
2676 | } else {
2677 | result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; };
2678 | }
2679 |
2680 | return result;
2681 | }
2682 | };
2683 | }
2684 |
2685 | return toThrow;
2686 | };
2687 |
2688 | getJasmineRequireObj().toThrowError = function(j$) {
2689 | function toThrowError (util) {
2690 | return {
2691 | compare: function(actual) {
2692 | var threw = false,
2693 | pass = {pass: true},
2694 | fail = {pass: false},
2695 | thrown;
2696 |
2697 | if (typeof actual != 'function') {
2698 | throw new Error('Actual is not a Function');
2699 | }
2700 |
2701 | var errorMatcher = getMatcher.apply(null, arguments);
2702 |
2703 | try {
2704 | actual();
2705 | } catch (e) {
2706 | threw = true;
2707 | thrown = e;
2708 | }
2709 |
2710 | if (!threw) {
2711 | fail.message = 'Expected function to throw an Error.';
2712 | return fail;
2713 | }
2714 |
2715 | if (!(thrown instanceof Error)) {
2716 | fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; };
2717 | return fail;
2718 | }
2719 |
2720 | if (errorMatcher.hasNoSpecifics()) {
2721 | pass.message = 'Expected function not to throw an Error, but it threw ' + fnNameFor(thrown) + '.';
2722 | return pass;
2723 | }
2724 |
2725 | if (errorMatcher.matches(thrown)) {
2726 | pass.message = function() {
2727 | return 'Expected function not to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + '.';
2728 | };
2729 | return pass;
2730 | } else {
2731 | fail.message = function() {
2732 | return 'Expected function to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() +
2733 | ', but it threw ' + errorMatcher.thrownDescription(thrown) + '.';
2734 | };
2735 | return fail;
2736 | }
2737 | }
2738 | };
2739 |
2740 | function getMatcher() {
2741 | var expected = null,
2742 | errorType = null;
2743 |
2744 | if (arguments.length == 2) {
2745 | expected = arguments[1];
2746 | if (isAnErrorType(expected)) {
2747 | errorType = expected;
2748 | expected = null;
2749 | }
2750 | } else if (arguments.length > 2) {
2751 | errorType = arguments[1];
2752 | expected = arguments[2];
2753 | if (!isAnErrorType(errorType)) {
2754 | throw new Error('Expected error type is not an Error.');
2755 | }
2756 | }
2757 |
2758 | if (expected && !isStringOrRegExp(expected)) {
2759 | if (errorType) {
2760 | throw new Error('Expected error message is not a string or RegExp.');
2761 | } else {
2762 | throw new Error('Expected is not an Error, string, or RegExp.');
2763 | }
2764 | }
2765 |
2766 | function messageMatch(message) {
2767 | if (typeof expected == 'string') {
2768 | return expected == message;
2769 | } else {
2770 | return expected.test(message);
2771 | }
2772 | }
2773 |
2774 | return {
2775 | errorTypeDescription: errorType ? fnNameFor(errorType) : 'an exception',
2776 | thrownDescription: function(thrown) {
2777 | var thrownName = errorType ? fnNameFor(thrown.constructor) : 'an exception',
2778 | thrownMessage = '';
2779 |
2780 | if (expected) {
2781 | thrownMessage = ' with message ' + j$.pp(thrown.message);
2782 | }
2783 |
2784 | return thrownName + thrownMessage;
2785 | },
2786 | messageDescription: function() {
2787 | if (expected === null) {
2788 | return '';
2789 | } else if (expected instanceof RegExp) {
2790 | return ' with a message matching ' + j$.pp(expected);
2791 | } else {
2792 | return ' with message ' + j$.pp(expected);
2793 | }
2794 | },
2795 | hasNoSpecifics: function() {
2796 | return expected === null && errorType === null;
2797 | },
2798 | matches: function(error) {
2799 | return (errorType === null || error.constructor === errorType) &&
2800 | (expected === null || messageMatch(error.message));
2801 | }
2802 | };
2803 | }
2804 |
2805 | function fnNameFor(func) {
2806 | return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
2807 | }
2808 |
2809 | function isStringOrRegExp(potential) {
2810 | return potential instanceof RegExp || (typeof potential == 'string');
2811 | }
2812 |
2813 | function isAnErrorType(type) {
2814 | if (typeof type !== 'function') {
2815 | return false;
2816 | }
2817 |
2818 | var Surrogate = function() {};
2819 | Surrogate.prototype = type.prototype;
2820 | return (new Surrogate()) instanceof Error;
2821 | }
2822 | }
2823 |
2824 | return toThrowError;
2825 | };
2826 |
2827 | getJasmineRequireObj().interface = function(jasmine, env) {
2828 | var jasmineInterface = {
2829 | describe: function(description, specDefinitions) {
2830 | return env.describe(description, specDefinitions);
2831 | },
2832 |
2833 | xdescribe: function(description, specDefinitions) {
2834 | return env.xdescribe(description, specDefinitions);
2835 | },
2836 |
2837 | fdescribe: function(description, specDefinitions) {
2838 | return env.fdescribe(description, specDefinitions);
2839 | },
2840 |
2841 | it: function(desc, func) {
2842 | return env.it(desc, func);
2843 | },
2844 |
2845 | xit: function(desc, func) {
2846 | return env.xit(desc, func);
2847 | },
2848 |
2849 | fit: function(desc, func) {
2850 | return env.fit(desc, func);
2851 | },
2852 |
2853 | beforeEach: function(beforeEachFunction) {
2854 | return env.beforeEach(beforeEachFunction);
2855 | },
2856 |
2857 | afterEach: function(afterEachFunction) {
2858 | return env.afterEach(afterEachFunction);
2859 | },
2860 |
2861 | beforeAll: function(beforeAllFunction) {
2862 | return env.beforeAll(beforeAllFunction);
2863 | },
2864 |
2865 | afterAll: function(afterAllFunction) {
2866 | return env.afterAll(afterAllFunction);
2867 | },
2868 |
2869 | expect: function(actual) {
2870 | return env.expect(actual);
2871 | },
2872 |
2873 | pending: function() {
2874 | return env.pending();
2875 | },
2876 |
2877 | fail: function() {
2878 | return env.fail.apply(env, arguments);
2879 | },
2880 |
2881 | spyOn: function(obj, methodName) {
2882 | return env.spyOn(obj, methodName);
2883 | },
2884 |
2885 | jsApiReporter: new jasmine.JsApiReporter({
2886 | timer: new jasmine.Timer()
2887 | }),
2888 |
2889 | jasmine: jasmine
2890 | };
2891 |
2892 | jasmine.addCustomEqualityTester = function(tester) {
2893 | env.addCustomEqualityTester(tester);
2894 | };
2895 |
2896 | jasmine.addMatchers = function(matchers) {
2897 | return env.addMatchers(matchers);
2898 | };
2899 |
2900 | jasmine.clock = function() {
2901 | return env.clock;
2902 | };
2903 |
2904 | return jasmineInterface;
2905 | };
2906 |
2907 | getJasmineRequireObj().version = function() {
2908 | return '2.1.2';
2909 | };
2910 |
--------------------------------------------------------------------------------
/jasmine/lib/jasmine-2.1.2/jasmine_favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VitskyDs/fend-feedreader/a3fb8b51d735f75a5bdeaceb4f82b5248d7c5ad6/jasmine/lib/jasmine-2.1.2/jasmine_favicon.png
--------------------------------------------------------------------------------
/jasmine/spec/feedreader.js:
--------------------------------------------------------------------------------
1 | /* feedreader.js
2 | *
3 | * This is the spec file that Jasmine will read and contains
4 | * all of the tests that will be run against your application.
5 | */
6 |
7 | /* All of our tests within the $() function,
8 | * since some of these tests may require DOM elements. We want
9 | * to ensure they don't run until the DOM is ready.
10 | */
11 | $(() => {
12 |
13 | describe('RSS Feeds', () => {
14 | /* Tests to make sure that the allFeeds variable has
15 | * been defined and that it is not empty.
16 | */
17 | it('are defined', () => {
18 | expect(allFeeds).toBeDefined();
19 | expect(allFeeds.length).not.toBe(0);
20 | });
21 |
22 | /* Test that loops through each feed
23 | * in the allFeeds object and ensures it has a URL defined
24 | * and that the URL is not empty.
25 | */
26 | it('have a valid url', () => {
27 | allFeeds.forEach((feed) => {
28 | expect(feed.url).toBeDefined();
29 | expect(feed.url.length).toBeGreaterThan(0);
30 | });
31 | });
32 |
33 | /* Test that loops through each feed
34 | * in the allFeeds object and ensures it has a name defined
35 | * and that the name is not empty.
36 | */
37 | it('have a valid name', () => {
38 | allFeeds.forEach((feed) => {
39 | expect(feed.name).toBeDefined();
40 | expect(feed.name.length).toBeGreaterThan(0);
41 | });
42 | });
43 | });
44 |
45 | /* Test suite that checks menu functionality */
46 | describe('The menu', () => {
47 | /* Test that ensures the menu element is
48 | * hidden by default.
49 | */
50 | it('hides the menu by default', () => {
51 | expect($('body').hasClass('menu-hidden')).toBe(true);
52 | });
53 |
54 | /* Test that ensures the menu changes
55 | * visibility when the menu icon is clicked.
56 | */
57 | it('visibility is toggled upon click on menu icon', () => {
58 |
59 | $('.menu-icon-link').click();
60 | expect($('body').hasClass('menu-hidden')).toBe(false);
61 |
62 | $('.menu-icon-link').click();
63 | expect($('body').hasClass('menu-hidden')).toBe(true);
64 | });
65 | });
66 | });
67 |
68 | /* Test suite that checks the loadFeed functionality*/
69 | describe('Initial Entries', () => {
70 |
71 | /* Test that ensures when the loadFeed
72 | * function is called and completes its work, there is at least
73 | * a single .entry element within the .feed container.
74 | */
75 | let feedLength;
76 | beforeEach((done) => {
77 | loadFeed(0, () => {
78 | feedLength = $('.feed .entry').length;
79 | done();
80 | });
81 |
82 | });
83 |
84 | it('has at least one entry', (done) => {
85 | expect(feedLength).toBeGreaterThan(0);
86 | done();
87 | });
88 | });
89 |
90 | /* Test suite that checks the feed functionality*/
91 | describe('New Feed Selection', () => {
92 |
93 | /* Test that ensures when a new feed is loaded
94 | * by the loadFeed function that the content actually changes.
95 | */
96 | let feedA,
97 | feedB;
98 |
99 | beforeEach((done) => {
100 | loadFeed(0, () => {
101 | feedA = document.querySelector('.feed').innerHTML;
102 | });
103 |
104 | loadFeed(1, () => {
105 | feedB = document.querySelector('.feed').innerHTML;
106 | done();
107 | });
108 | });
109 |
110 | /* Check if feeds have been added to the feedList*/
111 | it('loads new feeds', (done) => {
112 | expect(feedB !== feedA).toBe(true);
113 | done();
114 | });
115 | });
116 |
--------------------------------------------------------------------------------
/js/app.js:
--------------------------------------------------------------------------------
1 | /*eslint*/
2 |
3 | /* app.js
4 | *
5 | * This is our RSS feed reader application. It uses the Google
6 | * Feed Reader API to grab RSS feeds as JSON object we can make
7 | * use of. It also uses the Handlebars templating library and
8 | * jQuery.
9 | */
10 |
11 | // The names and URLs to all of the feeds we'd like available.
12 | var allFeeds = [
13 | {
14 | name: 'Udacity Blog',
15 | url: 'http://blog.udacity.com/feed'
16 | }, {
17 | name: 'CSS Tricks',
18 | url: 'http://feeds.feedburner.com/CssTricks'
19 | }, {
20 | name: 'HTML5 Rocks',
21 | url: 'http://feeds.feedburner.com/html5rocks'
22 | }, {
23 | name: 'Linear Digressions',
24 | url: 'http://feeds.feedburner.com/udacity-linear-digressions'
25 | }
26 | ];
27 |
28 | /* This function starts up our application. The Google Feed
29 | * Reader API is loaded asynchonously and will then call this
30 | * function when the API is loaded.
31 | */
32 | function init() {
33 | // Load the first feed we've defined (index of 0).
34 | loadFeed(0);
35 | }
36 |
37 | /* This function performs everything necessary to load a
38 | * feed using the Google Feed Reader API. It will then
39 | * perform all of the DOM operations required to display
40 | * feed entries on the page. Feeds are referenced by their
41 | * index position within the allFeeds array.
42 | * This function all supports a callback as the second parameter
43 | * which will be called after everything has run successfully.
44 | */
45 | function loadFeed(id, cb) {
46 | var feedUrl = allFeeds[id].url,
47 | feedName = allFeeds[id].name;
48 |
49 | $.ajax({
50 | type: "POST",
51 | url: 'https://rsstojson.udacity.com/parseFeed',
52 | data: JSON.stringify({
53 | url: feedUrl
54 | }),
55 | contentType: "application/json",
56 | success: function (result, status) {
57 |
58 | var container = $('.feed'),
59 | title = $('.header-title'),
60 | entries = result.feed.entries,
61 | entriesLen = entries.length,
62 | entryTemplate = Handlebars.compile($('.tpl-entry').html());
63 |
64 | title.html(feedName); // Set the header text
65 | container.empty(); // Empty out all previous entries
66 |
67 | /* Loop through the entries we just loaded via the Google
68 | * Feed Reader API. We'll then parse that entry against the
69 | * entryTemplate (created above using Handlebars) and append
70 | * the resulting HTML to the list of entries on the page.
71 | */
72 | entries.forEach(function (entry) {
73 | container.append(entryTemplate(entry));
74 | });
75 |
76 | if (cb) {
77 | cb();
78 | }
79 | },
80 | error: function (result, status, err) {
81 | //run only the callback without attempting to parse result due to error
82 | if (cb) {
83 | cb();
84 | }
85 | },
86 | dataType: "json"
87 | });
88 | }
89 |
90 | /* Google API: Loads the Feed Reader API and defines what function
91 | * to call when the Feed Reader API is done loading.
92 | */
93 | google.setOnLoadCallback(init);
94 |
95 |
96 | /* All of this functionality is heavily reliant upon the DOM, so we
97 | * place our code in the $() function to ensure it doesn't execute
98 | * until the DOM is ready.
99 | */
100 | $(function () {
101 | var container = $('.feed'),
102 | feedList = $('.feed-list'),
103 | feedItemTemplate = Handlebars.compile($('.tpl-feed-list-item').html()),
104 | feedId = 0,
105 | menuIcon = $('.menu-icon-link');
106 |
107 | /* Loop through all of our feeds, assigning an id property to
108 | * each of the feeds based upon its index within the array.
109 | * Then parse that feed against the feedItemTemplate (created
110 | * above using Handlebars) and append it to the list of all
111 | * available feeds within the menu.
112 | */
113 | allFeeds.forEach(function (feed) {
114 | feed.id = feedId;
115 | feedList.append(feedItemTemplate(feed));
116 |
117 | feedId++;
118 | });
119 |
120 | /* When a link in our feedList is clicked on, we want to hide
121 | * the menu, load the feed, and prevent the default action
122 | * (following the link) from occurring.
123 | */
124 | feedList.on('click', 'a', function () {
125 | var item = $(this);
126 |
127 | $('body').addClass('menu-hidden');
128 | loadFeed(item.data('id'));
129 | return false;
130 | });
131 |
132 | /* When the menu icon is clicked on, we need to toggle a class
133 | * on the body to perform the hiding/showing of our menu.
134 | */
135 | menuIcon.on('click', function () {
136 | $('body').toggleClass('menu-hidden');
137 | });
138 | }());
139 |
--------------------------------------------------------------------------------