aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngMock/angular-mocksSpec.js
AgeCommit message (Collapse)Author
2014-03-18test(ngMock): workaround issue with negative timestampsBrett Porter
In some specific timezones and operating systems, it seems that getTimezoneOffset() can return an incorrect value for negative timestamps, as described in #5017. While this isn't something easily fixed in the mock code, the tests can avoid that particular timeframe by using a positive timestamp. Closes #5017 Closes #6730
2014-03-18feat(ngMock.$httpBackend): added support for function as URL matcherCaio Cunha
It's now possible to pass a function to match the URL in $httpBackend mocked expectations. This gives a more sophisticate control over the URL matching without requiring complex RegExp mantainance or the workaround of creating an object with a `test` function in order to mimic RegExp interface. This approach was suggested in [this thread](https://groups.google.com/d/msg/angular/3QsCUEvvxlM/Q4C4ZIqNIuEJ) Closes #4580
2014-02-04fix(ngMock): return false from mock $interval.cancel() when no argument is ↵Daniel Luxemburg
supplied Closes #6103. Closed #6099.
2014-02-03fix(mocks): always call functions injected with `inject` with `this` set to ↵Wes Alvaro
the current spec Currently when a function is injected inside of a test we set the context to undefined which is a bug. Closes #6102
2014-01-06test(ngMock): fix the tests to not use global msieVojta Jina
My bad when merging 7e916455b36dc9ca4d4afc1e44cade90006d00e3. These tests are run with compiled Angular and then the msie is not defined.
2014-01-06fix(ngMock window.inject): Remove Error 'stack' property changesAndrew C. Greenberg
Recent browsers, particularly PhantomJS 1.9.2 and Safari 7.0 treat the stack property as non-configurable and unwritable. Because window.inject captures the stack at the time of the inject, and attempts to insert it into a captured throw from the injected function by modifying e.stack, a meaningless error message and stack is thrown instead. This commit inserts two tests exposing the problem, and implements a proposed solution that builds a new error-like object that mimicks the old Error object, but with the additional stack information, and captures the toString function from the Error object prototype. This appears to work for the browsers suppoerted here.
2013-12-11fix(angular-mocks): use copy of mock data in $httpBackendKarl Seamon
Copy mock data returned from the mock $httpBackend. This prevents modifications to the response from affecting future responses. Previously, this misbehavior was being mitigated by the deep copy in $resource, but that no longer exists.
2013-11-21fix(ngMock): fixes httpBackend expectation with body objectCorey Burrows
Fixes an issue with httpBackend expectations where a given body object may not match the actual request body if its keys are serialized in a different order. Closes #4956
2013-11-21fix(tests): Correct tests for IE11Tobias Bosch
Some tests were wrong. However, src/* did not contain problems. Fixes #5046
2013-10-10fix(modules): stop leaking global variables in testsPete Bacon Darwin
The routeUtils.js file was declaring a number of functions that were leaking into other modules such as ngMocks causing tests to pass incorrectly. Closes #4360
2013-10-07feat($interval): add a service wrapping setIntervalJulie
The $interval service simplifies creating and testing recurring tasks. This service does not increment $browser's outstanding request count, which means that scenario tests and Protractor tests will not timeout when a site uses a polling function registered by $interval. Provides a workaround for #2402. For unit tests, repeated tasks can be controlled using ngMock$interval's tick(), tickNext(), and tickAll() functions.
2013-10-07fix(*): protect calls to hasOwnProperty in public APIPeter Bacon Darwin
Objects received from outside AngularJS may have had their `hasOwnProperty` method overridden with something else. In cases where we can do this without incurring a performance penalty we call directly on Object.prototype.hasOwnProperty to ensure that we use the correct method. Also, we have some internal hash objects, where the keys for the map are provided from outside AngularJS. In such cases we either prevent `hasOwnProperty` from being used as a key or provide some other way of preventing our objects from having their `hasOwnProperty` overridden. BREAKING CHANGE: Inputs with name equal to "hasOwnProperty" are not allowed inside form or ngForm directives. Before, inputs whose name was "hasOwnProperty" were quietly ignored and not added to the scope. Now a badname exception is thrown. Using "hasOwnProperty" for an input name would be very unusual and bad practice. Either do not include such an input in a `form` or `ngForm` directive or change the name of the input. Closes #3331
2013-10-02feat(ngMock.$timeout): remove flushNext methodVojta Jina
2013-09-03feat(ngMock): allow passing an object literal as shorthand to moduleMerrick Christensen
2013-08-27revert: feat(mocks): make $timeout#flush throw an exception when emptyIgor Minar
This reverts commit cbf06a5d64aba537f0e2679a194d3998d8365493. This turned out to be a bad idea because it allow us to fast-forward the wall clock time (see previous commit).
2013-08-27revert: fix(mocks): $timeout#flush should not update time when emptyIgor Minar
This reverts commit 42af8eada2803a54a98b4f792e60feb480d68a0c. This turned out to be a bad idea as it prevents us from moving the time forward and asserting that the component state didn't change due to the scheduled task executing too early.
2013-08-25fix(mocks): $timeout#flush should not update time when emptyIgor Minar
When $timeout#flush is called with a delay and no task can be flushed within that delay, the current time should not be updated as that gets the mock into an inconsistent state. BREAKING CHANGE: if a tests was written around the buggy behavior the delays might be off now This would typically not be a problem, but because of the previous breaking change in $timeout.flush, the combination of two might be confusing and that's why we are documenting it. Old behavior: ``` doSomething(); //schedules task to execute in 500ms from now doOtherStuff(); //schedules task to execute in 600ms from now try { $timeout.flush(300); // throws "no task to be flushed" exception } catch(e) {}; $time.flush(200); //flushes only doSomething() task ``` New behavior: ``` doSomething(); //schedules task to execute in 500ms from now doOtherStuff(); //schedules task to execute in 600ms from now try { $timeout.flush(300); // throws "no task to be flushed" exception } catch(e) {}; $time.flush(200); // throws "no task to be flushed" exception again // because previous exception didn't move the time forward ``` Fixed test: ``` doSomething(); //schedules task to execute in 500ms from now doOtherStuff(); //schedules task to execute in 600ms from now try { $timeout.flush(300); // throws "no task to be flushed" exception } catch(e) {}; $time.flush(500); // flushes only doSomething() task ```
2013-08-25feat(mocks): make $timeout#flush throw an exception when emptyIgor Minar
When calling $timeout.flush with or without a delay an exception should be thrown if there is nothing to be flushed. This prevents tests from flushing stuff unnecessarily. BREAKING CHANGE: calling $timeout.flush(delay) when there is no task to be flushed within the delay throws an exception now. Please adjust the delay or remove the flush call from your tests as the exception is a signed of a programming error.
2013-08-23test: rename / remove duplicate unit testsVojta Jina
2013-08-06feat(ngMock/$httpBackend): support a matching function for data paramKen Chen
Add support for passing function as validating data: - To avoid hacking test method of RegExp - Optionally overwrite `toString` method of fn to show validation tips - change docs: param description for `when`, `whenPost`, `whenPut`, `expect`, `expectPost`, `expectPut`, `expectPATCH` Closes: #2981
2013-08-01fix(ngMock): keep withCredentials on passThroughÉtienne Barrié
When using passThrough() and specifying withCredentials on the $http call, the option is now passed to the underlying $httpBackend.
2013-07-31fix(mock.$log): keep in sync with $logChirayu Krishnappa
Closes #2343
2013-07-26feat(ngMock): $timeout.flushNext can expect specific timeout delaysMatias Niemelä
the $timeout mock's flush method allows flushing queued up requests but doesn't allow to for checking with what delay a task was queued up. flushNext flushes the next queued up task and can asserts the scheduled delay.
2013-07-26feat(ngMock): support delay limit for $timeout.flushMatias Niemelä
2013-07-22chore(dump): remove dead codeIgor Minar
This code is not being used any more and the test is now failing due to Karma changes. Karma used to expose window.dump but that changed recently and that's why our build is now failing. I'm removing the code and test, but we still need to figure out how to route window.dump through angular.mock.dump, but that will have to be a separate commit.
2013-06-19feat(jqLite): switch bind/unbind to more recent jQuery on/offMichał Gołębiowski
jQuery switched to a completely new event binding implementation as of 1.7.0, centering around on/off methods instead of previous bind/unbind. This patch makes jqLite match this implementation while still supporting previous bind/unbind methods.
2013-05-20feat($http): add support for aborting via timeout promisesDavid Bennett
If the timeout argument is a promise, abort the request when it is resolved. Implemented by adding support to $httpBackend service and $httpBackend mock service. This api can also be used to explicitly abort requests while keeping the communication between the deffered and promise unidirectional. Closes #1159
2013-02-07feat(dateFilter): add `[.,]sss` formatter for millisecondsMaxim Grach
Also Implement getMilliseconds() method of TzDate and add test for this in ngMock.
2012-12-20feat($timeout-mock): add verifyNoPendingTasks methodpetrovalex
added verifyNoPendingTasks method, which throws error if not all deferred tasks have been flushed Closes #1245
2012-06-12fix($defer): remove deprecated $defer serviceIgor Minar
2012-06-02feat($rootElement): added application root elementMisko Hevery
Publish the application root element as $rootElement so that it can be injected to other services.
2012-05-23feat($timeout): add $timeout service that supersedes $deferIgor Minar
$timeout has a better name ($defer got often confused with something related to $q) and is actually promise based with cancelation support. With this commit the $defer service is deprecated and will be removed before 1.0. Closes #704, #532
2012-05-17fix(jqLite): have same expando format as jQueryMisko Hevery
2012-05-14fix(jqLite): .data()/.bind() memory leakMisko Hevery
Since angular attaches scope/injector/controller into DOM it should clean up after itself. No need to complain about memory leaks, since they can only happened on detached DOM. Detached DOM would only be in tests, since in production the DOM would be attached to render tree and removal would automatically clear memory.
2012-04-20feat($resource): support HTTP PATCH methodsimpulton
Properly serialize data into request body instead of url. Closes #887
2012-04-09chore($browser): remove the addJs methodIgor Minar
this was never meant to be a public api used by apps. I refactored the code to hide the functionality. BREAKING CHANGE: $browser.addJs method was removed apps that depended on this functionality should either use many of the existing script loaders or create a simple helper method specific to the app.
2012-03-28feat(TzDate): add support for toISOString methodIgor Minar
2012-03-28chore(Rakefile): get ready for modulesMisko Hevery
2012-03-28chore(module): move files around in preparation for more modulesMisko Hevery