Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
application-administarator-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Рогов Артем Владимирович
application-administarator-service
Commits
53e6eef8
Unverified
Commit
53e6eef8
authored
Nov 17, 2023
by
ksmirnov
Committed by
GitHub
Nov 17, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7 from AyaDigital/hotfix/DMVP-1066
DMVP-1066 - Add Tests to Components
parents
3b263f3f
1a1425dd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
14 deletions
+137
-14
Loader.test.js
src/_components/Loader/Loader.test.js
+25
-0
modal.jsx
src/_components/controls/modal.jsx
+3
-2
modal.test.js
src/_components/controls/modal.test.js
+38
-0
InfiniteLoader.test.js
src/_components/inputs/InFiniteLoader/InfiniteLoader.test.js
+30
-0
index.jsx
src/_components/inputs/InFiniteLoader/index.jsx
+10
-12
map.test.js
src/_components/map/map.test.js
+31
-0
No files found.
src/_components/Loader/Loader.test.js
0 → 100644
View file @
53e6eef8
import
{
render
,
cleanup
}
from
"@testing-library/react"
;
// Importing the jest testing library
import
'@testing-library/jest-dom'
import
Loader
from
"./"
;
// afterEach function runs after each test suite is executed
afterEach
(()
=>
{
cleanup
();
// Resets the DOM after each test suite
})
describe
(
"Loader Component"
,
()
=>
{
const
handleOperation
=
jest
.
fn
();
test
(
"Modal Rendering"
,
()
=>
{
render
(
<
Loader
type
=
{
'balls'
}
color
=
{
'rgb(44, 121, 206, 0.4)'
}
className
=
'loader-style'
width
=
{
'300px'
}
height
=
{
'300px'
}
/
>
)
})
});
src/_components/controls/modal.jsx
View file @
53e6eef8
...
...
@@ -13,11 +13,10 @@ const ModalForm = ({
onClose
})
=>
{
return
(
<
div
className=
'clinics-form-layout'
>
<
div
className=
'clinics-form-layout'
data
-
testid=
"modal"
>
<>
{
isLoading
?
(
<
Spinner
thickness=
'4px'
speed=
'0.65s'
...
...
@@ -40,6 +39,7 @@ const ModalForm = ({
<
GridItem
rowSpan=
{
1
}
colSpan=
{
1
}
textAlign=
{
'center'
}
>
<
Button
data
-
testid=
"no-button"
w=
'180px'
h=
'50px'
variant=
'outline'
...
...
@@ -52,6 +52,7 @@ const ModalForm = ({
</
GridItem
>
<
GridItem
rowSpan=
{
1
}
colSpan=
{
1
}
textAlign=
{
'center'
}
>
<
Button
data
-
testid=
"yes-button"
colorScheme=
'teal'
variant=
'outline'
w=
'180px'
...
...
src/_components/controls/modal.test.js
0 → 100644
View file @
53e6eef8
import
{
render
,
screen
,
cleanup
}
from
"@testing-library/react"
;
// Importing the jest testing library
import
'@testing-library/jest-dom'
import
{
ModalForm
}
from
"./modal"
;
// afterEach function runs after each test suite is executed
afterEach
(()
=>
{
cleanup
();
// Resets the DOM after each test suite
})
describe
(
"Modal Component"
,
()
=>
{
const
handleOperation
=
jest
.
fn
();
const
isLoading
=
false
;
const
onClose
=
jest
.
fn
();
render
(
<
ModalForm
handleOperation
=
{
handleOperation
}
onClose
=
{
onClose
}
isLoading
=
{
isLoading
}
/
>
)
const
modal
=
screen
.
getByTestId
(
"modal"
);
const
buttonNo
=
screen
.
getByTestId
(
"no-button"
);
const
buttonYes
=
screen
.
getByTestId
(
"yes-button"
);
test
(
"Modal Rendering"
,
()
=>
{
expect
(
modal
).
toBeInTheDocument
();
})
test
(
"Button Text No"
,
()
=>
{
expect
(
buttonNo
).
toHaveTextContent
(
"No"
);
})
test
(
"Button Text Yes"
,
()
=>
{
expect
(
buttonYes
).
toHaveTextContent
(
"Yes"
);
})
})
\ No newline at end of file
src/_components/inputs/InFiniteLoader/InfiniteLoader.test.js
0 → 100644
View file @
53e6eef8
import
{
render
,
cleanup
}
from
"@testing-library/react"
;
// Importing the jest testing library
import
'@testing-library/jest-dom'
import
InfiniteLoaderWrapper
from
"./"
;
// afterEach function runs after each test suite is executed
afterEach
(()
=>
{
cleanup
();
// Resets the DOM after each test suite
})
describe
(
"InfiniteLoader Component"
,
()
=>
{
const
handleOperation
=
jest
.
fn
();
test
(
"Modal Rendering"
,
()
=>
{
render
(
<
InfiniteLoaderWrapper
hasNextPage
=
{
true
}
isNextPageLoading
=
{
false
}
items
=
{[]}
loadNextPage
=
{
handleOperation
}
wrapperClassName
=
{
null
}
search
=
{
''
}
onChange
=
{
handleOperation
}
onFocus
=
{
handleOperation
}
handleSelect
=
{
handleOperation
}
listOpen
=
{
true
}
/
>
)
})
})
src/_components/inputs/InFiniteLoader/index.jsx
View file @
53e6eef8
...
...
@@ -10,17 +10,16 @@ import {
}
from
'@chakra-ui/react'
;
const
InfiniteLoaderWrapper
=
({
hasNextPage
,
isNextPageLoading
,
items
,
loadNextPage
,
wrapperClassName
,
fieldname
=
'name'
,
search
,
onChange
,
onFocus
,
handleSelect
,
listOpen
hasNextPage
,
isNextPageLoading
,
items
,
loadNextPage
,
wrapperClassName
,
search
,
onChange
,
onFocus
,
handleSelect
,
listOpen
})
=>
{
const
itemCount
=
hasNextPage
?
items
.
length
+
1
:
items
.
length
;
...
...
@@ -29,7 +28,6 @@ const InfiniteLoaderWrapper =({
const
isItemLoaded
=
(
index
)
=>
!
hasNextPage
||
index
<
items
.
length
;
const
Item
=
({
index
,
style
})
=>
{
console
.
log
(
'index'
,
index
);
if
(
!
isItemLoaded
(
index
))
{
return
<
li
style=
{
style
}
>
Loading...
</
li
>;
}
else
{
...
...
src/_components/map/map.test.js
0 → 100644
View file @
53e6eef8
import
{
render
,
cleanup
}
from
"@testing-library/react"
;
// Importing the jest testing library
import
'@testing-library/jest-dom'
import
Map
from
"./map"
;
// afterEach function runs after each test suite is executed
afterEach
(()
=>
{
cleanup
();
// Resets the DOM after each test suite
})
describe
(
"Loader Component"
,
()
=>
{
const
handleOperation
=
jest
.
fn
();
test
(
"Modal Rendering"
,
()
=>
{
render
(
<
Map
center
=
{{
lat
:
55.555
,
lng
:
33.333
}}
marker
=
{
<><
/>
}
markers
=
{[]}
zoom
=
{
11
}
className
=
{
''
}
onClick
=
{
handleOperation
}
overlay
=
{
''
}
icon
=
{
''
}
/
>
)
})
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment