Skip to content

Commit

Permalink
Merge pull request #9491 from transcom/ruizaj-mb-14395-createBasicSer…
Browse files Browse the repository at this point in the history
…vieItem-refactor

[MB-14395] create basic service item refactor
  • Loading branch information
ruizajtruss committed Nov 2, 2022
2 parents 94e4e30 + ae66daa commit ad45a27
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React from 'react';

import a from 'constants/MoveHistory/Database/Actions';
import o from 'constants/MoveHistory/UIDisplay/Operations';
import d from 'constants/MoveHistory/UIDisplay/DetailsTypes';
import t from 'constants/MoveHistory/Database/Tables';

export default {
action: a.INSERT,
eventName: o.updateMoveTaskOrderStatus,
tableName: t.mto_service_items,
detailsType: d.PLAIN_TEXT,
getEventNameDisplay: () => 'Approved service item',
getDetailsPlainText: (historyRecord) => {
return `${historyRecord.context[0]?.name}`;
},
getDetails: ({ context }) => <> {context[0]?.name} </>,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { screen, render } from '@testing-library/react';

import getTemplate from 'constants/MoveHistory/TemplateManager';
import e from 'constants/MoveHistory/EventTemplates/UpdateMoveTaskOrderStatus/createBasicServiceItem';

describe('when given a Create basic service item history record', () => {
const historyRecord = {
action: 'INSERT',
context: [
{
name: 'Move management',
},
],
eventName: 'updateMoveTaskOrderStatus',
tableName: 'mto_service_items',
};

it('correctly matches the Create basic service item template', () => {
const template = getTemplate(historyRecord);

expect(template).toMatchObject(e);
expect(template.getEventNameDisplay(template)).toEqual('Approved service item');
});

it('displays the expected details column value', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Move management')).toBeInTheDocument();
});
});

This file was deleted.

2 changes: 1 addition & 1 deletion src/constants/MoveHistory/EventTemplates/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as acknowledgeExcessWeightRisk } from './AcknowledgeExcessWeightRisk/acknowledgeExcessWeightRisk';
export { default as approveShipment } from './ApproveShipment/approveShipment';
export { default as approveShipmentDiversion } from './ApproveShipmentDiversion/approveShipmentDiversion';
export { default as createBasicServiceItem } from './createBasicServiceItem';
export { default as createBasicServiceItem } from './UpdateMoveTaskOrderStatus/createBasicServiceItem';
export { default as createMTOServiceItem } from './CreateMTOServiceItem/createMTOServiceItem';
export { default as createMTOServiceItemCustomerContacts } from './CreateMTOServiceItem/createMTOServiceItemCustomerContacts';
export { default as createMTOServiceItemDimensions } from './CreateMTOServiceItem/createMTOServiceItemDimensions';
Expand Down

0 comments on commit ad45a27

Please sign in to comment.