-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14557 from transcom/INT-B-21507_POD-POE_TOO_Valid…
…ation Int b 21507 pod poe too validation
- Loading branch information
Showing
7 changed files
with
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
|
||
import DataTableWrapper from '../../DataTableWrapper/index'; | ||
import DataTable from '../../DataTable/index'; | ||
import styles from '../ShipmentAddresses/ShipmentAddresses.module.scss'; | ||
|
||
import { formatPortInfo } from 'utils/formatters'; | ||
|
||
const PortTable = ({ poeLocation, podLocation }) => { | ||
return ( | ||
<DataTableWrapper className={classnames('maxw-tablet', 'table--data-point-group', styles.mtoShipmentAddresses)}> | ||
<DataTable | ||
columnHeaders={['Port of Embarkation', 'Port of Debarkation']} | ||
dataRow={[formatPortInfo(poeLocation), formatPortInfo(podLocation)]} | ||
/> | ||
</DataTableWrapper> | ||
); | ||
}; | ||
|
||
export default PortTable; |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
|
||
import PortTable from './PortTable'; | ||
|
||
const poeLocationSet = { | ||
poeLocation: { | ||
portCode: 'PDX', | ||
portName: 'PORTLAND INTL', | ||
city: 'PORTLAND', | ||
state: 'OREGON', | ||
zip: '97220', | ||
}, | ||
podLocation: null, | ||
}; | ||
|
||
const podLocationSet = { | ||
poeLocation: null, | ||
podLocation: { | ||
portCode: 'SEA', | ||
portName: 'SEATTLE TACOMA INTL', | ||
city: 'SEATTLE', | ||
state: 'WASHINGTON', | ||
zip: '98158', | ||
}, | ||
}; | ||
|
||
export default { | ||
title: 'Office Components / PortTable', | ||
component: PortTable, | ||
}; | ||
|
||
export const standard = () => { | ||
return ( | ||
<div className="officeApp"> | ||
<PortTable {...poeLocationSet} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export const podLocationDisplay = () => { | ||
return ( | ||
<div className="officeApp"> | ||
<PortTable {...podLocationSet} /> | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import PortTable from './PortTable'; | ||
|
||
const poeLocationSet = { | ||
poeLocation: { | ||
portCode: 'PDX', | ||
portName: 'PORTLAND INTL', | ||
city: 'PORTLAND', | ||
state: 'OREGON', | ||
zip: '97220', | ||
}, | ||
podLocation: null, | ||
}; | ||
|
||
const podLocationSet = { | ||
poeLocation: null, | ||
podLocation: { | ||
portCode: 'SEA', | ||
portName: 'SEATTLE TACOMA INTL', | ||
city: 'SEATTLE', | ||
state: 'WASHINGTON', | ||
zip: '98158', | ||
}, | ||
}; | ||
|
||
const nullPortLocation = { | ||
poeLocation: null, | ||
podLocation: null, | ||
}; | ||
|
||
describe('PortTable', () => { | ||
it('renders POE location if poeLocation is set', async () => { | ||
render(<PortTable {...poeLocationSet} />); | ||
expect(screen.getByText(/PDX - PORTLAND INTL/)).toBeInTheDocument(); | ||
expect(screen.getByText(/Portland, Oregon 97220/)).toBeInTheDocument(); | ||
expect(screen.queryByText(/SEA - SEATTLE TACOMA INTL/)).not.toBeInTheDocument(); | ||
expect(screen.queryByText(/Seattle, Washington 98158/)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders POD location if podLocation is set', async () => { | ||
render(<PortTable {...podLocationSet} />); | ||
expect(screen.queryByText(/PDX - PORTLAND INTL/)).not.toBeInTheDocument(); | ||
expect(screen.queryByText(/Portland, Oregon 97220/)).not.toBeInTheDocument(); | ||
expect(screen.getByText(/SEA - SEATTLE TACOMA INTL/)).toBeInTheDocument(); | ||
expect(screen.getByText(/Seattle, Washington 98158/)).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render port information if poeLocation and podLocation are null', async () => { | ||
render(<PortTable {...nullPortLocation} />); | ||
expect(screen.queryByText(/PDX - PORTLAND INTL/)).not.toBeInTheDocument(); | ||
expect(screen.queryByText(/Portland, Oregon 97220/)).not.toBeInTheDocument(); | ||
expect(screen.queryByText(/SEA - SEATTLE TACOMA INTL/)).not.toBeInTheDocument(); | ||
expect(screen.queryByText(/Seattle, Washington 98158/)).not.toBeInTheDocument(); | ||
}); | ||
}); |
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