From af5570fac711ce578b4564ff8af8d14982268847 Mon Sep 17 00:00:00 2001 From: Julie Date: Sun, 12 Jan 2014 12:32:39 -0800 Subject: [PATCH] tests(routing): add a test for synchronization with slow routing --- spec/basic/synchronize_spec.js | 13 ++++++++++++- testapp/app.js | 9 +++++++++ testapp/async/async.html | 4 ++++ testapp/async/async.js | 12 +++++++++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/spec/basic/synchronize_spec.js b/spec/basic/synchronize_spec.js index 3378bd3b9..c19ca850b 100644 --- a/spec/basic/synchronize_spec.js +++ b/spec/basic/synchronize_spec.js @@ -1,6 +1,6 @@ var util = require('util'); -describe('synchronizing with slow pages', function() { +ddescribe('synchronizing with slow pages', function() { beforeEach(function() { browser.get('index.html#/async'); }); @@ -72,4 +72,15 @@ describe('synchronizing with slow pages', function() { expect(status.getText()).toEqual('done'); }); + + it('waits for slow routing changes', function() { + var status = element(by.binding('routingChangeStatus')); + var button = element(by.css('[ng-click="routingChange()"]')); + + expect(status.getText()).toEqual('not started'); + + button.click(); + + expect(browser.getPageSource()).toMatch('polling mechanism'); + }); }); diff --git a/testapp/app.js b/testapp/app.js index 2f786c46b..6f27cf3b9 100644 --- a/testapp/app.js +++ b/testapp/app.js @@ -10,5 +10,14 @@ angular.module('myApp', ['ngRoute', 'myApp.appVersion']). $routeProvider.when('/async', {templateUrl: 'async/async.html', controller: AsyncCtrl}); $routeProvider.when('/conflict', {templateUrl: 'conflict/conflict.html', controller: ConflictCtrl}); $routeProvider.when('/polling', {templateUrl: 'polling/polling.html', controller: PollingCtrl}); + $routeProvider.when('/slowloader', { + templateUrl: 'polling/polling.html', + controller: PollingCtrl, + resolve: { + slow: function($timeout) { + return $timeout(function() {}, 2000); + } + } + }); $routeProvider.otherwise({redirectTo: '/form'}); }]); diff --git a/testapp/async/async.html b/testapp/async/async.html index 65c037fff..427b4b914 100644 --- a/testapp/async/async.html +++ b/testapp/async/async.html @@ -24,4 +24,8 @@ +
  • + + +
  • diff --git a/testapp/async/async.js b/testapp/async/async.js index bb5bb2221..c62a931ac 100644 --- a/testapp/async/async.js +++ b/testapp/async/async.js @@ -1,10 +1,11 @@ -function AsyncCtrl($scope, $http, $timeout) { +function AsyncCtrl($scope, $http, $timeout, $location) { $scope.slowHttpStatus = 'not started'; $scope.slowFunctionStatus = 'not started'; $scope.slowTimeoutStatus = 'not started'; $scope.slowAngularTimeoutStatus = 'not started'; $scope.slowAngularTimeoutPromiseStatus = 'not started'; $scope.slowHttpPromiseStatus = 'not started'; + $scope.routingChangeStatus = 'not started'; $scope.slowHttp = function() { $scope.slowHttpStatus = 'pending...'; @@ -53,7 +54,12 @@ function AsyncCtrl($scope, $http, $timeout) { }).then(function() { $scope.slowHttpPromiseStatus = 'done'; }); - } + }; + + $scope.routingChange = function() { + $scope.routingChangeStatus = 'pending...'; + $location.url('/slowloader'); + }; }; -AsyncCtrl.$inject = ['$scope', '$http', '$timeout']; +AsyncCtrl.$inject = ['$scope', '$http', '$timeout', '$location'];