Skip to content

Commit

Permalink
feat: add javascript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omariosouto committed Jul 26, 2022
1 parent 42f32af commit a8f0632
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/parse-stylesheet/__snapshots__/parse-stylesheet.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`parseStyleSheet() when receive default stylesheet rules and it has a stylesheet for hover and focus 1`] = `
Object {
"&:focus, body.dark &.unique-id:focus": Object {
"backgroundColor": "black",
},
"&:hover, body.dark &.unique-id:hover": Object {
"backgroundColor": "blue",
},
"backgroundColor": "red",
}
`;

exports[`parseStyleSheet() when receive default stylesheet rules and it has only a stylesheet rule vertical and horizontal 1`] = `
Object {
"padding-bottom": "10px",
"padding-top": "10px",
}
`;

exports[`parseStyleSheet() when receive responsive stylesheet rules and it has a stylesheet for hover and focus 1`] = `
Object {
"&:focus, body.dark &.unique-id:focus": Object {
"@media (min-width: 0px)": Object {
"backgroundColor": "black",
},
"@media (min-width: 768px)": Object {
"backgroundColor": "grey",
},
},
"&:hover, body.dark &.unique-id:hover": Object {
"@media (min-width: 0px)": Object {
"backgroundColor": "blue",
},
"@media (min-width: 480px)": Object {
"backgroundColor": "navy",
},
},
"backgroundColor": "red",
}
`;

exports[`parseStyleSheet() when receive responsive stylesheet rules and it has only 1 stylesheet rule with 1 breakpoint 1`] = `
Object {
"@media (min-width: 0px)": Object {
Expand Down
31 changes: 31 additions & 0 deletions lib/parse-stylesheet/parse-stylesheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ describe('parseStyleSheet()', () => {
const input = parseStyleSheet({
paddingVertical: '10px',
});
expect(input).toMatchSnapshot();
});

it('and it has a stylesheet for hover and focus', () => {
const input = parseStyleSheet({
backgroundColor: 'red',
hover: {
backgroundColor: 'blue',
},
focus: {
backgroundColor: 'black',
},
});
expect(input).toMatchSnapshot();
});
});
Expand Down Expand Up @@ -58,5 +70,24 @@ describe('parseStyleSheet()', () => {

expect(input).toMatchSnapshot();
});

it('and it has a stylesheet for hover and focus', () => {
const input = parseStyleSheet({
backgroundColor: 'red',
hover: {
backgroundColor: {
xs: 'blue',
sm: 'navy',
},
},
focus: {
backgroundColor: {
xs: 'black',
md: 'grey',
},
},
});
expect(input).toMatchSnapshot();
});
});
});

0 comments on commit a8f0632

Please sign in to comment.