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
bcc4a85d
Commit
bcc4a85d
authored
Aug 20, 2019
by
Mickaël Bourgier
Browse files
Remove ButtonGroup snapshot testing
parent
90e80f00
Pipeline
#974
passed with stage
in 1 minute and 42 seconds
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
src/ButtonGroup/ButtonGroup.test.js
View file @
bcc4a85d
import
React
from
'
react
'
;
import
renderer
from
'
react-test-renderer
'
;
import
{
SheetsRegistry
}
from
'
react-jss
'
;
import
{
render
}
from
'
@testing-library/react
'
;
import
{
createTheme
}
from
'
../styles
'
;
import
wrapToTest
from
'
../utils/wrapToTest
'
;
import
Button
from
'
../Button
'
;
import
ButtonGroup
from
'
./ButtonGroup
'
;
import
Button
from
'
.
/.
./Button
'
;
import
Icon
Button
from
'
../
Icon
Button
'
;
describe
(
'
<ButtonGroup />
'
,
()
=>
{
let
componentToTest
;
let
sheets
;
let
theme
;
beforeEach
(()
=>
{
componentToTest
=
null
;
sheets
=
null
;
theme
=
null
;
});
afterEach
(()
=>
{
if
(
componentToTest
!==
null
)
{
const
options
=
{
...(
sheets
!==
null
?
{
sheets
}
:
{}),
...(
theme
!==
null
?
{
theme
}
:
{})
describe
(
'
color prop
'
,
()
=>
{
it
(
'
must set the background color of buttons if they do not override
'
,
()
=>
{
const
palette
=
{
success
:
'
green
'
,
danger
:
'
red
'
};
const
component
=
renderer
.
create
(
wrapToTest
(
options
)(
componentToTest
));
expect
(
component
.
toJSON
()).
toMatchSnapshot
();
if
(
sheets
!==
null
)
{
expect
(
sheets
.
toString
()).
toMatchSnapshot
();
}
}
});
test
(
'
Render with children
'
,
()
=>
{
componentToTest
=
(
<
ButtonGroup
>
<
Button
>
Hello
<
/Button
>
<
Button
>
<
strong
>
you
<
/strong
>
<
/Button
>
<
/ButtonGroup
>
);
sheets
=
new
SheetsRegistry
();
const
{
getAllByText
}
=
render
(
wrapToTest
({
theme
:
createTheme
({
colors
:
{
palette
}
})
})(
<
ButtonGroup
color
=
'
success
'
>
<
Button
>
success
<
/Button
>
<
Button
>
success
<
/Button
>
<
Button
color
=
'
danger
'
>
danger
<
/Button
>
<
Button
>
success
<
/Button
>
<
/ButtonGroup
>
)
);
getAllByText
(
/success/
).
forEach
(
element
=>
{
expect
(
element
).
toHaveStyle
(
`background-color:
${
palette
.
success
}
;`
);
});
getAllByText
(
/danger/
).
forEach
(
element
=>
{
expect
(
element
).
toHaveStyle
(
`background-color:
${
palette
.
danger
}
;`
);
});
});
});
test
(
'
Should include className and other props
'
,
()
=>
{
componentToTest
=
(
<
ButtonGroup
className
=
{
'
my-custom-classname
'
}
customProp
=
{
'
fez
'
}
>
<
Button
>
Hello
<
/Button
>
<
Button
>
<
strong
>
you
<
/strong
>
<
/Button
>
<
/ButtonGroup
>
);
describe
(
'
pill prop
'
,
()
=>
{
it
(
'
must round buttons and icon buttons
'
,
()
=>
{
const
Icon
=
()
=>
'
icon
'
;
const
{
getByText
}
=
render
(
wrapToTest
()(
<
ButtonGroup
pill
>
<
Button
>
button
<
/Button
>
<
IconButton
>
<
Icon
/>
<
/IconButton
>
<
/ButtonGroup
>
)
);
expect
(
getByText
(
/button/
)).
toHaveStyle
(
`border-radius: 100rem`
);
expect
(
getByText
(
/icon/
)).
toHaveStyle
(
`border-radius: 100rem`
);
});
});
});
src/ButtonGroup/__snapshots__/ButtonGroup.test.js.snap
deleted
100644 → 0
View file @
90e80f00
This diff is collapsed.
Click to expand it.
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