From 500ecda30d0c997e80bbb536640bdf9c27a40c3d Mon Sep 17 00:00:00 2001 From: christopherthielen Date: Sat, 23 Jan 2016 20:28:23 -0600 Subject: [PATCH] cherry-pick 41acad8 from 0.2.17 --- test/testUtils.js | 8 +++++++- test/urlMatcherFactorySpec.js | 2 +- test/urlRouterSpec.js | 4 ++-- test/viewDirectiveSpec.js | 15 ++++++++++----- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/test/testUtils.js b/test/testUtils.js index d6a8c40ee..5983b199b 100644 --- a/test/testUtils.js +++ b/test/testUtils.js @@ -2,7 +2,13 @@ /// // 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(); diff --git a/test/urlMatcherFactorySpec.js b/test/urlMatcherFactorySpec.js index 7dfee8874..87891ca68 100644 --- a/test/urlMatcherFactorySpec.js +++ b/test/urlMatcherFactorySpec.js @@ -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; diff --git a/test/urlRouterSpec.js b/test/urlRouterSpec.js index 8b740d40d..bce2ad40f 100644 --- a/test/urlRouterSpec.js +++ b/test/urlRouterSpec.js @@ -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; }); @@ -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; diff --git a/test/viewDirectiveSpec.js b/test/viewDirectiveSpec.js index 5083f1a10..b1d329d55 100644 --- a/test/viewDirectiveSpec.js +++ b/test/viewDirectiveSpec.js @@ -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'; @@ -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;'); @@ -297,7 +302,7 @@ describe('uiView', function () { $state.transitionTo(aState); $q.flush(); - if ($animate) $animate.triggerCallbacks(); + animateFlush($animate); expect($uiViewScroll).not.toHaveBeenCalled(); })); @@ -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()); })); @@ -320,7 +325,7 @@ describe('uiView', function () { $state.transitionTo(aState); $q.flush(); - if ($animate) $animate.triggerCallbacks(); + animateFlush($animate); expect($uiViewScroll).not.toHaveBeenCalled(); @@ -328,7 +333,7 @@ describe('uiView', function () { $state.transitionTo(bState); $q.flush(); - if ($animate) $animate.triggerCallbacks(); + animateFlush($animate); var target, index = -1,