Skip to content

Commit

Permalink
chore: add failing test to functionSize for #364
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Pena committed Sep 30, 2024
1 parent e29d746 commit 4ee56a3
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/rules/rrd/functionSize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DEFAULT_OVERRIDE_CONFIG } from '../../helpers/constants'
import { checkFunctionSize, reportFunctionSize } from './functionSize'

describe('checkFunctionSize', () => {
it('should not report files where functions do not exceed the recommended limit', () => {
it('should not report files where functions do not exceed the limit', () => {
const script = {
content: `
<script setup>
Expand All @@ -28,7 +28,7 @@ describe('checkFunctionSize', () => {
expect(result).toStrictEqual([])
})

it('should not report files where arrow functions without curly braces do not exceed the recommended limit', () => {
it('should not report files where arrow functions without curly braces do not exceed the limit', () => {
const script = {
content: `
<script setup>
Expand All @@ -53,6 +53,45 @@ describe('checkFunctionSize', () => {
expect(result).toStrictEqual([])
})

it.todo('should not report files where no function exceeds the limit', () => {
const script = {
content: `
<script setup>
const sum = (a, b) => a + b
const someVal = 100
function func() {
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
// ...
}
</script>
`,
} as SFCScriptBlock
const fileName = 'no-function-exceeds-limit.vue'
const maxSize = DEFAULT_OVERRIDE_CONFIG.maxFunctionSize
checkFunctionSize(script, fileName, maxSize)
const result = reportFunctionSize(maxSize)
expect(result.length).toBe(0)
expect(result).toStrictEqual([])
})

it('should not report files with multiple short functions', () => {
const script = {
content: `
Expand Down

0 comments on commit 4ee56a3

Please sign in to comment.