-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from wheresrhys/easier-naming
implement easier naming using just a string
- Loading branch information
Showing
3 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { afterEach, describe, expect, it, beforeAll } from 'vitest'; | ||
|
||
const { fetchMock } = testGlobals; | ||
describe('multiple routes', () => { | ||
let fm; | ||
beforeAll(() => { | ||
fm = fetchMock.createInstance(); | ||
fm.config.warnOnUnmatched = false; | ||
}); | ||
|
||
afterEach(() => fm.restore()); | ||
|
||
it('property on first parameter', () => { | ||
fm.mock({ url: 'http://a.com', name: 'my-name' }, 200); | ||
fm.fetchHandler('http://a.com'); | ||
expect(fm.called('my-name')).toBe(true); | ||
}); | ||
|
||
it('property on first parameter when only one parameter supplied', () => { | ||
fm.mock({ name: 'my-name', url: 'http://a.com', response: 200 }); | ||
fm.fetchHandler('http://a.com'); | ||
expect(fm.called('my-name')).toBe(true); | ||
}); | ||
|
||
it('property on third parameter', () => { | ||
fm.mock('http://a.com', 200, { name: 'my-name' }); | ||
fm.fetchHandler('http://a.com'); | ||
expect(fm.called('my-name')).toBe(true); | ||
}); | ||
|
||
it('string in third parameter', () => { | ||
fm.mock('http://a.com', 200, 'my-name'); | ||
fm.fetchHandler('http://a.com'); | ||
expect(fm.called('my-name')).toBe(true); | ||
}); | ||
}); |