|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | describe('private mocks', function() {
|
| 4 | + |
| 5 | + describe('Jasmine extensions', function() { |
| 6 | + |
| 7 | + describe('they', function() { |
| 8 | + it('should call `it` for each item in an array', function() { |
| 9 | + spyOn(window, 'it'); |
| 10 | + |
| 11 | + they('should do stuff with $prop', ['a', 'b', 'c']); |
| 12 | + expect(window.it.calls.length).toEqual(3); |
| 13 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 14 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 15 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 16 | + }); |
| 17 | + |
| 18 | + |
| 19 | + it('should pass each item in an array to the handler', function() { |
| 20 | + var handlerSpy = jasmine.createSpy('handler'); |
| 21 | + spyOn(window, 'it').andCallFake(function(msg, handler) { |
| 22 | + handler(); |
| 23 | + }); |
| 24 | + they('should do stuff with $prop', ['a', 'b', 'c'], handlerSpy); |
| 25 | + expect(handlerSpy).toHaveBeenCalledWith('a'); |
| 26 | + expect(handlerSpy).toHaveBeenCalledWith('b'); |
| 27 | + expect(handlerSpy).toHaveBeenCalledWith('c'); |
| 28 | + }); |
| 29 | + |
| 30 | + |
| 31 | + it('should call `it` for each key-value pair an object', function() { |
| 32 | + spyOn(window, 'it'); |
| 33 | + |
| 34 | + they('should do stuff with $prop', {a: 1, b:2, c:3}); |
| 35 | + expect(window.it.calls.length).toEqual(3); |
| 36 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 37 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 38 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 39 | + }); |
| 40 | + |
| 41 | + |
| 42 | + it('should pass each key-value pair in an object to the handler', function() { |
| 43 | + var handlerSpy = jasmine.createSpy('handler'); |
| 44 | + spyOn(window, 'it').andCallFake(function(msg, handler) { |
| 45 | + handler(); |
| 46 | + }); |
| 47 | + they('should do stuff with $prop', {a: 1, b:2, c:3}, handlerSpy); |
| 48 | + expect(handlerSpy).toHaveBeenCalledWith(1); |
| 49 | + expect(handlerSpy).toHaveBeenCalledWith(2); |
| 50 | + expect(handlerSpy).toHaveBeenCalledWith(3); |
| 51 | + }); |
| 52 | + |
| 53 | + |
| 54 | + it('should call handler with correct `this`', function() { |
| 55 | + var handlerSpy = jasmine.createSpy('handler'); |
| 56 | + var dummyThis = { name: 'dummyThis' }; |
| 57 | + |
| 58 | + spyOn(window, 'it').andCallFake(function(msg, handler) { |
| 59 | + handler.call(dummyThis); |
| 60 | + }); |
| 61 | + |
| 62 | + they('should do stuff with $prop', ['a'], handlerSpy); |
| 63 | + expect(window.it).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 64 | + expect(handlerSpy.mostRecentCall.object).toBe(dummyThis); |
| 65 | + }); |
| 66 | + }); |
| 67 | + |
| 68 | + |
| 69 | + describe('tthey', function() { |
| 70 | + it('should call `iit` for each item in an array', function() { |
| 71 | + spyOn(window, 'iit'); |
| 72 | + |
| 73 | + tthey('should do stuff with $prop', ['a', 'b', 'c']); |
| 74 | + expect(window.iit.calls.length).toEqual(3); |
| 75 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 76 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 77 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 78 | + }); |
| 79 | + |
| 80 | + |
| 81 | + it('should pass each item in an array to the handler', function() { |
| 82 | + var handlerSpy = jasmine.createSpy('handler'); |
| 83 | + spyOn(window, 'iit').andCallFake(function(msg, handler) { |
| 84 | + handler(); |
| 85 | + }); |
| 86 | + tthey('should do stuff with $prop', ['a', 'b', 'c'], handlerSpy); |
| 87 | + expect(handlerSpy).toHaveBeenCalledWith('a'); |
| 88 | + expect(handlerSpy).toHaveBeenCalledWith('b'); |
| 89 | + expect(handlerSpy).toHaveBeenCalledWith('c'); |
| 90 | + }); |
| 91 | + |
| 92 | + |
| 93 | + it('should call `it` for each key-value pair an object', function() { |
| 94 | + spyOn(window, 'iit'); |
| 95 | + |
| 96 | + tthey('should do stuff with $prop', {a: 1, b:2, c:3}); |
| 97 | + expect(window.iit.calls.length).toEqual(3); |
| 98 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 99 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 100 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 101 | + }); |
| 102 | + |
| 103 | + |
| 104 | + it('should pass each key-value pair in an object to the handler', function() { |
| 105 | + var handlerSpy = jasmine.createSpy('handler'); |
| 106 | + spyOn(window, 'iit').andCallFake(function(msg, handler) { |
| 107 | + handler(); |
| 108 | + }); |
| 109 | + tthey('should do stuff with $prop', {a: 1, b:2, c:3}, handlerSpy); |
| 110 | + expect(handlerSpy).toHaveBeenCalledWith(1); |
| 111 | + expect(handlerSpy).toHaveBeenCalledWith(2); |
| 112 | + expect(handlerSpy).toHaveBeenCalledWith(3); |
| 113 | + }); |
| 114 | + |
| 115 | + |
| 116 | + it('should call handler with correct `this`', function() { |
| 117 | + var handlerSpy = jasmine.createSpy('handler'); |
| 118 | + var dummyThis = { name: 'dummyThis' }; |
| 119 | + |
| 120 | + spyOn(window, 'iit').andCallFake(function(msg, handler) { |
| 121 | + handler.call(dummyThis); |
| 122 | + }); |
| 123 | + |
| 124 | + tthey('should do stuff with $prop', ['a'], handlerSpy); |
| 125 | + expect(window.iit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 126 | + expect(handlerSpy.mostRecentCall.object).toBe(dummyThis); |
| 127 | + }); |
| 128 | + }); |
| 129 | + |
| 130 | + |
| 131 | + describe('xthey', function() { |
| 132 | + it('should call `xit` for each item in an array', function() { |
| 133 | + spyOn(window, 'xit'); |
| 134 | + |
| 135 | + xthey('should do stuff with $prop', ['a', 'b', 'c']); |
| 136 | + expect(window.xit.calls.length).toEqual(3); |
| 137 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 138 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 139 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 140 | + }); |
| 141 | + |
| 142 | + |
| 143 | + it('should pass each item in an array to the handler', function() { |
| 144 | + var handlerSpy = jasmine.createSpy('handler'); |
| 145 | + spyOn(window, 'xit').andCallFake(function(msg, handler) { |
| 146 | + handler(); |
| 147 | + }); |
| 148 | + xthey('should do stuff with $prop', ['a', 'b', 'c'], handlerSpy); |
| 149 | + expect(handlerSpy).toHaveBeenCalledWith('a'); |
| 150 | + expect(handlerSpy).toHaveBeenCalledWith('b'); |
| 151 | + expect(handlerSpy).toHaveBeenCalledWith('c'); |
| 152 | + }); |
| 153 | + |
| 154 | + |
| 155 | + it('should call `it` for each key-value pair an object', function() { |
| 156 | + spyOn(window, 'xit'); |
| 157 | + |
| 158 | + xthey('should do stuff with $prop', {a: 1, b:2, c:3}); |
| 159 | + expect(window.xit.calls.length).toEqual(3); |
| 160 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 161 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "b"', jasmine.any(Function)); |
| 162 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "c"', jasmine.any(Function)); |
| 163 | + }); |
| 164 | + |
| 165 | + |
| 166 | + it('should pass each key-value pair in an object to the handler', function() { |
| 167 | + var handlerSpy = jasmine.createSpy('handler'); |
| 168 | + spyOn(window, 'xit').andCallFake(function(msg, handler) { |
| 169 | + handler(); |
| 170 | + }); |
| 171 | + xthey('should do stuff with $prop', {a: 1, b:2, c:3}, handlerSpy); |
| 172 | + expect(handlerSpy).toHaveBeenCalledWith(1); |
| 173 | + expect(handlerSpy).toHaveBeenCalledWith(2); |
| 174 | + expect(handlerSpy).toHaveBeenCalledWith(3); |
| 175 | + }); |
| 176 | + |
| 177 | + |
| 178 | + it('should call handler with correct `this`', function() { |
| 179 | + var handlerSpy = jasmine.createSpy('handler'); |
| 180 | + var dummyThis = { name: 'dummyThis' }; |
| 181 | + |
| 182 | + spyOn(window, 'xit').andCallFake(function(msg, handler) { |
| 183 | + handler.call(dummyThis); |
| 184 | + }); |
| 185 | + |
| 186 | + xthey('should do stuff with $prop', ['a'], handlerSpy); |
| 187 | + expect(window.xit).toHaveBeenCalledWith('should do stuff with "a"', jasmine.any(Function)); |
| 188 | + expect(handlerSpy.mostRecentCall.object).toBe(dummyThis); |
| 189 | + }); |
| 190 | + }); |
| 191 | + }); |
| 192 | + |
| 193 | + |
4 | 194 | describe('createMockStyleSheet', function() {
|
5 | 195 |
|
6 | 196 | it('should allow custom styles to be created and removed when the stylesheet is destroyed',
|
|
0 commit comments