blob: 6c15e2d2984cb386ce353f39cdac11958bed3c92 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 | 'use strict';
describe('$$rAF', function() {
  it('should queue and block animation frames', inject(function($$rAF) {
    if(!$$rAF.supported) return;
    var message;
    $$rAF(function() {
      message = 'yes';
    });
    expect(message).toBeUndefined();
    $$rAF.flush();
    expect(message).toBe('yes');
  }));
  it('should provide a cancellation method', inject(function($$rAF) {
    if(!$$rAF.supported) return;
    var present = true;
    var cancel = $$rAF(function() {
      present = false;
    });
    expect(present).toBe(true);
    cancel();
    try {
      $$rAF.flush();
    } catch(e) {};
    expect(present).toBe(true);
  }));
  describe('mocks', function() {
    it('should throw an error if no frames are present', inject(function($$rAF) {
      if($$rAF.supported) {
        var failed = false;
        try {
          $$rAF.flush();
        } catch(e) {
          failed = true;
        }
        expect(failed).toBe(true);
      }
    }));
  });
});
 |