Created
April 29, 2020 15:58
-
-
Save jonurry/bd929451008da9a3a6183b9eaeea0d48 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const { | |
copyAllProjectCustomFields, | |
} = require('./copy_all_project_custom_fields'); | |
const { falafel } = require('./mocks'); | |
const input = { | |
access_token: 1234, | |
destination_project_id: 2, | |
source_project_id: 1, | |
}; | |
describe('copy all project custom fields', () => { | |
beforeEach(() => { | |
jest.clearAllMocks(); | |
}); | |
test('getProject is called once with correct input', async () => { | |
await copyAllProjectCustomFields(input); | |
expect(falafel.asana.getProject).toHaveBeenCalledTimes(1); | |
expect(falafel.asana.getProject).toHaveBeenCalledWith({ | |
access_token: input.access_token, | |
project_id: input.source_project_id, | |
}); | |
}); | |
test('addCustomFieldToProject is called twice with correct input', async () => { | |
await copyAllProjectCustomFields(input); | |
expect(falafel.asana.addCustomFieldToProject).toHaveBeenCalledTimes(2); | |
expect(falafel.asana.addCustomFieldToProject).toHaveBeenNthCalledWith( | |
1, | |
{ | |
access_token: input.access_token, | |
project_id: input.destination_project_id, | |
custom_field_id: '1', | |
is_important: true, | |
}, | |
); | |
expect(falafel.asana.addCustomFieldToProject).toHaveBeenNthCalledWith( | |
2, | |
{ | |
access_token: input.access_token, | |
project_id: input.destination_project_id, | |
custom_field_id: '2', | |
is_important: false, | |
}, | |
); | |
}); | |
test('returns success and number of fields added', async () => { | |
const result = await copyAllProjectCustomFields(input); | |
expect(result).toEqual({ success: true, fieldsCopied: 2 }); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment