Skip to content

Commit

Permalink
Add tests for haveStyleRule messages
Browse files Browse the repository at this point in the history
  • Loading branch information
myabc committed Sep 5, 2017
1 parent c9b9609 commit fa771a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/__snapshots__/toHaveStyleRule.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`message when property not found 1`] = `"Property not found: \\"a\\""`;

exports[`message when value does not match 1`] = `
"Expected background to match:
\\"red\\"
Received:
\\"orange\\""
`;
15 changes: 15 additions & 0 deletions test/toHaveStyleRule.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const toHaveStyleRule = (component, property, value, options) => {
expect(mount(component)).toHaveStyleRule(property, value, options)
}

test('message when property not found', () => {
expect(() => expect(null).toHaveStyleRule('a')).toThrowErrorMatchingSnapshot()
})

test('null', () => {
expect(null).not.toHaveStyleRule('a', 'b')
})
Expand All @@ -31,6 +35,17 @@ test('non-styled', () => {
notToHaveStyleRule(<div />, 'a', 'b')
})

test('message when value does not match', () => {
const Wrapper = styled.section`background: orange;`

expect(() => {
expect(renderer.create(<Wrapper />).toJSON()).toHaveStyleRule(
'background',
'red'
)
}).toThrowErrorMatchingSnapshot()
})

test('basic', () => {
const Wrapper = styled.section`
padding: 4em;
Expand Down

0 comments on commit fa771a6

Please sign in to comment.