42 lines
1.9 KiB
TypeScript
42 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import AuctionSoldBanner, { getSoldText } from './AuctionSoldBanner';
|
|
import { shallow } from 'enzyme';
|
|
import { IAutoIMS } from '../../../../reducers/AuctionAssignmentReducer';
|
|
import moment from 'moment';
|
|
|
|
describe('AuctionSoldBaner Component', () => {
|
|
|
|
it ('Sold Banner Does Not Display When AutoIMS is Undefined', () => {
|
|
const wrapper = shallow(<AuctionSoldBanner />);
|
|
const soldNotification = wrapper.find(`[data-test='auction-sold-banner-notification']`);
|
|
expect(soldNotification.length).toBe(0);
|
|
});
|
|
|
|
it ('Sold Banner Does Not Display When SalePrice is Undefined', () => {
|
|
const wrapper = shallow(<AuctionSoldBanner autoIMS={{ soldDate: moment() } as IAutoIMS} />);
|
|
const soldNotification = wrapper.find(`[data-test='auction-sold-banner-notification']`);
|
|
expect(soldNotification.length).toBe(0);
|
|
});
|
|
|
|
it ('Sold Banner Does Not Display When SoldDate is Undefined', () => {
|
|
const wrapper = shallow(<AuctionSoldBanner autoIMS={{ salePrice: 1916 } as IAutoIMS} />);
|
|
const soldNotification = wrapper.find(`[data-test='auction-sold-banner-notification']`);
|
|
expect(soldNotification.length).toBe(0);
|
|
});
|
|
|
|
it ('Sold Banner Displays Correct Text', () => {
|
|
const dummyAutoIMS = { salePrice: 1945, soldDate: moment('1945-09-02') } as IAutoIMS;
|
|
const wrapper = shallow(<AuctionSoldBanner autoIMS={dummyAutoIMS} />);
|
|
const soldNotification = wrapper.find(`[data-test='auction-sold-banner-notification']`);
|
|
expect(soldNotification.length).toBe(1);
|
|
|
|
const soldDateText = getSoldText(dummyAutoIMS);
|
|
expect(soldDateText).toBe('Sold on 09/02/1945 for $1,945.00. Funds Not Sent.');
|
|
|
|
dummyAutoIMS.fundsSent = moment();
|
|
const updatedSoldDateText = getSoldText(dummyAutoIMS);
|
|
expect(updatedSoldDateText).toBe('Sold on 09/02/1945 for $1,945.00. Funds Sent.');
|
|
});
|
|
|
|
});
|