Skip to content

Commit 9ed3e72

Browse files
committed
add unit test verifying the return signature behavior
1 parent dd7d788 commit 9ed3e72

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/minify/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
compressSymbols,
66
} from '../../src/minify'
77

8+
import { makePlaceholder } from '../../src/css/placeholderUtils'
9+
810
describe('minify utils', () => {
911
describe('stripLineComment', () => {
1012
it('splits a line by potential comment starts and joins until one is an actual comment', () => {
@@ -75,6 +77,18 @@ describe('minify utils', () => {
7577
expect(actual).toBe(expected)
7678
expect(actual).toBe(minifyCooked(input)[0])
7779
})
80+
81+
it('Returns the indices of removed placeholders (expressions)', () => {
82+
const placeholder1 = makePlaceholder(0)
83+
const placeholder2 = makePlaceholder(1)
84+
const input = `this is some\ninput with ${placeholder1} and // ignored ${placeholder2}`
85+
const expected = `this is some input with ${placeholder1} and `
86+
const [actual, indices] = minifyRaw(input)
87+
88+
expect(actual).toBe(expected)
89+
expect(indices).toEqual([1])
90+
expect(minifyCooked(input)).toEqual([actual, [1]])
91+
})
7892
})
7993

8094
describe('minifyRaw', () => {

0 commit comments

Comments
 (0)