|
@@ -42,19 +42,22 @@ void main() {
|
|
final String response = await rootBundle.loadString('assets/document.json');
|
|
final String response = await rootBundle.loadString('assets/document.json');
|
|
final data = Map<String, Object>.from(json.decode(response));
|
|
final data = Map<String, Object>.from(json.decode(response));
|
|
final stateTree = StateTree.fromJson(data);
|
|
final stateTree = StateTree.fromJson(data);
|
|
- final deletedNode = stateTree.delete([1, 0]);
|
|
|
|
|
|
+ final deletedNode = stateTree.delete([1, 1]);
|
|
expect(deletedNode != null, true);
|
|
expect(deletedNode != null, true);
|
|
expect(deletedNode!.attributes['text-type'], 'check-box');
|
|
expect(deletedNode!.attributes['text-type'], 'check-box');
|
|
|
|
+ final node = stateTree.nodeAtPath([1, 1]);
|
|
|
|
+ expect(node != null, true);
|
|
|
|
+ expect(node!.attributes['tag'], '**');
|
|
});
|
|
});
|
|
|
|
|
|
test('update node in state tree', () async {
|
|
test('update node in state tree', () async {
|
|
final String response = await rootBundle.loadString('assets/document.json');
|
|
final String response = await rootBundle.loadString('assets/document.json');
|
|
final data = Map<String, Object>.from(json.decode(response));
|
|
final data = Map<String, Object>.from(json.decode(response));
|
|
final stateTree = StateTree.fromJson(data);
|
|
final stateTree = StateTree.fromJson(data);
|
|
- final attributes = stateTree.update([1, 0], {'text-type': 'heading1'});
|
|
|
|
|
|
+ final attributes = stateTree.update([1, 1], {'text-type': 'heading1'});
|
|
expect(attributes != null, true);
|
|
expect(attributes != null, true);
|
|
expect(attributes!['text-type'], 'check-box');
|
|
expect(attributes!['text-type'], 'check-box');
|
|
- final updatedNode = stateTree.nodeAtPath([1, 0]);
|
|
|
|
|
|
+ final updatedNode = stateTree.nodeAtPath([1, 1]);
|
|
expect(updatedNode != null, true);
|
|
expect(updatedNode != null, true);
|
|
expect(updatedNode!.attributes['text-type'], 'heading1');
|
|
expect(updatedNode!.attributes['text-type'], 'heading1');
|
|
});
|
|
});
|