Skip to content

Commit bb61c07

Browse files
committed
improving tests
1 parent cbad7e0 commit bb61c07

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/parser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ function minify(sql, options) {
102102
continue;
103103
}
104104

105-
if (s === '\'') {
105+
if (s === `'`) {
106106
closeIdx = idx;
107107
do {
108-
closeIdx = sql.indexOf('\'', closeIdx + 1);
108+
closeIdx = sql.indexOf(`'`, closeIdx + 1);
109109
if (closeIdx > 0) {
110110
let i = closeIdx;
111111
while (sql[--i] === '\\') ;
112112
if ((closeIdx - i) % 2) {
113113
let step = closeIdx;
114-
while (++step < len && sql[step] === '\'') ;
114+
while (++step < len && sql[step] === `'`) ;
115115
if ((step - closeIdx) % 2) {
116116
closeIdx = step - 1;
117117
break;

test/mainSpec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const minify = require('../lib');
55
const {parsingErrorCode} = require('../lib/error');
66
const PEC = parsingErrorCode;
77

8-
98
describe('Minify/Positive', () => {
109

1110
describe('end-of-line detection', () => {
@@ -279,7 +278,14 @@ describe('Minify/Negative', () => {
279278
err = e.toString();
280279
}
281280
it('must contain error', () => {
282-
expect(err).toBe(`SQLParsingError {${EOL}${gap}code: parsingErrorCode.unclosedText${EOL}${gap}error: "Unclosed text block."${EOL}${gap}position: {line: 1, col: 1}${EOL}}`);
281+
const txt = [
282+
`SQLParsingError {`,
283+
`${gap}code: parsingErrorCode.unclosedText`,
284+
`${gap}error: "Unclosed text block."`,
285+
`${gap}position: {line: 1, col: 1}`,
286+
`}`
287+
];
288+
expect(err).toBe(txt.join(EOL));
283289
});
284290
});
285291

0 commit comments

Comments
 (0)