Skip to content

Commit 277cde6

Browse files
authored
test: add snapshot toHaveStyle diff output (#42)
1 parent 3ce9c62 commit 277cde6

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`.toHaveStyle handles negative test cases 1`] = `
4+
"<dim>expect(</><red>element</><dim>).toHaveStyle()</>
5+
6+
<green>- Expected</>
7+
8+
<dim> backgroundColor: blue;</>
9+
<dim> transform: [</>
10+
<dim> {</>
11+
<green>- \\"scale\\": 1</>
12+
<red>+ \\"scale\\": 2</>
13+
<dim> }</>
14+
<dim> ];</>"
15+
`;
16+
17+
exports[`.toHaveStyle handles transform when transform undefined 1`] = `
18+
"<dim>expect(</><red>element</><dim>).toHaveStyle()</>
19+
20+
<green>- Expected</>
21+
22+
<green>- transform: [</>
23+
<green>- {</>
24+
<green>- \\"scale\\": 1</>
25+
<green>- }</>
26+
<green>- ];</>
27+
<red>+ transform: undefined;</>"
28+
`;

src/__tests__/to-have-style.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('.toHaveStyle', () => {
5252
const container = getByTestId('container');
5353
expect(() =>
5454
expect(container).toHaveStyle({ backgroundColor: 'blue', transform: [{ scale: 1 }] }),
55-
).toThrowError();
55+
).toThrowErrorMatchingSnapshot();
5656
expect(() => expect(container).toHaveStyle({ fontWeight: 'bold' })).toThrowError();
5757
expect(() => expect(container).not.toHaveStyle({ color: 'black' })).toThrowError();
5858
});
@@ -83,6 +83,8 @@ describe('.toHaveStyle', () => {
8383
);
8484

8585
const container = getByTestId('container');
86-
expect(() => expect(container).toHaveStyle({ transform: [{ scale: 1 }] })).toThrowError();
86+
expect(() =>
87+
expect(container).toHaveStyle({ transform: [{ scale: 1 }] }),
88+
).toThrowErrorMatchingSnapshot();
8789
});
8890
});

0 commit comments

Comments
 (0)