Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
webf
react-webf
Commits
d2cb2a34
Commit
d2cb2a34
authored
Aug 31, 2019
by
Mickaël Bourgier
Browse files
Remove Anchor snapshot testing
parent
0d8011c6
Pipeline
#1074
passed with stage
in 1 minute and 46 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/Anchor/Anchor.test.js
View file @
d2cb2a34
import
React
from
'
react
'
;
import
renderer
from
'
react-test-renderer
'
;
import
{
SheetsRegistry
}
from
'
react-jss
'
;
import
{
cleanup
,
render
}
from
'
@testing-library/react
'
;
import
wrapToTest
from
'
../utils/wrapToTest
'
;
import
Anchor
from
'
./Anchor
'
;
describe
(
'
<Anchor />
'
,
()
=>
{
let
componentToTest
;
let
sheets
;
beforeEach
(()
=>
{
componentToTest
=
null
;
sheets
=
null
;
});
afterEach
(()
=>
{
if
(
componentToTest
!==
null
)
{
const
options
=
sheets
===
null
?
{}
:
{
sheets
};
const
component
=
renderer
.
create
(
wrapToTest
(
options
)(
componentToTest
));
afterEach
(
cleanup
);
expect
(
component
.
toJSON
()).
toMatchSnapshot
();
if
(
sheets
!==
null
)
{
expect
(
sheets
.
toString
()).
toMatchSnapshot
();
}
}
});
test
(
'
Render with minimum required props
'
,
()
=>
{
componentToTest
=
<
Anchor
id
=
'
id
'
/>
;
sheets
=
new
SheetsRegistry
();
});
test
(
'
Could render a custom component
'
,
()
=>
{
componentToTest
=
<
Anchor
id
=
'
id
'
component
=
'
p
'
/>
;
});
test
(
'
Render with children
'
,
()
=>
{
componentToTest
=
(
<
Anchor
id
=
'
id
'
>
Hello
<
strong
>
you
<
/strong
>
<
/Anchor
>
it
(
'
can be rendered
'
,
()
=>
{
const
{
getByText
}
=
render
(
wrapToTest
()(
<
Anchor
id
=
'
anchor-id
'
>
anchor
<
/Anchor>
)
);
});
test
(
'
Should include className and other props
'
,
()
=>
{
componentToTest
=
(
<
Anchor
id
=
'
id
'
className
=
'
my-custom-class
'
myCustomProp
=
'
value
'
/>
);
});
const
anchor
=
getByText
(
/anchor/
);
test
(
'
Render with custom offset
'
,
()
=>
{
componentToTest
=
<
Anchor
id
=
'
id
'
offset
=
{
42
}
/>
;
sheets
=
new
SheetsRegistry
();
expect
(
anchor
).
toHaveTextContent
(
'
anchor
'
);
expect
(
anchor
).
toContainElement
(
document
.
getElementById
(
'
anchor-id
'
));
});
});
src/Anchor/__snapshots__/Anchor.test.js.snap
deleted
100644 → 0
View file @
0d8011c6
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Anchor /> Could render a custom component 1`] = `
<p
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</p>
`;
exports[`<Anchor /> Render with children 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
Hello
<strong>
you
</strong>
</div>
`;
exports[`<Anchor /> Render with custom offset 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
exports[`<Anchor /> Render with custom offset 2`] = `
".Anchor-root-0-1-1 {
position: relative;
}
.Anchor-anchor-0-1-3 {
position: absolute;
top: -42px;
}
@media (min-width:0px) and (orientation: landscape) {
.Anchor-anchor-0-1-3 {
top: -42px;
}
}
@media (min-width:576px) {
.Anchor-anchor-0-1-3 {
top: -42px;
}
}"
`;
exports[`<Anchor /> Render with minimum required props 1`] = `
<div
className="Anchor-root-0-1-1"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
exports[`<Anchor /> Render with minimum required props 2`] = `
".Anchor-root-0-1-1 {
position: relative;
}
.Anchor-anchor-0-1-3 {
position: absolute;
top: -56px;
}
@media (min-width:0px) and (orientation: landscape) {
.Anchor-anchor-0-1-3 {
top: -48px;
}
}
@media (min-width:576px) {
.Anchor-anchor-0-1-3 {
top: -64px;
}
}"
`;
exports[`<Anchor /> Should include className and other props 1`] = `
<div
className="Anchor-root-0-1-1 my-custom-class"
myCustomProp="value"
>
<div
className="Anchor-anchor-0-1-2 Anchor-anchor-0-1-3"
id="id"
/>
</div>
`;
Write
Preview
Supports
Markdown
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