mirror of
https://github.com/sasjs/lint.git
synced 2025-12-10 17:34:36 +00:00
test: Added for trimComments
This commit is contained in:
74
src/utils/trimComments.spec.ts
Normal file
74
src/utils/trimComments.spec.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { trimComments } from './trimComments'
|
||||
|
||||
describe('trimComments', () => {
|
||||
it('should return statment', () => {
|
||||
expect(
|
||||
trimComments(`
|
||||
/* some comment */ some code;
|
||||
`)
|
||||
).toEqual({ statement: 'some code;', commentStarted: false })
|
||||
})
|
||||
|
||||
it('should return statment, having multi-line comment', () => {
|
||||
expect(
|
||||
trimComments(`
|
||||
/* some
|
||||
comment */
|
||||
some code;
|
||||
`)
|
||||
).toEqual({ statement: 'some code;', commentStarted: false })
|
||||
})
|
||||
|
||||
it('should return statment, having multi-line comment and some code present in comment', () => {
|
||||
expect(
|
||||
trimComments(`
|
||||
/* some
|
||||
some code;
|
||||
comment */
|
||||
some other code;
|
||||
`)
|
||||
).toEqual({ statement: 'some other code;', commentStarted: false })
|
||||
})
|
||||
|
||||
it('should return empty statment, having only comment', () => {
|
||||
expect(
|
||||
trimComments(`
|
||||
/* some
|
||||
some code;
|
||||
comment */
|
||||
`)
|
||||
).toEqual({ statement: '', commentStarted: false })
|
||||
})
|
||||
|
||||
it('should return empty statment, having continuity in comment', () => {
|
||||
expect(
|
||||
trimComments(`
|
||||
/* some
|
||||
some code;
|
||||
`)
|
||||
).toEqual({ statement: '', commentStarted: true })
|
||||
})
|
||||
|
||||
it('should return statment, having already started comment and ends', () => {
|
||||
expect(
|
||||
trimComments(
|
||||
`
|
||||
comment */
|
||||
some code;
|
||||
`,
|
||||
true
|
||||
)
|
||||
).toEqual({ statement: 'some code;', commentStarted: false })
|
||||
})
|
||||
|
||||
it('should return empty statment, having already started comment and continuity in comment', () => {
|
||||
expect(
|
||||
trimComments(
|
||||
`
|
||||
some code;
|
||||
`,
|
||||
true
|
||||
)
|
||||
).toEqual({ statement: '', commentStarted: true })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user