Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 6cd11e1

Browse files
committed
Initial tests
1 parent 6118932 commit 6cd11e1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/utils.test.js

+39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const interleave = require('../src/utils/tagged-template-literal').interleave
2+
const hasInterpolationTag = require('../src/utils/tagged-template-literal').hasInterpolationTag
3+
const parseInterpolationTag = require('../src/utils/tagged-template-literal').parseInterpolationTag
24
const isLastDeclarationCompleted = require('../src/utils/general').isLastDeclarationCompleted
35
const nextNonWhitespaceChar = require('../src/utils/general').nextNonWhitespaceChar
46
const reverseString = require('../src/utils/general').reverseString
@@ -335,4 +337,41 @@ describe('utils', () => {
335337
expect(fn(' \tstylelint-disable \t')).toBe(true)
336338
})
337339
})
340+
341+
describe('hasInterpolationTag', () => {
342+
const fn = hasInterpolationTag
343+
it('works for starting comment', () => {
344+
const expression = {
345+
leadingComments: [{ value: ' scp-block ' }],
346+
trailingComments: []
347+
}
348+
expect(fn(expression)).toBe(true)
349+
})
350+
351+
it('correctly identifies lack of tag', () => {
352+
const expression = {
353+
leadingComments: [{ value: 'some test value' }],
354+
trailingComments: [{ value: 'second test value' }]
355+
}
356+
expect(fn(expression)).toBe(false)
357+
})
358+
})
359+
360+
describe('parseInterpolationTag', () => {
361+
const fn = parseInterpolationTag
362+
it('correctly works as dummy', () => {
363+
// This is temporary
364+
const expression1 = {
365+
leadingComments: [{ value: ' scp-block ' }],
366+
trailingComments: []
367+
}
368+
expect(fn(expression1)).toBe('-interpolation-tag-mixin: test')
369+
370+
const expression2 = {
371+
leadingComments: [{ value: 'some test value' }],
372+
trailingComments: [{ value: 'second test value' }]
373+
}
374+
expect(fn(expression2)).toBe(undefined)
375+
})
376+
})
338377
})

0 commit comments

Comments
 (0)