Skip to content

Commit dd7d788

Browse files
committed
modify tests to account for new return signatures
1 parent f131f99 commit dd7d788

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

test/minify/index.test.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
stripLineComment,
33
minifyRaw,
44
minifyCooked,
5-
compressSymbols
5+
compressSymbols,
66
} from '../../src/minify'
77

88
describe('minify utils', () => {
@@ -12,7 +12,9 @@ describe('minify utils', () => {
1212
})
1313

1414
it('ignores comment markers that are inside strings', () => {
15-
expect(stripLineComment('abc def"//"ghi\'//\'jkl//the end')).toBe('abc def"//"ghi\'//\'jkl')
15+
expect(stripLineComment('abc def"//"ghi\'//\'jkl//the end')).toBe(
16+
'abc def"//"ghi\'//\'jkl'
17+
)
1618
expect(stripLineComment('abc def"//"')).toBe('abc def"//"')
1719
})
1820

@@ -21,67 +23,77 @@ describe('minify utils', () => {
2123
})
2224

2325
it('ignores even unescaped URLs', () => {
24-
expect(stripLineComment('https://test.com// comment//')).toBe('https://test.com')
26+
expect(stripLineComment('https://test.com// comment//')).toBe(
27+
'https://test.com'
28+
)
2529
})
2630
})
2731

2832
describe('minify(Raw|Cooked)', () => {
2933
it('Removes multi-line comments', () => {
3034
const input = 'this is a/* ignore me please */test'
3135
const expected = 'this is a test' // NOTE: They're replaced with newlines, and newlines are joined
32-
const actual = minifyRaw(input)
36+
const [actual] = minifyRaw(input)
3337

3438
expect(actual).toBe(expected)
35-
expect(actual).toBe(minifyCooked(input))
39+
expect(actual).toBe(minifyCooked(input)[0])
3640
})
3741

3842
it('Joins all lines of code', () => {
3943
const input = 'this\nis\na/* ignore me \n please */\ntest'
4044
const expected = 'this is a test'
41-
const actual = minifyRaw(input)
45+
const [actual] = minifyRaw(input)
4246

4347
expect(actual).toBe(expected)
44-
expect(actual).toBe(minifyCooked(input))
48+
expect(actual).toBe(minifyCooked(input)[0])
4549
})
4650

4751
it('Removes line comments filling an entire line', () => {
4852
const input = 'line one\n// remove this comment\nline two'
4953
const expected = 'line one line two'
50-
const actual = minifyRaw(input)
54+
const [actual] = minifyRaw(input)
5155

5256
expect(actual).toBe(expected)
53-
expect(actual).toBe(minifyCooked(input))
57+
expect(actual).toBe(minifyCooked(input)[0])
5458
})
5559

5660
it('Removes line comments at the end of lines of code', () => {
5761
const input = 'valid line with // a comment\nout comments'
5862
const expected = 'valid line with out comments'
59-
const actual = minifyRaw(input)
63+
const [actual] = minifyRaw(input)
6064

6165
expect(actual).toBe(expected)
62-
expect(actual).toBe(minifyCooked(input))
66+
expect(actual).toBe(minifyCooked(input)[0])
6367
})
6468

6569
it('Preserves multi-line comments starting with /*!', () => {
66-
const input = 'this is a /*! dont ignore me please */ test/* but you can ignore me */'
70+
const input =
71+
'this is a /*! dont ignore me please */ test/* but you can ignore me */'
6772
const expected = 'this is a /*! dont ignore me please */ test'
68-
const actual = minifyRaw(input)
73+
const [actual] = minifyRaw(input)
6974

7075
expect(actual).toBe(expected)
71-
expect(actual).toBe(minifyCooked(input))
76+
expect(actual).toBe(minifyCooked(input)[0])
7277
})
7378
})
7479

7580
describe('minifyRaw', () => {
7681
it('works with raw escape codes', () => {
7782
const input = 'this\\nis\\na/* ignore me \\n please */\\ntest'
7883
const expected = 'this is a test'
79-
const actual = minifyRaw(input)
84+
const [actual] = minifyRaw(input)
8085

81-
expect(minifyRaw(input)).toBe(expected)
86+
expect(actual).toBe(expected)
87+
})
88+
})
8289

83-
// NOTE: This is just a sanity check
84-
expect(minifyCooked(input)).toBe('this\\nis\\na \\ntest')
90+
describe('minifyCooked', () => {
91+
it('works with raw escape codes', () => {
92+
const input = 'this\\nis\\na/* ignore me \\n please */\\ntest'
93+
const expected = 'this\\nis\\na \\ntest'
94+
const [actual] = minifyCooked(input)
95+
96+
expect(actual).toBe(expected)
8597
})
8698
})
8799

0 commit comments

Comments
 (0)