-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix and add Aieracast tests and include package-lock updates f…
…rom prior release
- Loading branch information
1 parent
d46f0e8
commit 5ccf22e
Showing
2 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,103 @@ | ||
import React from 'react'; | ||
import { within } from '@testing-library/dom'; | ||
import { screen } from '@testing-library/react'; | ||
import { fromValue } from 'wonka'; | ||
|
||
import { renderWithProvider } from 'testUtils'; | ||
import { actAndFlush, renderWithProvider } from 'testUtils'; | ||
import { Aieracast } from '.'; | ||
|
||
const EVENT_DATE_TIME = '2021-08-25T18:00:00+00:00'; | ||
|
||
const eventList = [ | ||
{ | ||
id: '1', | ||
title: 'Event Title', | ||
eventType: 'earnings', | ||
eventDate: EVENT_DATE_TIME, | ||
primaryCompany: { | ||
instruments: [ | ||
{ | ||
isPrimary: true, | ||
quotes: [ | ||
{ | ||
isPrimary: true, | ||
localTicker: 'TICK', | ||
exchange: { | ||
country: { countryCode: 'US' }, | ||
shortName: 'EXCH', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
id: '2', | ||
title: 'Event Title 2', | ||
eventType: 'presentation', | ||
eventDate: new Date(new Date().getTime() + 3000).toISOString(), | ||
primaryCompany: { | ||
instruments: [ | ||
{ | ||
isPrimary: true, | ||
quotes: [ | ||
{ | ||
isPrimary: true, | ||
localTicker: 'TOCK', | ||
exchange: { | ||
country: { countryCode: 'USA' }, | ||
shortName: 'NOPE', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
].map((event) => ({ id: event.id, numTotalHits: 1, event })); | ||
|
||
describe('Aieracast', () => { | ||
test('renders', () => { | ||
renderWithProvider(<Aieracast />); | ||
screen.getByText('Earnings'); | ||
test('renders', async () => { | ||
const { rendered } = await actAndFlush(() => renderWithProvider(<Aieracast />)); | ||
expect(rendered.container.getElementsByClassName('aieracast').length).toBeGreaterThan(0); | ||
}); | ||
|
||
test('handles empty state', async () => { | ||
await actAndFlush(() => | ||
renderWithProvider(<Aieracast />, { | ||
executeQuery: () => | ||
fromValue({ | ||
data: { | ||
search: { events: { numTotalHits: 0, hits: [] } }, | ||
}, | ||
}), | ||
}) | ||
); | ||
screen.getByText('Select events from the left sidebar'); | ||
}); | ||
|
||
test('handles event list', async () => { | ||
await actAndFlush(() => | ||
renderWithProvider(<Aieracast />, { | ||
executeQuery: () => | ||
fromValue({ | ||
data: { | ||
search: { events: { numTotalHits: eventList.length, hits: eventList } }, | ||
}, | ||
}), | ||
}) | ||
); | ||
screen.getByText('TICK'); | ||
screen.getByText('EXCH'); | ||
const row = screen.getByText('TICK').closest('li'); | ||
expect(row).toBeTruthy(); | ||
if (row) within(row).getByText('Aug 25, 2021'); | ||
if (row) within(row).getByText('earnings'); | ||
screen.getByText( | ||
new Date(EVENT_DATE_TIME) | ||
.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }) | ||
.replace(/\s/, '') | ||
); | ||
}); | ||
}); |