11import {
22 stripLineComment ,
33 minifyRaw ,
4- minifyCooked
4+ minifyCooked ,
5+ compressSymbols
56} from '../../src/minify'
67
78describe ( 'minify utils' , ( ) => {
@@ -27,7 +28,7 @@ describe('minify utils', () => {
2728 describe ( 'minify(Raw|Cooked)' , ( ) => {
2829 it ( 'Removes multi-line comments' , ( ) => {
2930 const input = 'this is a/* ignore me please */test'
30- const expected = 'this is atest ' // NOTE: They're replaced with newlines, and newlines are joined
31+ const expected = 'this is a test ' // NOTE: They're replaced with newlines, and newlines are joined
3132 const actual = minifyRaw ( input )
3233
3334 expect ( actual ) . toBe ( expected )
@@ -36,7 +37,7 @@ describe('minify utils', () => {
3637
3738 it ( 'Joins all lines of code' , ( ) => {
3839 const input = 'this\nis\na/* ignore me \n please */\ntest'
39- const expected = 'thisisatest '
40+ const expected = 'this is a test '
4041 const actual = minifyRaw ( input )
4142
4243 expect ( actual ) . toBe ( expected )
@@ -45,7 +46,7 @@ describe('minify utils', () => {
4546
4647 it ( 'Removes line comments filling an entire line' , ( ) => {
4748 const input = 'line one\n// remove this comment\nline two'
48- const expected = 'line oneline two'
49+ const expected = 'line one line two'
4950 const actual = minifyRaw ( input )
5051
5152 expect ( actual ) . toBe ( expected )
@@ -54,7 +55,7 @@ describe('minify utils', () => {
5455
5556 it ( 'Removes line comments at the end of lines of code' , ( ) => {
5657 const input = 'valid line with // a comment\nout comments'
57- const expected = 'valid line with out comments'
58+ const expected = 'valid line with out comments'
5859 const actual = minifyRaw ( input )
5960
6061 expect ( actual ) . toBe ( expected )
@@ -65,13 +66,29 @@ describe('minify utils', () => {
6566 describe ( 'minifyRaw' , ( ) => {
6667 it ( 'works with raw escape codes' , ( ) => {
6768 const input = 'this\\nis\\na/* ignore me \\n please */\\ntest'
68- const expected = 'thisisatest '
69+ const expected = 'this is a test '
6970 const actual = minifyRaw ( input )
7071
7172 expect ( minifyRaw ( input ) ) . toBe ( expected )
7273
7374 // NOTE: This is just a sanity check
74- expect ( minifyCooked ( input ) ) . toBe ( 'this\\nis\\na\\ntest' )
75+ expect ( minifyCooked ( input ) ) . toBe ( 'this\\nis\\na \\ntest' )
76+ } )
77+ } )
78+
79+ describe ( 'compressSymbols' , ( ) => {
80+ it ( 'removes spaces around symbols' , ( ) => {
81+ const input = '; : { } , ; '
82+ const expected = ';:{},;'
83+
84+ expect ( compressSymbols ( input ) ) . toBe ( expected )
85+ } )
86+
87+ it ( 'ignores symbols inside strings' , ( ) => {
88+ const input = '; " : " \' : \' ;'
89+ const expected = ';" : " \' : \';'
90+
91+ expect ( compressSymbols ( input ) ) . toBe ( expected )
7592 } )
7693 } )
7794} )
0 commit comments