@param {!Object} env
(env)
| 2 | describes.sandboxed('fetch-mock', {}, () => { |
| 3 | /** @param {!Object} env */ |
| 4 | function runTests(env) { |
| 5 | it('should mock fetches', () => { |
| 6 | const mock = env.expectFetch('fake.com', {payload: 'foo'}); |
| 7 | |
| 8 | return env.win |
| 9 | .fetch('fake.com') |
| 10 | .then((response) => { |
| 11 | return response.json(); |
| 12 | }) |
| 13 | .then((data) => { |
| 14 | expect(data.payload).to.equal('foo'); |
| 15 | expect(mock.called('fake.com')).to.be.true; |
| 16 | }); |
| 17 | }); |
| 18 | } |
| 19 | |
| 20 | describes.realWin('on realWin', {mockFetch: true}, (env) => { |
| 21 | runTests(env); |