Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Prosjekt-4
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Huda Mohamad Muataz Albizreh
Prosjekt-4
Commits
35005a99
Commit
35005a99
authored
4 years ago
by
hudaal
Browse files
Options
Downloads
Patches
Plain Diff
Added comment test, but it's not working well yet
parent
4390d429
Branches
Add_other_tests
Branches containing commit
No related tags found
1 merge request
!2
Suggestions in search
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cypress/integration/Search_test.tsx
+1
-2
1 addition, 2 deletions
cypress/integration/Search_test.tsx
src/__test__/comment.test.tsx
+38
-0
38 additions, 0 deletions
src/__test__/comment.test.tsx
src/components/Article/Comment.tsx
+4
-3
4 additions, 3 deletions
src/components/Article/Comment.tsx
with
43 additions
and
5 deletions
cypress/integration/Search_test.tsx
+
1
−
2
View file @
35005a99
/// <reference types="cypress" />
import
{
Filter
,
Search
}
from
"
../../src/actions/Actions
"
;
import
{
filter_type
,
sort_type
}
from
"
../../src/components/Navbar/FilterSortTypes
"
;
import
{
Search
}
from
"
../../src/actions/Actions
"
;
describe
(
"
SearchChecking
"
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/__test__/comment.test.tsx
0 → 100644
+
38
−
0
View file @
35005a99
import
React
from
'
react
'
;
import
{
render
,
cleanup
,
waitForElementToBeRemoved
}
from
'
@testing-library/react
'
;
import
userEvent
from
'
@testing-library/user-event
'
import
'
@testing-library/jest-dom/extend-expect
'
;
import
{
Provider
,
useSelector
}
from
"
react-redux
"
;
import
{
applyMiddleware
,
createStore
}
from
"
redux
"
;
import
{
rootReducer
,
RootState
}
from
"
../reducers/rootReducer
"
;
import
thunk
from
"
redux-thunk
"
;
import
Article
from
"
../components/Article/Article
"
;
const
myStore
=
createStore
(
rootReducer
,
applyMiddleware
(
thunk
));
function
ArticleDummyWrapper
()
{
const
search_results
=
useSelector
((
state
:
RootState
)
=>
state
.
search
)
return
(
<
div
>
<
Article
searchQuery
=
{
search_results
}
/>
</
div
>
);
}
afterEach
(()
=>
{
cleanup
();
})
beforeEach
(()
=>
{
jest
.
useFakeTimers
();
})
it
(
'
Add comment test
'
,
async
()
=>
{
const
{
getByPlaceholderText
,
getByTestId
,
getByText
,
asFragment
}
=
render
(<><
Provider
store
=
{
myStore
}
><
ArticleDummyWrapper
/></
Provider
></>,
10000
);
await
waitForElementToBeRemoved
(()
=>
getByPlaceholderText
(
"
Add your comment ..
"
));
await
userEvent
.
type
(
getByPlaceholderText
(
"
Add your comment ..
"
),
'
test comment jest
'
)
await
userEvent
.
click
(
getByTestId
(
"
comment-button
"
));
expect
(
getByTestId
(
"
comments
"
)).
toHaveValue
(
"
test comment jest
"
);
expect
(
asFragment
()).
toMatchSnapshot
();
});
This diff is collapsed.
Click to expand it.
src/components/Article/Comment.tsx
+
4
−
3
View file @
35005a99
...
...
@@ -64,11 +64,12 @@ class CommentInput extends React.Component<CommentProps , CommentState> {
<
form
>
<
div
>
{
this
.
props
.
article
.
commentConnection
.
map
((
comment
:
any
,
i
:
number
)
=>
<
p
key
=
{
i
}
className
=
{
'
comments
'
}
>
{
comment
.
text
}
</
p
>
<
p
key
=
{
i
}
data-testid
=
{
"
comments
"
}
className
=
{
'
comments
'
}
>
{
comment
.
text
}
</
p
>
)
}
<
input
type
=
{
"
text
"
}
id
=
{
"
comment-input
"
}
name
=
{
"
comment
"
}
value
=
{
this
.
state
.
value
}
onChange
=
{
this
.
handleChange
}
/>
<
button
type
=
{
'
submit
'
}
className
=
{
'
add-comment-btn
'
}
onClick
=
{
(
event
)
=>
{
data-testid
=
{
"
comment-input
"
}
placeholder
=
{
"
Add your comment ..
"
}
onChange
=
{
this
.
handleChange
}
/>
<
button
type
=
{
'
submit
'
}
className
=
{
'
add-comment-btn
'
}
data-testid
=
{
"
comment-button
"
}
onClick
=
{
(
event
)
=>
{
this
.
handleSubmit
(
event
);
this
.
setState
({
value
:
""
})
}
}
>
Add comment
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment