Skip to content

Commit

Permalink
cherry-pick 41acad8 from 0.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jan 31, 2016
1 parent 91c1ff1 commit 500ecda
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
8 changes: 7 additions & 1 deletion test/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
/// <reference path='../typings/jasmine/jasmine.d.ts' />

// Promise testing support
angular.module('ngMock').config(function ($provide) {
angular.module('ngMock').config(function ($provide, $locationProvider) {
var oldFn = $locationProvider.html5Mode;
$locationProvider.html5Mode = function() {
var retval = oldFn.apply($locationProvider, arguments);
return (angular.isDefined(retval) && angular.isDefined(retval.enabled)) ? retval.enabled : retval;
};

$provide.decorator('$q', function ($delegate, $rootScope) {
$delegate.flush = function() {
$rootScope.$digest();
Expand Down
2 changes: 1 addition & 1 deletion test/urlMatcherFactorySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var common = uiRouter.common;
var prop = common.prop;

beforeEach(function() {
var app = angular.module('ui.router.router.test', function () { });
var app = angular.module('ui.router.router.test', []);
app.config(function ($urlMatcherFactoryProvider) {
provider = $urlMatcherFactoryProvider;
UrlMatcher = provider.UrlMatcher;
Expand Down
4 changes: 2 additions & 2 deletions test/urlRouterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("UrlRouter", function () {
describe("provider", function () {

beforeEach(function() {
angular.module('ui.router.router.test', function() {}).config(function ($urlRouterProvider) {
angular.module('ui.router.router.test', []).config(function ($urlRouterProvider) {
$urlRouterProvider.deferIntercept();
$urp = $urlRouterProvider;
});
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("UrlRouter", function () {
describe("service", function() {

beforeEach(function() {
angular.module('ui.router.router.test', function() {}).config(function ($urlRouterProvider, $locationProvider) {
angular.module('ui.router.router.test', []).config(function ($urlRouterProvider, $locationProvider) {
$urp = $urlRouterProvider;
$lp = $locationProvider;

Expand Down
15 changes: 10 additions & 5 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var module = angular.mock.module;
var uiRouter = require("angular-ui-router");

function animateFlush($animate) {
$animate && $animate.triggerCallbacks && $animate.triggerCallbacks(); // 1.2-1.3
$animate && $animate.flush && $animate.flush(); // 1.4
}

describe('uiView', function () {
'use strict';

Expand Down Expand Up @@ -160,7 +165,7 @@ describe('uiView', function () {
$q.flush();
if ($animate) {
expect(log).toBe('m;n;');
$animate.triggerCallbacks();
animateFlush($animate);
expect(log).toBe('m;n;$destroy(m);');
} else {
expect(log).toBe('m;$destroy(m);n;');
Expand Down Expand Up @@ -297,7 +302,7 @@ describe('uiView', function () {
$state.transitionTo(aState);
$q.flush();

if ($animate) $animate.triggerCallbacks();
animateFlush($animate);

expect($uiViewScroll).not.toHaveBeenCalled();
}));
Expand All @@ -307,7 +312,7 @@ describe('uiView', function () {
$state.transitionTo(aState);
$q.flush();

if ($animate) $animate.triggerCallbacks();
animateFlush($animate);

expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
}));
Expand All @@ -320,15 +325,15 @@ describe('uiView', function () {
$state.transitionTo(aState);
$q.flush();

if ($animate) $animate.triggerCallbacks();
animateFlush($animate);

expect($uiViewScroll).not.toHaveBeenCalled();

scope.doScroll = true;
$state.transitionTo(bState);
$q.flush();

if ($animate) $animate.triggerCallbacks();
animateFlush($animate);

var target,
index = -1,
Expand Down

0 comments on commit 500ecda

Please sign in to comment.