Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/grid-ui/src/tests/components/NavBar.test.tsx
2887 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
import * as React from 'react'
19
import { render, screen } from '@testing-library/react'
20
import NavBar from '../../components/NavBar/NavBar'
21
import { MemoryRouter } from 'react-router-dom'
22
23
it('renders menu options names', () => {
24
render(
25
<MemoryRouter initialEntries={['/']}>
26
<NavBar
27
open
28
maxSession={10}
29
sessionCount={0}
30
nodeCount={1}
31
sessionQueueSize={0}
32
/>
33
</MemoryRouter>
34
)
35
expect(screen.getByText('Sessions')).toBeInTheDocument()
36
expect(screen.getByText('Overview')).toBeInTheDocument()
37
expect(screen.getByText('Help')).toBeInTheDocument()
38
})
39
40
it('overall concurrency is not rendered on root path with a single node',
41
() => {
42
render(
43
<MemoryRouter initialEntries={['/']}>
44
<NavBar
45
open
46
maxSession={0}
47
sessionCount={0}
48
nodeCount={1}
49
sessionQueueSize={0}
50
/>
51
</MemoryRouter>
52
)
53
expect(screen.queryByTestId('overall-concurrency')).not.toBeInTheDocument()
54
})
55
56
it('overall concurrency is rendered on root path with more than one node',
57
() => {
58
render(
59
<MemoryRouter initialEntries={['/']}>
60
<NavBar
61
open
62
maxSession={0}
63
sessionCount={0}
64
nodeCount={2}
65
sessionQueueSize={0}
66
/>
67
</MemoryRouter>
68
)
69
expect(screen.getByTestId('overall-concurrency')).toBeInTheDocument()
70
})
71
72
it('overall concurrency is rendered on root path with more than one node',
73
() => {
74
render(
75
<MemoryRouter initialEntries={['/']}>
76
<NavBar
77
open
78
maxSession={0}
79
sessionCount={0}
80
nodeCount={2}
81
sessionQueueSize={0}
82
/>
83
</MemoryRouter>
84
)
85
expect(screen.getByTestId('overall-concurrency')).toBeInTheDocument()
86
})
87
88
it('overall concurrency is rendered on a path different than and one node',
89
() => {
90
render(
91
<MemoryRouter initialEntries={['/sessions']}>
92
<NavBar
93
open
94
maxSession={0}
95
sessionCount={0}
96
nodeCount={1}
97
sessionQueueSize={0}
98
/>
99
</MemoryRouter>
100
)
101
expect(screen.getByTestId('overall-concurrency')).toBeInTheDocument()
102
})
103
104