-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: send data as body for the request
- Loading branch information
Showing
9 changed files
with
40 additions
and
30 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
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
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 |
---|---|---|
|
@@ -24,21 +24,20 @@ test('addMember will set the proper method', () => { | |
|
||
test('if a member is sent as string it will work as expected', () => { | ||
teamsRequest.addMembers({ members: '[email protected]' }) | ||
expect(fetch.mock.calls[0][1].data).toEqual([ | ||
expect(fetch.mock.calls[0][1].body).toEqual(JSON.stringify([ | ||
{ | ||
op: 'add', | ||
path: '/members', | ||
value: { | ||
email: '[email protected]' | ||
} | ||
} | ||
]) | ||
])) | ||
}) | ||
|
||
test('it will support array or multiple members at a time', () => { | ||
teamsRequest.addMembers({ members: ['[email protected]', '[email protected]'] }) | ||
expect(fetch.mock.calls[0][1].data.length).toEqual(2) | ||
expect(fetch.mock.calls[0][1].data).toEqual([ | ||
expect(fetch.mock.calls[0][1].body).toEqual(JSON.stringify([ | ||
{ | ||
op: 'add', | ||
path: '/members', | ||
|
@@ -53,28 +52,27 @@ test('it will support array or multiple members at a time', () => { | |
email: '[email protected]' | ||
} | ||
} | ||
]) | ||
])) | ||
}) | ||
|
||
test('if no members or incorrect format defined throws', () => { | ||
expect(() => teamsRequest.addMembers({ members: {} })).toThrow() | ||
}) | ||
|
||
//removeMember | ||
test('removeMember will set the proper method', () => { | ||
teamsRequest.removeMembers({ members: ['[email protected]'] }) | ||
expect(fetch.mock.calls[0][1].method).toBe('delete') | ||
}) | ||
|
||
test('if a member is sent as string it will work as expected', () => { | ||
teamsRequest.removeMembers({ members: '[email protected]' }) | ||
expect(fetch.mock.calls[0][1].data).toEqual([ | ||
expect(fetch.mock.calls[0][1].body).toEqual(JSON.stringify([ | ||
{ | ||
op: 'remove', | ||
path: '/members', | ||
value: { | ||
email: '[email protected]' | ||
} | ||
} | ||
]) | ||
])) | ||
}) |
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 |
---|---|---|
|
@@ -48,7 +48,8 @@ test(`add a member to a workscape has the correct payload`, () => { | |
id: 2, | ||
members: ['[email protected]', '[email protected]'] | ||
}) | ||
expect(fetch.mock.calls[0][1].data).toEqual([ | ||
const body = fetch.mock.calls[0][1].body | ||
expect(body).toEqual(JSON.stringify([ | ||
{ | ||
op: 'add', | ||
path: '/members', | ||
|
@@ -63,25 +64,28 @@ test(`add a member to a workscape has the correct payload`, () => { | |
email: '[email protected]' | ||
} | ||
} | ||
]) | ||
expect(fetch.mock.calls[0][1].data.length).toEqual(2) | ||
])) | ||
expect(JSON.parse(body).length).toEqual(2) | ||
}) | ||
|
||
test(`remove a member to a workscape has the correct payload`, () => { | ||
workspacesRequest.removeMembers({ | ||
id: 2, | ||
members: ['[email protected]'] | ||
}) | ||
expect(fetch.mock.calls[0][1].data).toEqual([ | ||
|
||
const body = fetch.mock.calls[0][1].body | ||
|
||
expect(body).toEqual(JSON.stringify([ | ||
{ | ||
op: 'remove', | ||
path: '/members', | ||
value: { | ||
email: '[email protected]' | ||
} | ||
} | ||
]) | ||
expect(fetch.mock.calls[0][1].data.length).toEqual(1) | ||
])) | ||
expect(JSON.parse(body).length).toEqual(1) | ||
}) | ||
|
||
test(`Deleting a workscape has the correct path and method`, () => { | ||
|