Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Nov 4, 2023
1 parent 89d496e commit 0b4417d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
7 changes: 4 additions & 3 deletions packages/eslint-plugin/tests/class-matching/angular.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import rule from '../../src/rules/class-order'
import { RuleTester } from 'eslint'
import parser from '@angular-eslint/template-parser'

new RuleTester({
parserOptions: {
Expand All @@ -16,23 +17,23 @@ new RuleTester({
m:8
bg:black
p:8
fg:white
f:24
fg:white
">
:)
</div>`,
output: `
<div class="
bg:black
fg:white
f:24
fg:white
m:8
p:8
">
:)
</div>`,
errors: [{ messageId: 'invalidClassOrder' }],
parser: require.resolve('@angular-eslint/template-parser'),
parser,
}
],
})
6 changes: 3 additions & 3 deletions packages/eslint-plugin/tests/class-matching/mdx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const ruleTester = new RuleTester({
})

ruleTester.run('mdx class order', OrderRule, {
valid: [{ code: `<div class="bg:black fg:white f:24 m:8 p:8">Simple, basic</div>` }],
valid: [{ code: `<div class="bg:black f:24 fg:white m:8 p:8">Simple, basic</div>` }],
invalid: [
{
code: `
# Test
<div class="m:8 bg:black p:8 fg:white f:24">Simple</div>`,
<div class="m:8 bg:black p:8 f:24 fg:white">Simple</div>`,
output: `
# Test
<div class="bg:black fg:white f:24 m:8 p:8">Simple</div>`,
<div class="bg:black f:24 fg:white m:8 p:8">Simple</div>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.mdx',
parser: require.resolve('eslint-mdx'),
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/tests/class-matching/svelte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const ruleTester = new RuleTester({
})

ruleTester.run('svelte class order', rule, {
valid: [{ code: `<div class="bg:black fg:white f:24 m:8 p:8">Simple, basic</div>` }],
valid: [{ code: `<div class="bg:black f:24 fg:white m:8 p:8">Simple, basic</div>` }],
invalid: [
{
code: `<div class="m:8 bg:black p:8 fg:white f:24 {flipped ? 'flipped' : ''}">Enhancing readability</div>`,
output: `<div class="bg:black fg:white f:24 m:8 p:8 {flipped ? 'flipped' : ''}">Enhancing readability</div>`,
code: `<div class="m:8 bg:black p:8 f:24 fg:white {flipped ? 'flipped' : ''}">Enhancing readability</div>`,
output: `<div class="bg:black f:24 fg:white m:8 p:8 {flipped ? 'flipped' : ''}">Enhancing readability</div>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.svelte',
parser: require.resolve('svelte-eslint-parser'),
Expand Down
22 changes: 11 additions & 11 deletions packages/eslint-plugin/tests/class-matching/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ const ruleTester = new RuleTester({
})

ruleTester.run('vue class order', rule, {
valid: [{ code: `<div class="bg:black fg:white f:24 m:8 p:8">Simple, basic</div>` }],
valid: [{ code: `<div class="bg:black f:24 fg:white m:8 p:8">Simple, basic</div>` }],
invalid: [
{
code: `<template><div class="m:8 bg:black p:8 fg:white f:24">Enhancing readability</div></template>`,
output: `<template><div class="bg:black fg:white f:24 m:8 p:8">Enhancing readability</div></template>`,
code: `<template><div class="m:8 bg:black p:8 f:24 fg:white">Enhancing readability</div></template>`,
output: `<template><div class="bg:black f:24 fg:white m:8 p:8">Enhancing readability</div></template>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.vue',
parser: require.resolve('vue-eslint-parser'),
},
{
code: `<template><div class="m:8 bg:black p:8 fg:white f:24">Classnames will be ordered</div></template>`,
output: `<template><div class="bg:black fg:white f:24 m:8 p:8">Classnames will be ordered</div></template>`,
code: `<template><div class="m:8 bg:black p:8 f:24 fg:white">Classnames will be ordered</div></template>`,
output: `<template><div class="bg:black f:24 fg:white m:8 p:8">Classnames will be ordered</div></template>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.vue',
parser: require.resolve('vue-eslint-parser'),
},
{
code: `<template><div :class="['m:8 bg:black p:8 fg:white f:24']">Enhancing readability 2</div></template>`,
output: `<template><div :class="['bg:black fg:white f:24 m:8 p:8']">Enhancing readability 2</div></template>`,
code: `<template><div :class="['m:8 bg:black p:8 f:24 fg:white']">Enhancing readability 2</div></template>`,
output: `<template><div :class="['bg:black f:24 fg:white m:8 p:8']">Enhancing readability 2</div></template>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.vue',
parser: require.resolve('vue-eslint-parser'),
},
{
code: `<template><div v-bind:class="{'m:8 bg:black p:8 fg:white f:24': true}">:)...</div></template>`,
output: `<template><div v-bind:class="{'bg:black fg:white f:24 m:8 p:8': true}">:)...</div></template>`,
code: `<template><div v-bind:class="{'m:8 bg:black p:8 f:24 fg:white': true}">:)...</div></template>`,
output: `<template><div v-bind:class="{'bg:black f:24 fg:white m:8 p:8': true}">:)...</div></template>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.vue',
parser: require.resolve('vue-eslint-parser'),
},
{
code: `<template><div :class="ctl(\`m:8 bg:black p:8 fg:white f:24 \${some}\`)" /></template>`,
output: `<template><div :class="ctl(\`bg:black fg:white f:24 m:8 p:8 \${some}\`)" /></template>`,
code: `<template><div :class="ctl(\`m:8 bg:black p:8 f:24 fg:white \${some}\`)" /></template>`,
output: `<template><div :class="ctl(\`bg:black f:24 fg:white m:8 p:8 \${some}\`)" /></template>`,
errors: [{ messageId: 'invalidClassOrder' }],
filename: 'test.vue',
parser: require.resolve('vue-eslint-parser'),
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ new RuleTester({
],
invalid: [
{
code: `<div class="fg:white f:24 m:8 p:8 bg:black">Classnames will be ordered</div>`,
code: `<div class="f:24 fg:white m:8 p:8 bg:black">Classnames will be ordered</div>`,
output: `<div class="bg:black f:24 fg:white m:8 p:8">Classnames will be ordered</div>`,
errors: [{ messageId: 'invalidClassOrder' }],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ new RuleTester({
}).run('invalid', rule, {
valid: [
{
code: `<div class="bg:black fg:white f:24 m:8 p:8">Simple, basic</div>`,
code: `<div class="bg:black f:24 fg:white m:8 p:8">Simple, basic</div>`,
}
],
invalid: [
Expand Down

0 comments on commit 0b4417d

Please sign in to comment.