-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #703
- Loading branch information
Showing
8 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import dedent from 'dedent-js'; | ||
|
||
import { FormatFn } from '../../src/sqlFormatter.js'; | ||
|
||
export default function supportsDisableComment(format: FormatFn) { | ||
it('does not format text between /* sql-formatter-disable */ and /* sql-formatter-enable */', () => { | ||
const result = format(dedent` | ||
SELECT foo FROM bar; | ||
/* sql-formatter-disable */ | ||
SELECT foo FROM bar; | ||
/* sql-formatter-enable */ | ||
SELECT foo FROM bar; | ||
`); | ||
|
||
expect(result).toBe(dedent` | ||
SELECT | ||
foo | ||
FROM | ||
bar; | ||
/* sql-formatter-disable */ | ||
SELECT foo FROM bar; | ||
/* sql-formatter-enable */ | ||
SELECT | ||
foo | ||
FROM | ||
bar; | ||
`); | ||
}); | ||
|
||
it('does not format text after /* sql-formatter-disable */ until end of file', () => { | ||
const result = format(dedent` | ||
SELECT foo FROM bar; | ||
/* sql-formatter-disable */ | ||
SELECT foo FROM bar; | ||
SELECT foo FROM bar; | ||
`); | ||
|
||
expect(result).toBe(dedent` | ||
SELECT | ||
foo | ||
FROM | ||
bar; | ||
/* sql-formatter-disable */ | ||
SELECT foo FROM bar; | ||
SELECT foo FROM bar; | ||
`); | ||
}); | ||
|
||
it('does not parse code between disable/enable comments', () => { | ||
const result = format(dedent` | ||
SELECT /*sql-formatter-disable*/ ?!{}[] /*sql-formatter-enable*/ FROM bar; | ||
`); | ||
|
||
expect(result).toBe(dedent` | ||
SELECT | ||
/*sql-formatter-disable*/ ?!{}[] /*sql-formatter-enable*/ | ||
FROM | ||
bar; | ||
`); | ||
}); | ||
} |