-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patheditor_test.dart
56 lines (44 loc) · 1.85 KB
/
editor_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test/test.dart';
import 'package:yaml_edit/yaml_edit.dart';
void main() {
group('YamlEditor records edits', () {
test('returns empty list at start', () {
final yamlEditor = YamlEditor('YAML: YAML');
expect(yamlEditor.edits, []);
});
test('after one change', () {
final yamlEditor = YamlEditor('YAML: YAML');
yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
expect(
yamlEditor.edits, [SourceEdit(5, 5, " YAML Ain't Markup Language")]);
});
test('after multiple changes', () {
final yamlEditor = YamlEditor('YAML: YAML');
yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
yamlEditor.update(['XML'], 'Extensible Markup Language');
yamlEditor.remove(['YAML']);
expect(yamlEditor.edits, [
SourceEdit(5, 5, " YAML Ain't Markup Language"),
SourceEdit(0, 0, 'XML: Extensible Markup Language\n'),
SourceEdit(32, 32, '')
]);
});
test('that do not automatically update with internal list', () {
final yamlEditor = YamlEditor('YAML: YAML');
yamlEditor.update(['YAML'], "YAML Ain't Markup Language");
final firstEdits = yamlEditor.edits;
expect(firstEdits, [SourceEdit(5, 5, " YAML Ain't Markup Language")]);
yamlEditor.update(['XML'], 'Extensible Markup Language');
yamlEditor.remove(['YAML']);
expect(firstEdits, [SourceEdit(5, 5, " YAML Ain't Markup Language")]);
expect(yamlEditor.edits, [
SourceEdit(5, 5, " YAML Ain't Markup Language"),
SourceEdit(0, 0, 'XML: Extensible Markup Language\n'),
SourceEdit(32, 32, '')
]);
});
});
}