Skip to content

Commit

Permalink
Merge pull request #68 from yoqwerty/improveCoverage
Browse files Browse the repository at this point in the history
adding test cases for increasing coverage
  • Loading branch information
adierkens committed Oct 2, 2021
2 parents b6dd622 + 0bf1a2c commit 469bc24
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@
"doc",
"test"
]
},
{
"login": "yoqwerty",
"name": "yoqwerty",
"avatar_url": "https://avatars.githubusercontent.com/u/26031967?v=4",
"profile": "https://github.com/yoqwerty",
"contributions": [
"test"
]
}
],
"contributorsPerLine": 7
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/joshtym"><img src="https://avatars3.githubusercontent.com/u/6886456?v=4" width="100px;" alt="Joshua Tymburski"/><br /><sub><b>Joshua Tymburski</b></sub></a><br /><a href="https://github.com/intuit/postcss-themed/commits?author=joshtym" title="Tests">⚠️</a> <a href="https://github.com/intuit/postcss-themed/commits?author=joshtym" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kendallgassner"><img src="https://avatars3.githubusercontent.com/u/15275462?v=4" width="100px;" alt="Kendall Gassner"/><br /><sub><b>Kendall Gassner</b></sub></a><br /><a href="https://github.com/intuit/postcss-themed/commits?author=kendallgassner" title="Tests">⚠️</a> <a href="https://github.com/intuit/postcss-themed/commits?author=kendallgassner" title="Code">💻</a></td>
<td align="center"><a href="http://kellyharrop.com"><img src="https://avatars.githubusercontent.com/u/24794756?v=4" width="100px;" alt="Kelly Harrop"/><br /><sub><b>Kelly Harrop</b></sub></a><br /><a href="https://github.com/intuit/postcss-themed/commits?author=kharrop" title="Code">💻</a> <a href="https://github.com/intuit/postcss-themed/commits?author=kharrop" title="Documentation">📖</a> <a href="https://github.com/intuit/postcss-themed/commits?author=kharrop" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/yoqwerty"><img src="https://avatars.githubusercontent.com/u/26031967?v=4" width="100px;" alt="yoqwerty"/><br /><sub><b>yoqwerty</b></sub></a><br /><a href="https://github.com/intuit/postcss-themed/commits?author=yoqwerty" title="Tests">⚠️</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
104 changes: 104 additions & 0 deletions __tests__/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,110 @@ it('should be able to extend a theme that extends another theme', () => {
});
});

it('should add the light extras if there is an extension in the light theme', () => {
expect(
resolveThemeExtension({
default: {
light: { color: 'white' },
dark: { color: 'black' },
},
myTheme: {
light: { color: 'blue' },
dark: {},
},
myChildTheme: {
light: { extends: 'myTheme' },
dark: {},
},
})
).toStrictEqual({
default: {
light: { color: 'white' },
dark: { color: 'black' },
},
myChildTheme: {
dark: {},
light: { color: 'blue' },
},
myTheme: {
dark: {},
light: { color: 'blue' },
}
});
});

it('should add dark extras if there is an extension in the dark theme', () => {
expect(
resolveThemeExtension({
default: {
light: { color: 'white' },
dark: { color: 'black' },
},
myTheme: {
light: {},
dark: {color: 'blue'},
},
myChildTheme: {
light: {},
dark: {extends: 'myTheme'}
},
})
).toStrictEqual({
default: {
light: { color: 'white' },
dark: { color: 'black' },
},
myChildTheme: {
light: {},
dark: { color: 'blue' },
},
myTheme: {
light: {},
dark: { color: 'blue' },
}
});
});

it('should be able to resolve color scheme theme correctly if there is a chain in the extension ', () => {
expect(
resolveThemeExtension({
default: {
light: { color: 'white' },
dark: {},
},
myTheme: {
light: {},
dark: {color: 'pink', extends: 'myOtherTheme'},
},
myOtherTheme: {
light: { color: 'blue'},
dark: {color: 'red', extends: 'yetAnotherTheme'},
},
yetAnotherTheme: {
light: { color: 'red'},
dark: { color: 'red'}
}
})
).toStrictEqual({
default: {
light: { color: 'white' },
dark: {},
},
myTheme: {
light: {},
dark: { color: 'pink' }
},
myOtherTheme: {
light: { color: 'blue'},
dark: { color: 'red'}
},
yetAnotherTheme: {
light: { color: 'red' },
dark: { color: 'red' }
}
});
});

it('should be able to extend a theme that extends another theme - out of order', () => {
expect(
resolveThemeExtension(
Expand Down
30 changes: 30 additions & 0 deletions __tests__/modern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,36 @@ it('should error on missing space', () => {
});
});

it('should error while trying to read invalid/ not available input file provided', () => {
const config = {
default: {
color: 'purple',
},
light: {
color: 'white',
},
};

return run(
`
.test {
color: @theme color;
background-image: linear-gradient(to right, @theme color, @theme color)
}
`,
'',
{
config,
modules: 'default',
},
'/qwerty.css'
).catch((e) => {
expect(e.message).toEqual(
"ENOENT: no such file or directory, open '/qwerty.css'"
);
});
});

it('should error on invalid alt usage space', () => {
const config = {
default: {
Expand Down

0 comments on commit 469bc24

Please sign in to comment.