Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed May 20, 2020
1 parent d556ed6 commit 99eaa5e
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions test/specs/routing/function-matching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,28 @@ describe('function matching', () => {
expect(fm.calls(true).length).to.equal(1);
});

// Following test works in latest chrome but not in v62 in CI
let itInDev = it;
it('match using custom function with Request with unusual options', async () => {
// as node-fetch does not try to emulate all the WHATWG standards, we can't check for the
// same properties in the browser and nodejs
const propertyToCheck = new fm.config.Request('http://example.com').cache
? 'credentials'
: 'timeout';
const valueToSet = propertyToCheck === 'credentials' ? 'include' : 2000;

try {
/Chrome\/62/.test(window.navigator.appVersion) && (itInDev = it.skip);
} catch (err) {}
fm.mock(
(url, options, request) => request[propertyToCheck] === valueToSet,
200
).catch();

itInDev(
'match using custom function with Request with unusual options',
async () => {
// as node-fetch does not try to emulate all the WHATWG standards, we can't check for the
// same properties in the browser and nodejs
const propertyToCheck = new fm.config.Request('http://example.com').cache
? 'credentials'
: 'timeout';
const valueToSet = propertyToCheck === 'credentials' ? 'include' : 2000;

fm.mock(
(url, options, request) => request[propertyToCheck] === valueToSet,
200
).catch();

await fm.fetchHandler(new fm.config.Request('http://a.com/logged-in'));
expect(fm.calls(true).length).to.equal(0);
await fm.fetchHandler(
new fm.config.Request('http://a.com/logged-in', {
[propertyToCheck]: valueToSet,
})
);
expect(fm.calls(true).length).to.equal(1);
}
);
await fm.fetchHandler(new fm.config.Request('http://a.com/logged-in'));
expect(fm.calls(true).length).to.equal(0);
await fm.fetchHandler(
new fm.config.Request('http://a.com/logged-in', {
[propertyToCheck]: valueToSet,
})
);
expect(fm.calls(true).length).to.equal(1);
});

it('match using custom function alongside other matchers', async () => {
fm.mock('end:profile', 200, {
Expand Down

0 comments on commit 99eaa5e

Please sign in to comment.