Last active
October 8, 2020 11:50
-
-
Save jonurry/33d2f07588d4ac619378e9e73aff7a9b to your computer and use it in GitHub Desktop.
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
exports.url = '/users.list'; | |
exports.method = 'get'; | |
exports.validateInput = false; | |
const mockListConversations = jest | |
.fn() | |
.mockImplementationOnce(() => ({ | |
ok: true, | |
channels: [ | |
{ | |
id: 'C024Q2C1P', | |
name: 'engineering', | |
is_channel: true, | |
is_group: false, | |
is_im: false, | |
created: 1389392606, | |
is_archived: false, | |
is_general: false, | |
unlinked: 0, | |
name_normalized: 'engineering', | |
is_shared: false, | |
parent_conversation: null, | |
creator: 'U024Q5PFC', | |
is_ext_shared: false, | |
is_org_shared: false, | |
shared_team_ids: ['T024Q5PFA'], | |
pending_shared: [], | |
pending_connected_team_ids: [], | |
is_pending_ext_shared: false, | |
is_member: true, | |
is_private: false, | |
is_mpim: false, | |
topic: { | |
value: 'almost zero downtime', | |
creator: 'U069TEU7L', | |
last_set: 1559234874, | |
}, | |
purpose: { | |
value: 'Talk about all things technical', | |
creator: 'U024Q5PFC', | |
last_set: 1400595281, | |
}, | |
previous_names: [], | |
num_members: 106, | |
}, | |
], | |
})) | |
.mockImplementationOnce(() => ({ | |
ok: true, | |
channels: [ | |
{ | |
id: 'CU6UW5940', | |
name: 'connector-test-runner', | |
is_channel: true, | |
is_group: false, | |
is_im: false, | |
created: 1582109983, | |
is_archived: false, | |
is_general: false, | |
unlinked: 0, | |
name_normalized: 'connector-test-runner', | |
is_shared: false, | |
parent_conversation: null, | |
creator: 'UL7CWS0UD', | |
is_ext_shared: false, | |
is_org_shared: false, | |
shared_team_ids: ['T024Q5PFA'], | |
pending_shared: [], | |
pending_connected_team_ids: [], | |
is_pending_ext_shared: false, | |
is_member: true, | |
is_private: true, | |
is_mpim: false, | |
topic: { | |
value: '', | |
creator: '', | |
last_set: 0, | |
}, | |
purpose: { | |
value: '', | |
creator: '', | |
last_set: 0, | |
}, | |
num_members: 6, | |
}, | |
], | |
})) | |
.mockImplementationOnce(() => ({ | |
ok: true, | |
channels: [ | |
{ | |
id: 'D017BC05QSH', | |
created: 1595232726, | |
is_archived: false, | |
is_im: true, | |
is_org_shared: false, | |
user: 'USER_ID', | |
is_user_deleted: false, | |
priority: 0.020963221077195, | |
}, | |
{ | |
id: 'NO_USER_CHANNEL', | |
created: 1595232726, | |
is_archived: false, | |
is_im: true, | |
is_org_shared: false, | |
user: 'NO_USER_ID', | |
is_user_deleted: false, | |
priority: 0.020963221077195, | |
}, | |
], | |
})) | |
.mockImplementationOnce(() => ({ | |
ok: true, | |
channels: [ | |
{ | |
id: 'GJQV9CJNA', | |
name: 'mpdm-jon--az--sam-1', | |
is_channel: false, | |
is_group: true, | |
is_im: false, | |
created: 1557826267, | |
is_archived: false, | |
is_general: false, | |
unlinked: 0, | |
name_normalized: 'mpdm-jon--az--sam-1', | |
is_shared: false, | |
parent_conversation: null, | |
creator: 'UJ2UWBH7B', | |
is_ext_shared: false, | |
is_org_shared: false, | |
shared_team_ids: ['T024Q5PFA'], | |
pending_shared: [], | |
pending_connected_team_ids: [], | |
is_pending_ext_shared: false, | |
is_member: true, | |
is_private: true, | |
is_mpim: true, | |
last_read: '1559296457.001400', | |
is_open: false, | |
topic: { | |
value: 'Group messaging', | |
creator: 'UJ2UWBH7B', | |
last_set: 1557826267, | |
}, | |
purpose: { | |
value: 'Group messaging with: @jon @az @sam', | |
creator: 'UJ2UWBH7B', | |
last_set: 1557826267, | |
}, | |
priority: 0, | |
}, | |
{ | |
id: 'group-no-purpose', | |
is_mpim: true, | |
purpose: { | |
value: '', | |
creator: '', | |
last_set: 0, | |
}, | |
}, | |
], | |
})); | |
exports.before = () => { | |
jest.spyOn(falafel.slack, 'listConversations').mockImplementation( | |
mockListConversations, | |
); | |
}; | |
exports.after = () => { | |
expect(mockListConversations).toHaveBeenNthCalledWith(1, { | |
limit: 1000, | |
token: '123', | |
types: ['public_channel'], | |
}); | |
expect(mockListConversations).toHaveBeenNthCalledWith(2, { | |
limit: 1000, | |
token: '123', | |
types: ['private_channel'], | |
}); | |
expect(mockListConversations).toHaveBeenNthCalledWith(3, { | |
limit: 1000, | |
token: '123', | |
types: ['im'], | |
}); | |
expect(mockListConversations).toHaveBeenNthCalledWith(4, { | |
limit: 1000, | |
token: '123', | |
types: ['mpim'], | |
}); | |
expect(mockListConversations).toHaveBeenCalledTimes(4); | |
}; | |
exports.mock = { | |
response: { | |
ok: true, | |
members: [ | |
{ | |
id: 'USER_ID', | |
name: 'username', | |
real_name: 'First Last', | |
}, | |
], | |
}, | |
}; | |
exports.expect = { | |
request: { | |
query: { token: '123' }, | |
}, | |
output: { | |
result: [ | |
{ | |
text: '@unknown (user not found)', | |
value: 'NO_USER_CHANNEL', | |
}, | |
{ | |
text: '@username (First Last)', | |
value: 'D017BC05QSH', | |
}, | |
{ | |
text: 'connector-test-runner', | |
value: 'CU6UW5940', | |
}, | |
{ | |
text: 'engineering', | |
value: 'C024Q2C1P', | |
}, | |
{ | |
text: 'group-no-purpose', | |
value: 'group-no-purpose', | |
}, | |
{ | |
text: 'group: @jon @az @sam', | |
value: 'GJQV9CJNA', | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment