Skip to content

Commit 4ee56a3

Browse files
author
David-Pena
committed
chore: add failing test to functionSize for #364
1 parent e29d746 commit 4ee56a3

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/rules/rrd/functionSize.test.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DEFAULT_OVERRIDE_CONFIG } from '../../helpers/constants'
44
import { checkFunctionSize, reportFunctionSize } from './functionSize'
55

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

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

56+
it.todo('should not report files where no function exceeds the limit', () => {
57+
const script = {
58+
content: `
59+
<script setup>
60+
const sum = (a, b) => a + b
61+
62+
const someVal = 100
63+
64+
function func() {
65+
// ...
66+
// ...
67+
// ...
68+
// ...
69+
// ...
70+
// ...
71+
// ...
72+
// ...
73+
// ...
74+
// ...
75+
// ...
76+
// ...
77+
// ...
78+
// ...
79+
// ...
80+
// ...
81+
// ...
82+
// ...
83+
}
84+
</script>
85+
`,
86+
} as SFCScriptBlock
87+
const fileName = 'no-function-exceeds-limit.vue'
88+
const maxSize = DEFAULT_OVERRIDE_CONFIG.maxFunctionSize
89+
checkFunctionSize(script, fileName, maxSize)
90+
const result = reportFunctionSize(maxSize)
91+
expect(result.length).toBe(0)
92+
expect(result).toStrictEqual([])
93+
})
94+
5695
it('should not report files with multiple short functions', () => {
5796
const script = {
5897
content: `

0 commit comments

Comments
 (0)