zefyr

util_test.dart 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file
  2. // for details. All rights reserved. Use of this source code is governed by a
  3. // BSD-style license that can be found in the LICENSE file.
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:quill_delta/quill_delta.dart';
  6. import 'package:zefyr/util.dart';
  7. void main() {
  8. group('getPositionDelta', () {
  9. test('actual has more characters inserted than user', () {
  10. final user = Delta()
  11. ..retain(7)
  12. ..insert('a');
  13. final actual = Delta()
  14. ..retain(7)
  15. ..insert('\na');
  16. final result = getPositionDelta(user, actual);
  17. expect(result, 1);
  18. });
  19. test('actual has less characters inserted than user', () {
  20. final user = Delta()
  21. ..retain(7)
  22. ..insert('abc');
  23. final actual = Delta()
  24. ..retain(7)
  25. ..insert('ab');
  26. final result = getPositionDelta(user, actual);
  27. expect(result, -1);
  28. });
  29. test('actual has less characters deleted than user', () {
  30. final user = Delta()
  31. ..retain(7)
  32. ..delete(3);
  33. final actual = Delta()
  34. ..retain(7)
  35. ..delete(2);
  36. final result = getPositionDelta(user, actual);
  37. expect(result, 1);
  38. });
  39. });
  40. }