-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds initial tests and mock for user resource
- Loading branch information
1 parent
0c77118
commit 3e0c42f
Showing
2 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
get: jest.fn(() => Promise.resolve({ data: {} })) | ||
} |
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,90 @@ | ||
import mockAxios from 'axios'; | ||
import User from './user'; | ||
|
||
it('will set assigned filter', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.assigned()) | ||
.toHaveProperty('filters', { | ||
assigned: true, | ||
}); | ||
}); | ||
|
||
it('will set location filter using a number', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.at(1)) | ||
.toHaveProperty('filters', { | ||
location: 1, | ||
}); | ||
}); | ||
|
||
it('will set location filter using a string', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.at('identifier')) | ||
.toHaveProperty('filters', { | ||
location: 'identifier', | ||
}); | ||
}); | ||
|
||
it('will set service filter using a number', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.performing(1)) | ||
.toHaveProperty('filters', { | ||
services: 1, | ||
}); | ||
}); | ||
|
||
it('will set service filter using an array of numbers', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.performing([1, 2])) | ||
.toHaveProperty('filters', { | ||
services: [1, 2], | ||
}); | ||
}); | ||
|
||
it('will set service filter using a string', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.performing('identifier')) | ||
.toHaveProperty('filters', { | ||
services: 'identifier', | ||
}); | ||
}); | ||
|
||
it('will set service filter using an array of strings', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.performing(['identifier', 'other'])) | ||
.toHaveProperty('filters', { | ||
services: ['identifier', 'other'], | ||
}); | ||
}); | ||
|
||
it('will set the sortable filter', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
expect(resource.sortBy('first_name,-created')) | ||
.toHaveProperty('sortable', 'first_name,-created'); | ||
}); | ||
|
||
it('can string all filterable options together', async () => { | ||
const resource = new User(mockAxios); | ||
|
||
const expected = expect( | ||
resource.assigned() | ||
.at(1) | ||
.performing([1, 2]) | ||
.sortBy('created') | ||
); | ||
|
||
expected.toHaveProperty('filters', { | ||
assigned: true, | ||
location: 1, | ||
services: [1, 2], | ||
}); | ||
expected.toHaveProperty('sortable', 'created'); | ||
}); |