Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
After fixing a bunch of eslint errors, I needed to make some extra
tweaks to make the tests happier.
  • Loading branch information
lencioni committed Jun 25, 2024
1 parent 165f4ff commit 64f5dac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
14 changes: 2 additions & 12 deletions test/integrations/examples/Foo-react-happo.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,14 @@ export const dynamicImportExample = () => <DynamicImportExample />;

export const themedExample = () => (
<ThemeContext.Consumer>
{(theme) => (
<button type="button">
I am
{theme}
</button>
)}
{(theme) => <button type="button">I am {theme}</button>}
</ThemeContext.Consumer>
);

export const themedExampleAsync = (renderInDom) => {
renderInDom(
<ThemeContext.Consumer>
{(theme) => (
<button type="button">
I am
{theme}
</button>
)}
{(theme) => <button type="button">I am {theme}</button>}
</ThemeContext.Consumer>,
);
return new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion test/integrations/plain-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ beforeEach(() => {
await subject();
const css = config.targets.firefox.globalCSS;
// styles.css
expect(css[0].css.trim()).toEqual('.a { b: c }');
expect(css[0].css.trim()).toMatch(/\.a \{\s*b: c;\s*}\n/);

// https://meyerweb.com/eric/tools/css/reset/reset.css
expect(css[1].css.slice(0, 44)).toEqual(
Expand Down
24 changes: 12 additions & 12 deletions test/integrations/react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ it('produces the right html', async () => {
{
component: 'Foo-react',
css: '',
html: '<button>Click meish</button>',
html: '<button type="button">Click meish</button>',
variant: 'anotherVariant',
},
{
component: 'Foo-react',
css: '',
html: '<button>Ready</button>',
html: '<button type="button">Ready</button>',
variant: 'asyncExample',
},
{
component: 'Foo-react',
css: '',
html: '<button></button>',
html: '<button type="button"></button>',
variant: 'asyncWithoutPromise',
},
{
Expand Down Expand Up @@ -161,7 +161,7 @@ it('produces the right html', async () => {
{
component: 'Foo-react',
css: '',
html: '<button>I am in a portal</button>',
html: '<button type="button">I am in a portal</button>',
variant: 'portalExample',
},
{
Expand All @@ -179,38 +179,38 @@ it('produces the right html', async () => {
{
component: 'Foo-react',
css: '',
html: '<button>I am dark</button>',
html: '<button type="button">I am dark</button>',
variant: 'themedExample',
},
{
component: 'Foo-react',
css: '',
html: '<button>I am dark</button>',
html: '<button type="button">I am dark</button>',
variant: 'themedExampleAsync',
},
{
component: 'Generated',
css: '',
html: '<button>Four</button>',
html: '<button type="button">Four</button>',
variant: '_four',
},
{
component: 'Generated',
css: '',
html: '<button>One</button>',
html: '<button type="button">One</button>',
variant: 'one',
stylesheets: ['one'],
},
{
component: 'Generated',
css: '',
html: '<button>Three</button>',
html: '<button type="button">Three</button>',
variant: 'three',
},
{
component: 'Generated',
css: '',
html: '<button>Two</button>',
html: '<button type="button">Two</button>',
variant: 'two',
stylesheets: ['two'],
},
Expand Down Expand Up @@ -261,7 +261,7 @@ it('resolves assets correctly', async () => {
it('produces the right css', async () => {
await subject();
expect(config.targets.chrome.globalCSS[0]).toEqual({
css: '.a { b: c }\n',
css: expect.stringMatching(/\.a \{\s*b: c;\s*}\n/),
source: path.resolve(__dirname, 'styles.css'),
});
expect(config.targets.chrome.globalCSS[1]).toEqual({
Expand Down Expand Up @@ -298,7 +298,7 @@ it('works with prerender=false', async () => {
await subject();
expect(config.targets.chrome.globalCSS).toEqual([
{
css: '.a { b: c }\n',
css: expect.stringMatching(/\.a \{\s*b: c;\s*}\n/),
source: path.resolve(__dirname, 'styles.css'),
},
{
Expand Down
4 changes: 2 additions & 2 deletions test/integrations/static-plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ it('produces the static package', async () => {

it('includes css', async () => {
await subject();
expect(config.targets.chrome.globalCSS).toEqual('.a { b: c }.foo { color: red }');
expect(config.targets.chrome.globalCSS).toEqual('.a { b: c;}.foo { color: red }');
});

it('includes external css', async () => {
config.stylesheets.push('http://andybrewer.github.io/mvp/mvp.css');
await subject();
expect(config.targets.chrome.globalCSS).toMatch(/\.a { b: c }.*MVP\.css v/);
expect(config.targets.chrome.globalCSS).toMatch(/\.a {\s*b: c;}.*MVP\.css v/);
});

0 comments on commit 64f5dac

Please sign in to comment.