mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-01 22:37:41 +08:00
Before we were simply sending the current location, but multiple URLs map to the same document. Now, we use the canonical path of the current document if available and fall back to the $location path otherwise. Includes tests!! Closes #6402
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
describe("DocsController", function() {
|
|
var $scope;
|
|
|
|
angular.module('fake', [])
|
|
.value('$cookies', {})
|
|
.value('NG_PAGES', {})
|
|
.value('NG_NAVIGATION', {})
|
|
.value('NG_VERSION', {});
|
|
|
|
beforeEach(module('fake', 'DocsController'));
|
|
beforeEach(inject(function($rootScope, $controller) {
|
|
$scope = $rootScope;
|
|
$controller('DocsController', { $scope: $scope });
|
|
}));
|
|
|
|
|
|
describe('afterPartialLoaded', function() {
|
|
it("should update the Google Analytics with currentPage path if currentPage exists", inject(function($window) {
|
|
$window._gaq = [];
|
|
$scope.currentPage = { path: 'a/b/c' };
|
|
$scope.afterPartialLoaded();
|
|
expect($window._gaq.pop()).toEqual(['_trackPageview', 'a/b/c']);
|
|
}));
|
|
|
|
|
|
it("should update the Google Analytics with $location.path if currentPage is missing", inject(function($window, $location) {
|
|
$window._gaq = [];
|
|
spyOn($location, 'path').andReturn('x/y/z');
|
|
$scope.afterPartialLoaded();
|
|
expect($window._gaq.pop()).toEqual(['_trackPageview', 'x/y/z']);
|
|
}));
|
|
});
|
|
}); |