-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build): dedent of a single-line region (#1687)
Co-authored-by: Divyansh Singh <[email protected]>
- Loading branch information
Showing
3 changed files
with
72 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { dedent } from 'node/markdown/plugins/snippet' | ||
|
||
describe('node/markdown/plugins/snippet', () => { | ||
describe('dedent', () => { | ||
test('when 0-level is minimal, do not remove spaces', () => { | ||
expect( | ||
dedent( | ||
[ | ||
// | ||
'fn main() {', | ||
' println!("Hello");', | ||
'}' | ||
].join('\n') | ||
) | ||
).toMatchInlineSnapshot(` | ||
"fn main() { | ||
println!(\\"Hello\\"); | ||
}" | ||
`) | ||
}) | ||
|
||
test('when 4-level is minimal, remove 4 spaces', () => { | ||
expect( | ||
dedent( | ||
[ | ||
// | ||
' let a = {', | ||
' value: 42', | ||
' };' | ||
].join('\n') | ||
) | ||
).toMatchInlineSnapshot(` | ||
"let a = { | ||
value: 42 | ||
};" | ||
`) | ||
}) | ||
|
||
test('when only 1 line is passed, dedent it', () => { | ||
expect(dedent(' let a = 42;')).toEqual('let a = 42;') | ||
}) | ||
|
||
test('handle tabs as well', () => { | ||
expect( | ||
dedent( | ||
[ | ||
// | ||
' let a = {', | ||
' value: 42', | ||
' };' | ||
].join('\n') | ||
) | ||
).toMatchInlineSnapshot(` | ||
"let a = { | ||
value: 42 | ||
};" | ||
`) | ||
}) | ||
}) | ||
}) |
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