assorted ui_next search phase 1 pr feedback updates

- remove unnecessary displayAll prop from ChipGroup
- update notification api fn to be 2 with no boolean param
- fix params passing to api functions
This commit is contained in:
John Mitchell
2019-07-30 13:57:16 -04:00
parent f0ff5b190a
commit 30253d21fc
12 changed files with 117 additions and 73 deletions

View File

@@ -8,23 +8,36 @@ export function describeNotificationMixin (Model, name) {
jest.clearAllMocks();
});
const parameters = [
['success', true],
['success', false],
['error', true],
['error', false],
];
parameters.forEach(([type, state]) => {
const label = `[notificationType=${type}, associationState=${state}]`;
const testName = `updateNotificationTemplateAssociation ${label} makes expected http calls`;
const parameters = ['success', 'error'];
parameters.forEach((type) => {
const label = `[notificationType=${type}, associationState=true`;
const testName = `associateNotificationTemplate ${label} makes expected http calls`;
test(testName, async (done) => {
await ModelAPI.updateNotificationTemplateAssociation(1, 21, type, state);
await ModelAPI.associateNotificationTemplate(1, 21, type);
const expectedPath = `${ModelAPI.baseUrl}1/notification_templates_${type}/`;
expect(mockHttp.post).toHaveBeenCalledTimes(1);
const expectedParams = state ? { id: 21 } : { id: 21, disassociate: true };
const expectedParams = { id: 21 };
expect(mockHttp.post.mock.calls.pop()).toEqual([expectedPath, expectedParams]);
done();
});
});
parameters.forEach((type) => {
const label = `[notificationType=${type}, associationState=false`;
const testName = `disassociateNotificationTemplate ${label} makes expected http calls`;
test(testName, async (done) => {
await ModelAPI.disassociateNotificationTemplate(1, 21, type);
const expectedPath = `${ModelAPI.baseUrl}1/notification_templates_${type}/`;
expect(mockHttp.post).toHaveBeenCalledTimes(1);
const expectedParams = { id: 21, disassociate: true };
expect(mockHttp.post.mock.calls.pop()).toEqual([expectedPath, expectedParams]);
done();