Skip to content

Commit

Permalink
chore: add more lint rules to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cardoso committed Nov 13, 2024
1 parent 66d35e1 commit 8deb91f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 4 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ export default tseslint.config(
},
rules: {
...vitest.configs.recommended.rules,
'vitest/no-focused-tests': 'error',
'vitest/valid-expect-in-promise': 'error',
'vitest/no-conditional-tests': 'error',
'vitest/no-done-callback': 'error',
},
},
{
Expand Down
44 changes: 20 additions & 24 deletions packages/@lwc/ssr-compiler/src/__tests__/estemplate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ describe.each(
)('%s', (topLevelFnName, topLevelFn) => {
const yieldStmtsAllowed = topLevelFnName === 'esTemplateWithYield';
describe('failure upon parse', () => {
if (!yieldStmtsAllowed) {
test('with yield statements', () => {
const createTemplate = () => topLevelFn`
const foo = "bar";
yield foo;
`;
expect(createTemplate).toThrow('Unexpected token');
});
}
test.skipIf(yieldStmtsAllowed)('with yield statements', () => {
const createTemplate = () => topLevelFn`
const foo = "bar";
yield foo;
`;
expect(createTemplate).toThrow('Unexpected token');
});

test('when attempting to replace unreplaceable code constructs', () => {
// Someone might try to create a template where 'class' or 'function'
Expand Down Expand Up @@ -68,26 +66,24 @@ describe.each(
});

describe('successful replacement', () => {
if (yieldStmtsAllowed) {
test('with yield statements', () => {
const tmpl = topLevelFn`
test.runIf(yieldStmtsAllowed)('with yield statements', () => {
const tmpl = topLevelFn`
yield ${is.literal};
`;
const replacedAst = tmpl(b.literal('foo'));
const replacedAst = tmpl(b.literal('foo'));

expect(replacedAst).toMatchObject({
expression: {
argument: {
type: 'Literal',
value: 'foo',
},
delegate: false,
type: 'YieldExpression',
expect(replacedAst).toMatchObject({
expression: {
argument: {
type: 'Literal',
value: 'foo',
},
type: 'ExpressionStatement',
});
delegate: false,
type: 'YieldExpression',
},
type: 'ExpressionStatement',
});
}
});
test('with LH identifier nodes', () => {
const tmpl = topLevelFn`
const ${is.identifier} = 'foobar'
Expand Down

0 comments on commit 8deb91f

Please sign in to comment.