Skip to content

Commit

Permalink
Add keep + chomping indicator tests
Browse files Browse the repository at this point in the history
> Add a string test case in `string_tests.dart`
  • Loading branch information
kekavc24 committed Jun 10, 2024
1 parent e047567 commit d94ba04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions test/string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final _testStrings = [
'whitespace and line breaks at end 2 \n \n',
'whitespace and line breaks at end 3 \n\n',
'whitespace and line breaks at end 3 \n\n ',
'\n line break at the start',
'word',
'foo bar',
'foo\nbar',
Expand Down
28 changes: 25 additions & 3 deletions test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void main() {
final doc = YamlEditor('''
- 1
- 2
-
-
- 3
- 4''');
expect(getIndentation(doc), equals(3));
Expand All @@ -53,7 +53,7 @@ c:
final doc = YamlEditor('''
- 1
- 2
-
-
d: 4
e: 5''');
expect(getIndentation(doc), equals(4));
Expand All @@ -64,7 +64,7 @@ c:
final doc = YamlEditor('''
- 1
- 2
-
-
? d
: 4''');
expect(getIndentation(doc), equals(4));
Expand Down Expand Up @@ -318,13 +318,35 @@ strings:
test'''));
});

test('generates folded strings with trailing line break and space', () {
final doc = YamlEditor('');

doc.update(
[],
wrapAsYamlNode('test\ntest\n ', scalarStyle: ScalarStyle.FOLDED),
);

expect(doc.toString(), equals('>+\n test\n\n test\n '));
});

test('generates literal strings properly', () {
final doc = YamlEditor('');
doc.update(
[], wrapAsYamlNode('test\ntest', scalarStyle: ScalarStyle.LITERAL));
expect(doc.toString(), equals('|-\n test\n test'));
});

test('generates literal string with trailing line break and space', () {
final doc = YamlEditor('');

doc.update(
[],
wrapAsYamlNode('test\ntest\n ', scalarStyle: ScalarStyle.LITERAL),
);

expect(doc.toString(), equals('|+\n test\n test\n '));
});

test('rewrites literal strings properly', () {
final doc = YamlEditor('''
- |
Expand Down

0 comments on commit d94ba04

Please sign in to comment.