mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test: add delete node test
This commit is contained in:
parent
d2e62f882b
commit
9e4227d3d2
@ -14,6 +14,13 @@
|
|||||||
"tag": "*"
|
"tag": "*"
|
||||||
},
|
},
|
||||||
"children": [
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"attributes": {
|
||||||
|
"text-type": "heading2",
|
||||||
|
"check": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
|
@ -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');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user