Commit Graph

130 Commits

Author SHA1 Message Date
Tobias Bosch
fc706d13d8 fix($location): set baseHref in mock browser to /
Set the default value for the base tag in the mock browser to `/`,
as we now always require a base tag to be present for html5 mode.

Fixes #8866
Closes #8889
2014-09-02 09:54:46 -07:00
Tobias Bosch
3be00df495 fix($browser): detect changes to the browser url that happened in sync
Closes #6976.
2014-08-27 16:36:53 -07:00
Caitlin Potter
ea6fc6e69c feat($http): implement mechanism for coalescing calls to $apply in $http
When multiple responses are received within a short window from each other, it can be wasteful to
perform full dirty-checking cycles for each individual response. In order to prevent this, it is
now possible to coalesce calls to $apply for responses which occur close together.

This behaviour is opt-in, and the default is disabled, in order to avoid breaking tests or
applications.

In order to activate coalesced apply in tests or in an application, simply perform the following
steps during configuration.

   angular.module('myFancyApp', []).
     config(function($httpProvider) {
       $httpProvider.useApplyAsync(true);
     });

OR:

   angular.mock.module(function($httpProvider) {
     $httpProvider.useApplyAsync(true);
   });

Closes #8736
Closes #7634
Closes #5297
2014-08-26 21:42:47 -04:00
Matias Niemelä
bf0f5502b1 feat($animate): use promises instead of callbacks for animations
The $animate service (both the service inside of ng and ngAnimate) now
makes use of promises instead of callback functions.

BREAKING CHANGE

Both the API for the cancallation method and the done callback for
$animate animations is different. Instead of using a callback function
for each of the $animate animation methods, a promise is used instead.

```js
//before
$animate.enter(element, container, null, callbackFn);

//after
$animate.enter(element, container).then(callbackFn);
```

The animation can now be cancelled via `$animate.cancel(promise)`.

```js
//before
var cancelFn = $animate.enter(element, container);
cancelFn(); //cancels the animation

//after
var promise = $animate.enter(element, container);
$animate.cancel(promise); //cancels the animation
```
2014-08-26 11:44:25 -04:00
Igor Minar
1a2caad922 chore(mocks): remove helper fn angular.mocks.clearData
we don't need this any more because Karma reloads the iframe after each test run

Related to #8532
Closes #8618
2014-08-22 15:30:34 -07:00
mishoo78
05791c0133 docs(ngMock): note that inject/module helpers only defined for jasmine / mocha
Closes #8694
2014-08-20 13:43:14 -04:00
Shahar Talmi
477626d846 feat(ngMock): allow override of when/expect definitions
Closes #5766
Closes #8352
2014-08-03 17:08:48 +01:00
Michał Gołębiowski
9e7cb3c375 feat(jQuery): upgrade to jQuery to 2.1.1
The data jQuery method was re-implemented in 2.0 in a secure way. This made
current hacky Angular solution to move data between elements via changing the
value of the internal node[jQuery.expando] stop working. Instead, just copy the
data from the first element to the other one.

Testing cache leaks on jQuery 2.x is not possible in the same way as it's done
in jqLite or in jQuery 1.x as there is no publicly exposed data storage. One
way to test it would be to intercept all places where a jQuery object is created
to save a reference to the underlaying node but there is no single place in the
jQuery code through which all element creation passes (there are various
shortcuts for performance reasons). Instead we rely on jqLite.cache testing
to find potential data leaks.

BREAKING CHANGE: Angular no longer supports jQuery versions below 2.1.1.
2014-07-31 22:20:31 +02:00
Danielle
9836a2d696 docs(ngMockE2E): remove repeated word
Closes #8411
2014-07-31 13:40:33 +01:00
Peter Bacon Darwin
2ad1b4cb9c docs(ngMock) add @packageName tag to fix invalid module overview pages
Closes #7284
Closes #8038
2014-07-21 21:02:22 +01:00
Matias Niemelä
ca752790d9 feat($animate): allow directives to cancel animation events
Closes #7722
2014-07-02 01:03:06 +03:00
rodyhaddad
a1c19c457b chore(ngMock): replace misplaced comma with semicolon 2014-06-26 12:32:01 -07:00
Shahar Talmi
2f0a448873 fix(injector): allow multiple loading of function modules
Change HashMap to give $$hashKey also for functions so it will be possible to load multiple module
function instances. In order to prevent problem in angular's test suite,  added an option to HashMap
to maintain its own id counter and added cleanup of $$hashKey from all module functions after each
test.

Before this CL, functions were added to the HashMap via toString(), which could potentially return
the same value for different actual instances of a function. This corrects this behaviour by
ensuring that functions are mapped with hashKeys, and ensuring that hashKeys are removed from
functions and objects at the end of tests.

In addition to these changes, the injector uses its own set of UIDs in order to prevent confusingly
breaking tests which expect scopes or ng-repeated items to have specific hash keys.

Closes #7255
2014-06-16 20:43:16 -04:00
James Harrison Fisher
68dcb35ff9 docs(ngMock): fix typo providers -> provides
Should be a verb, ☆.。.:・゜☆MERCI BEAUCOUP☆.。.:・゜☆

Closes #7852
2014-06-16 11:45:29 -04:00
Sergei Z
854bf5b74d feat(ngMock): add support of mocha tdd interface
Closes #7489
2014-05-21 10:43:32 -07:00
Dave Smith
e1d6178457 fix($httpBackend): Add missing expectHEAD() method
This was documented but not implemented.

With accompanying unit test to ensure the $httpBackend.expect*() methods exist.

Closes #7320
2014-04-30 18:51:20 -04:00
Søren Louv-Jansen
e19dbc7793 docs(ngMock): fix example for $http respond() helper with function as 1st param
The  `whenPOST` method should return a response object containing status, response body and headers.
If omitted the following error will be thrown:

`Uncaught TypeError: Cannot read property '2' of undefined`

The documentation doesn't make it very clear, so I think it will be appropriate to add it here.

Closes #6761
2014-04-24 09:41:54 -04:00
Chris Wheatley
f0407d2aa0 docs(ngMock): grammar fix
Small grammar fix for mock $httpBackend documentation.
2014-04-18 15:41:26 -04:00
Caitlin Potter
4b1695ec61 feat(injector): "strict-DI" mode which disables "automatic" function annotation
This modifies the injector to prevent automatic annotation from occurring for a given injector.

This behaviour can be enabled when bootstrapping the application by using the attribute
"ng-strict-di" on the root element (the element containing "ng-app"), or alternatively by passing
an object with the property "strictDi" set to "true" in angular.bootstrap, when bootstrapping
manually.

JS example:

    angular.module("name", ["dependencies", "otherdeps"])
      .provider("$willBreak", function() {
        this.$get = function($rootScope) {
        };
      })
      .run(["$willBreak", function($willBreak) {
        // This block will never run because the noMagic flag was set to true,
        // and the $willBreak '$get' function does not have an explicit
        // annotation.
      }]);

    angular.bootstrap(document, ["name"], {
      strictDi: true
    });

HTML:

    <html ng-app="name" ng-strict-di>
      <!-- ... -->
    </html>

This will only affect functions with an arity greater than 0, and without an $inject property.

Closes #6719
Closes #6717
Closes #4504
Closes #6069
Closes #3611
2014-04-10 17:51:15 -04:00
Tyler McGinnis
f45241649b docs(ngMock): fix typo
"register" should be "registered"

Closes #7034
2014-04-07 16:33:20 -04:00
jim lyndon
1d2414ca93 feat($http): add xhr statusText to completeRequest callback
Makes xhr status text accessible is $http success/error callback.
See www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-statustext

Closes #2335
Closes #2665
Closes #6713
2014-03-27 17:08:23 -04:00
Igor Minar
2b84f43a6d style(ngMocks): remove ws 2014-03-18 15:54:17 -07:00
Caio Cunha
d6cfcacee1 feat(ngMock.$httpBackend): added support for function as URL matcher
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-03-18 15:19:26 -07:00
Nick Heiner
79592ce9e2 docs(ngMock): grammar nitpick. 2014-03-13 16:52:59 -07:00
MikeMcElroy
9bffccd935 docs($interval): cancel() takes a promise not a number
Closes #6485
2014-03-02 16:07:44 +00:00
thenickcox
3248233f5e docs(ngMock): fixes in flush() documentation
The docs for the `flush()` method contained a few grammatical
errors and were awkwardly worded. Change the explanation of
the method to remove errors and read more naturally.

Closes #4886
2014-03-02 13:55:51 +01:00
Matias Niemelä
4c4537e65e perf($animate): use rAF instead of timeouts to issue animation callbacks 2014-02-24 21:23:18 -05:00
Matias Niemelä
62761428ef chore(core): create a wrapper to manage async callbacks 2014-02-24 21:23:10 -05:00
Matias Niemelä
04d7317cdd chore(core): introduce a wrapper for requestAnimationFrame 2014-02-24 21:23:05 -05:00
Peter Bacon Darwin
4a6a3ba7fb docs(*): fix anchors for members in api docs 2014-02-21 19:37:37 +00:00
Sadaoui Abderrahim
7cd79b6f8f docs(ngMock.$interval): fix return description
Closes #6384
2014-02-21 13:48:01 +00:00
Sadaoui Abderrahim
6082e2ad16 docs(ngMock): document method ngMock.$interval#cancel()
I have been looking around and was not able to find any informations on how to clear the $interval
but reading the source code, sharing is caring!

Closes #6367
2014-02-20 10:43:05 -05:00
Peter Bacon Darwin
cc1f7539d4 docs(modules): remove unused {@installModule} tags 2014-02-19 21:22:27 +00:00
Peter Bacon Darwin
2f7c57233a docs(bike-shed-migration): let markdown deal with extenal links
It is problematic to use {@link} tags with external links because the
markdown parser converts them to links for us before we parse the @links.
This means that the following tag:

```
{@link http://www.google.com Google}
```

get converted to:

```
{@link <a href="http://www.google.com/"></a> Google}
```

Our {@link} parser then converts this to:

```
<a href="<a">&lt;</a>href="http://www.google.com/"></a> Google}
```

which is clearly a mess.  The best solution is not to use {@link} tags
for external links and just use the standard markdown syntax:

```
[Google](http://www.google.com)
```

In the long run, we could look into configuring or modifying `marked` not
to convert these external links or we could provide a "pre-parser"
processor that dealt with such links before `marked` gets its hands on it.
2014-02-16 19:03:41 +00:00
Caitlin Potter
f7d28cd377 docs(all): convert <pre>/</pre> snippets to GFM snippets 2014-02-16 19:03:40 +00:00
Peter Bacon Darwin
2e641ac49f docs(bike-shed-migration): convert doctype and names 2014-02-16 19:03:40 +00:00
Matias Niemelä
4f84f6b3e4 fix($animate): ensure $animate doesn't break natural CSS transitions
BREAKING CHANGE: ngClass and {{ class }} will now call the `setClass`
animation callback instead of addClass / removeClass when both a
addClass/removeClass operation is being executed on the element during the animation.

Please include the setClass animation callback as well as addClass and removeClass within
your JS animations to work with ngClass and {{ class }} directives.

Closes #6019
2014-02-14 16:30:48 -08:00
Igor Minar
d5c7ef0f78 revert: refactor(mocks): simplify the inject implementation
This reverts commit 64d58a5b52.

For some weird reason this is causing regressions at Google.
I'm not sure why and I'm running out of time to investigate, so I'm taking
a safe route here and reverting the commit since it's just a refactoring.
2014-02-07 12:14:32 -08:00
Matias Niemelä
4224cd5182 fix(mocks): rename mock.animate to ngAnimateMock and ensure it contains all test helper code for ngAnimate
Closes #5822
Closes #5917
2014-02-06 01:22:14 -05:00
Matias Niemelä
906fdad0f9 fix(mocks): remove usage of $animate.flushNext in favour of queing
The flushNext method of testing is difficult and highly coupled with the behavior
of ngAnimate's $animate workflow. It is much better instead to just queue all
$animate animation calls into a queue collection which is available on the $animate
service when mock.animate is included as a module within test code.
2014-02-06 01:21:41 -05:00
Daniel Luxemburg
dd24c78373 fix(ngMock): return false from mock $interval.cancel() when no argument is supplied
Closes #6103.
Closed #6099.
2014-02-04 16:41:25 -08:00
Igor Minar
64d58a5b52 refactor(mocks): simplify the implementation 2014-02-03 22:41:18 -08:00
Wes Alvaro
3bf4390339 fix(mocks): always call functions injected with inject with this set to 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-02-03 22:25:30 -08:00
Shawn Flahave
29432ffe37 Edited the 'Flushing HTTP requests' section
Minor grammatical edits in the Flushing HTTP requests section.
2014-01-30 16:52:06 -08:00
John Papa
95f0bf9b52 fix(mocks): refactor currentSpec to work w/ Jasmine 2
Closes #5662
2014-01-27 22:26:18 -08:00
Peter Bacon Darwin
5e9835b4f2 docs(ngdoc): ensure module installation docs are accurate
The ngMock module is built into a package called angular-mocks, which is
not named consistently and the docs were giving invalid info.

Closes #5810
2014-01-23 17:27:30 +00:00
gabrielbrasil
ec59be67bc docs(ngMock): $log.error property contains messages from $log.error, not $log.log
Closes #5932
2014-01-22 11:34:56 -05:00
Matias Niemelä
1413328e6a fix(ngMock): ensure ngAnimate isn't a required mock 2014-01-15 03:43:52 -05:00
Matias Niemelä
4ae3184c59 feat($animate): use requestAnimationFrame instead of a timeout to issue a reflow
Closes #4278
Closes #4225
2014-01-14 13:21:19 -05:00
Andrew C. Greenberg
7e916455b3 fix(ngMock window.inject): Remove Error 'stack' property changes
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.
2014-01-06 17:47:06 -08:00