bahmutov / lazy-ass

Lazy node assertions without performance penalty
http://glebbahmutov.com/lazy-ass/
MIT License
69 stars 5 forks source link

Describe unit testing with spying on la #7

Closed bahmutov closed 10 years ago

bahmutov commented 10 years ago

Convenient to test on la

it('raises error if load fails', function () {
    spyOn(window, 'la');
    // la(condition, arg1, arg2) will be recorded by the spy
    // but the actual window.la will NOT be called.
    // http://jasmine.github.io/1.3/introduction.html#section-Spies
    // actual window.la will be restored automatically after this spec finishes

    loadFoo('invalid argument');
    $httpBackend.flush();

    // use different alias to window.la to avoid the spy
    lazyAss(window.la.mostRecentCall.args[1] === 'failed to load invalid argument');
  });