Skip to content

Commit e6ccfd1

Browse files
joyenjoyerclaude
andcommitted
test(ui-truncate-text): use vitest matchers instead of chai's to.equal
Replace expect(...).to.equal(...) chai-style assertions with vitest's native toEqual() in cleanString.test.tsx and cleanData.test.tsx. These were leftover from an old Mocha/Chai migration and were the only reason oxlint's vitest/valid-expect rule was disabled for this package's tests. Remove that now-unneeded per-file override from .oxlintrc.json so the rule applies uniformly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 527cc7d commit e6ccfd1

3 files changed

Lines changed: 13 additions & 20 deletions

File tree

.oxlintrc.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,6 @@
366366
]
367367
}
368368
},
369-
{
370-
"files": ["packages/ui-truncate-text/src/TruncateText/__tests__/**"],
371-
"plugins": ["vitest"],
372-
"rules": {
373-
"vitest/valid-expect": "off"
374-
}
375-
},
376369
{
377370
"files": ["**/*"],
378371
"excludeFiles": ["**/__tests__/**"],

packages/ui-truncate-text/src/TruncateText/__tests__/cleanData.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('cleanData', () => {
3535
ignore: [' ']
3636
}
3737
const newData = cleanData(data, options)
38-
expect(newData[0].join('')).to.equal('Test...')
38+
expect(newData[0].join('')).toEqual('Test...')
3939
})
4040

4141
it('should remove spaces from the end of word data', async () => {
@@ -47,7 +47,7 @@ describe('cleanData', () => {
4747
}
4848

4949
const newData = cleanData(data, options)
50-
expect(newData[0].join('')).to.equal('Test...')
50+
expect(newData[0].join('')).toEqual('Test...')
5151
})
5252

5353
it('should remove spaces from the middle of character data', async () => {
@@ -61,7 +61,7 @@ describe('cleanData', () => {
6161
}
6262

6363
const newData = cleanData(data, options)
64-
expect(newData[0].join('')).to.equal('Hello...world')
64+
expect(newData[0].join('')).toEqual('Hello...world')
6565
})
6666

6767
it('should remove spaces from the middle of word data', async () => {
@@ -73,7 +73,7 @@ describe('cleanData', () => {
7373
}
7474

7575
const newData = cleanData(data, options)
76-
expect(newData[0].join('')).to.equal('Hello...world')
76+
expect(newData[0].join('')).toEqual('Hello...world')
7777
})
7878

7979
it('should do a thorough cleaning', async () => {
@@ -85,7 +85,7 @@ describe('cleanData', () => {
8585
}
8686

8787
const newData = cleanData(data, options, true)
88-
expect(newData[0].join('')).to.equal('Test...')
88+
expect(newData[0].join('')).toEqual('Test...')
8989
})
9090

9191
it('should remove spaces from the end of complex character data', async () => {
@@ -106,8 +106,8 @@ describe('cleanData', () => {
106106
newData = cleanData(data, options)
107107
const text2 = newData[0].join('') + newData[1].join('')
108108

109-
expect(text).to.equal('Hello...')
110-
expect(text2).to.equal('Hello world...')
109+
expect(text).toEqual('Hello...')
110+
expect(text2).toEqual('Hello world...')
111111
})
112112

113113
it('should remove spaces from the middle of complex word data', async () => {
@@ -125,7 +125,7 @@ describe('cleanData', () => {
125125
newData = cleanData(data, options)
126126
const text2 = newData[0].join('') + newData[1].join('')
127127

128-
expect(text).to.equal('Hello...world')
129-
expect(text2).to.equal('Hello...world')
128+
expect(text).toEqual('Hello...world')
129+
expect(text2).toEqual('Hello...world')
130130
})
131131
})

packages/ui-truncate-text/src/TruncateText/__tests__/cleanString.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ describe('cleanSring', () => {
3131
const string = ' Hello world '
3232

3333
const newString = cleanString(string, [' '])
34-
expect(newString).to.equal('Hello world')
34+
expect(newString).toEqual('Hello world')
3535
})
3636

3737
it('should remove spaces from only the end of string', async () => {
3838
const string = ' Hello world '
3939

4040
const newString = cleanString(string, [' '], false)
41-
expect(newString).to.equal(' Hello world')
41+
expect(newString).toEqual(' Hello world')
4242
})
4343

4444
it('should remove spaces and commas', async () => {
4545
const string = ' Hello world,'
4646

4747
const newString = cleanString(string, [' ', ','])
48-
expect(newString).to.equal('Hello world')
48+
expect(newString).toEqual('Hello world')
4949
})
5050

5151
it('should do a thorough cleaning', async () => {
5252
const string = 'Hello world. '
5353

5454
const newString = cleanString(string, [' ', '.'], false, true, true)
55-
expect(newString).to.equal('Hello world')
55+
expect(newString).toEqual('Hello world')
5656
})
5757
})

0 commit comments

Comments
 (0)