-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be591ac
commit 242390d
Showing
4 changed files
with
206 additions
and
24 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
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,35 @@ | ||
import 'package:flat/src/flatten.dart'; | ||
import 'package:flat/src/unflatten.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('flatten and unflatten', () { | ||
test( | ||
'Order of keys should not be changed after round trip flatten/unflatten', | ||
() { | ||
const obj = { | ||
'b': 1, | ||
'abc': { | ||
'c': [ | ||
{ | ||
'd': 1, | ||
'bca': 1, | ||
'a': 1, | ||
}, | ||
], | ||
}, | ||
'a': 1, | ||
}; | ||
|
||
final result = unflatten(flatten(obj)); | ||
|
||
expect(obj.keys, result.keys); | ||
expect((obj['abc']! as Map).keys, (result['abc']! as Map).keys); | ||
expect( | ||
// ignore: avoid_dynamic_calls | ||
(obj['abc']! as Map)['c'][0].keys, | ||
(result['abc']! as Map).keys, | ||
); | ||
}); | ||
}); | ||
} |
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