9360aa2d27
The quotes rule had to be disabled for e2e tests generated from ngdoc because dgeni templates use double quotes as string delimiters. Since we can't have guarantees that dgeni template wrappers will follow the same JS code style the Angular 1 repo uses, we should find a way to enforce our ESLint setup only for the parts in this repo, perhaps via prepending a generated `/* eslint-enable OUR_RULES */` pragma. Closes #15011
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
describe('$document', function() {
|
|
|
|
|
|
it('should inject $document', inject(function($document) {
|
|
expect($document).toEqual(jqLite(window.document));
|
|
}));
|
|
|
|
|
|
it('should be able to mock $document object', function() {
|
|
module({$document: {}});
|
|
inject(function($httpBackend, $http) {
|
|
$httpBackend.expectGET('/dummy').respond('dummy');
|
|
$http.get('/dummy');
|
|
$httpBackend.flush();
|
|
});
|
|
});
|
|
|
|
|
|
it('should be able to mock $document array', function() {
|
|
module({$document: [{}]});
|
|
inject(function($httpBackend, $http) {
|
|
$httpBackend.expectGET('/dummy').respond('dummy');
|
|
$http.get('/dummy');
|
|
$httpBackend.flush();
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
describe('$$isDocumentHidden', function() {
|
|
it('should listen on the visibilitychange event', function() {
|
|
var doc;
|
|
|
|
var spy = spyOn(window.document, 'addEventListener').and.callThrough();
|
|
|
|
inject(function($$isDocumentHidden, $document) {
|
|
expect(spy.calls.mostRecent().args[0]).toBe('visibilitychange');
|
|
expect(spy.calls.mostRecent().args[1]).toEqual(jasmine.any(Function));
|
|
expect($$isDocumentHidden()).toBeFalsy(); // undefined in browsers that don't support visibility
|
|
});
|
|
|
|
});
|
|
|
|
it('should remove the listener when the $rootScope is destroyed', function() {
|
|
var spy = spyOn(window.document, 'removeEventListener').and.callThrough();
|
|
|
|
inject(function($$isDocumentHidden, $rootScope) {
|
|
$rootScope.$destroy();
|
|
expect(spy.calls.mostRecent().args[0]).toBe('visibilitychange');
|
|
expect(spy.calls.mostRecent().args[1]).toEqual(jasmine.any(Function));
|
|
});
|
|
});
|
|
});
|