aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/templates/css
'use strict';

describe('$timeout', function() {

  beforeEach(module(provideLog));


  it('should delegate functions to $browser.defer', inject(function($timeout, $browser) {
    var counter = 0;
    $timeout(function() { counter++; });

    expect(counter).toBe(0);

    $browser.defer.flush();
    expect(counter).toBe(1);

    expect(function() {$browser.defer.flush();}).toThrow('No deferred tasks to be flushed');
    expect(counter).toBe(1);
  }));


  it('should call $apply after each callback is executed', inject(function($timeout, $rootScope) {
    var applySpy = spyOn($rootScope, '$apply').andCallThrough();

    $timeout(function() {});
    expect(applySpy).not.toHaveBeenCalled();

    $timeout.flush();
    expect(applySpy).toHaveBeenCalledOnce();

    applySpy.reset();

    $timeout(function() {});
    $timeout(function() {});
    $timeout.flush();
    expect(<
AgeCommit message (Expand)Author
2013-10-10chore(ngdocs): improve the side search animation effectsMatias Niemelä
2013-09-26docs(minerr): fix bad line wrap due to errand nowrap in CSSBrian Ford
2013-09-25docs(docs.css): prevent `<code>` elements from wrappingMisha Moroshko
2013-08-30fix(guide) broken title overflow in navlistgdi2290
2013-08-23fix($animate): skip ngAnimate animations if the provided element already has ...Matias Niemelä
2013-08-16fix(docs): wrap error message text inside boxKen Sheedlo
2013-07-31docs(header): replace logo.png with logo.svgBrenton
2013-07-29chore(ngdocs): all animation-supported directives working with docs examples ...Matias Niemelä
2013-07-27fix(docs): fix margin around nav-list itemsKen Sheedlo
2013-07-26chore(ngdocs): fix docs search to properly hide the X button when collapsedMatias Niemelä
2013-07-26fix(ngInclude): $animate refactoring + use transclusionMatias Niemelä
2013-07-26feat(ngAnimate): complete rewrite of animationsMatias Niemelä
2013-07-24docs(minErr): Build minErr doc siteKen Sheedlo
2013-07-18chore(ngdocs): fix improve button overlapMatias Niemelä
2013-07-12chore(ngdoc): wrap all pages inside of a container tag for easy stylingMatias Niemelä
2013-07-12style(ngdocs): fix minor CSS issuesAlex Olshansky
2013-07-11feat(ngDocs): add links to source for APIJulien Bouquillon
2013-06-18chore(ngdocs): provide test code for lunr search in docs
span class="p">('should NOT call $apply if skipApply is set to true', inject(function($timeout, $rootScope) { var applySpy = spyOn($rootScope, '$apply').andCallThrough(); $timeout(function() {}, 12, false); expect(applySpy).not.toHaveBeenCalled(); $timeout.flush(); expect(applySpy).not.toHaveBeenCalled(); })); it('should allow you to specify the delay time', inject(function($timeout, $browser) { var defer = spyOn($browser, 'defer'); $timeout(noop, 123); expect(defer.callCount).toEqual(1); expect(defer.mostRecentCall.args[1]).toEqual(123); })); it('should return a promise which will be resolved with return value of the timeout callback', inject(function($timeout, log) { var promise = $timeout(function() { log('timeout'); return 'buba'; }); promise.then(function(value) { log('promise success: ' + value); }, log.fn('promise error')); expect(log).toEqual([]); $timeout.flush(); expect(log).toEqual(['timeout', 'promise success: buba']); })); describe('exception handling', function() { beforeEach(module(function($exceptionHandlerProvider) { $exceptionHandlerProvider.mode('log'); })); it('should delegate exception to the $exceptionHandler service', inject( function($timeout, $exceptionHandler) { $timeout(function() {throw "Test Error";}); expect($exceptionHandler.errors).toEqual([]); $timeout.flush(); expect($exceptionHandler.errors).toEqual(["Test Error"]); })); it('should call $apply even if an exception is thrown in callback', inject( function($timeout, $rootScope) { var applySpy = spyOn($rootScope, '$apply').andCallThrough(); $timeout(function() {throw "Test Error";}); expect(applySpy).not.toHaveBeenCalled(); $timeout.flush(); expect(applySpy).toHaveBeenCalled(); })); it('should reject the timeout promise when an exception is thrown in the timeout callback', inject(function($timeout, log) { var promise = $timeout(function() { throw "Some Error"; }); promise.then(log.fn('success'), function(reason) { log('error: ' + reason); }); $timeout.flush(); expect(log).toEqual('error: Some Error'); })); }); describe('cancel', function() { it('should cancel tasks', inject(function($timeout) { var task1 = jasmine.createSpy('task1'), task2 = jasmine.createSpy('task2'), task3 = jasmine.createSpy('task3'), promise1, promise3; promise1 = $timeout(task1); $timeout(task2); promise3 = $timeout(task3, 333); $timeout.cancel(promise3); $timeout.cancel(promise1); $timeout.flush(); expect(task1).not.toHaveBeenCalled(); expect(task2).toHaveBeenCalledOnce(); expect(task3).not.toHaveBeenCalled(); })); it('should return true if a task was successfully canceled', inject(function($timeout) { var task1 = jasmine.createSpy('task1'), task2 = jasmine.createSpy('task2'), promise1, promise2; promise1 = $timeout(task1); $timeout.flush(); promise2 = $timeout(task2); expect($timeout.cancel(promise1)).toBe(false); expect($timeout.cancel(promise2)).toBe(true); })); it('should not throw a runtime exception when given an undefined promise', inject(function($timeout) { expect($timeout.cancel()).toBe(false); })); }); });