-
Notifications
You must be signed in to change notification settings - Fork 0
/
FragmentLineToVecRanking.test.tsx
58 lines (55 loc) · 1.94 KB
/
FragmentLineToVecRanking.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react'
import FragmentLineToVecRanking from './FragmentLineToVecRanking'
import { MemoryRouter } from 'react-router-dom'
import { render, screen } from '@testing-library/react'
import { waitForSpinnerToBeRemoved } from 'test-support/waitForSpinnerToBeRemoved'
import Promise from 'bluebird'
import { LineToVecRanking } from 'fragmentarium/domain/lineToVecRanking'
import SessionContext from 'auth/SessionContext'
import { Session } from 'auth/Session'
import { scriptFactory } from 'test-support/fragment-data-fixtures'
import { Periods } from 'common/period'
import { HelmetProvider } from 'react-helmet-async'
import { helmetContext } from 'router/head'
const script = scriptFactory.build(
{},
{ associations: { period: Periods['Neo-Assyrian'] } }
)
beforeEach(async () => {
const session = {
isAllowedToReadFragments: jest.fn().mockReturnValue(true),
}
const lineToVecRankingsResults: LineToVecRanking = {
score: [
{ museumNumber: 'X.1', script: script, score: 10 },
{ museumNumber: 'X.2', script: script, score: 8 },
],
scoreWeighted: [
{ museumNumber: 'X.1', script: script, score: 13 },
{ museumNumber: 'X.2', script: script, score: 9 },
],
}
const fragmentService = {
lineToVecRanking: jest.fn(),
}
fragmentService.lineToVecRanking.mockReturnValueOnce(
Promise.resolve(lineToVecRankingsResults)
)
render(
<HelmetProvider context={helmetContext}>
<MemoryRouter>
<SessionContext.Provider value={(session as unknown) as Session}>
<FragmentLineToVecRanking
number={'X.0'}
fragmentService={fragmentService}
/>
</SessionContext.Provider>
</MemoryRouter>
</HelmetProvider>
)
await waitForSpinnerToBeRemoved(screen)
})
it('Shows the number of transliterated tablets', async () => {
expect(screen.getAllByText(/X.1/)[0]).toBeVisible()
expect(screen.getByText(/,\s*Neo-Assyrian:\s*10/)).toBeVisible()
})