zefyr

heuristics_test.dart 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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:notus/notus.dart';
  5. import 'package:quill_delta/quill_delta.dart';
  6. import 'package:test/test.dart';
  7. NotusDocument dartconfDoc() {
  8. final delta = Delta()..insert('DartConf\nLos Angeles\n');
  9. return NotusDocument.fromDelta(delta);
  10. }
  11. final ul = NotusAttribute.ul.toJson();
  12. final h1 = NotusAttribute.h1.toJson();
  13. void main() {
  14. group('$NotusHeuristics', () {
  15. test('ensures heuristics are applied', () {
  16. final doc = dartconfDoc();
  17. final heuristics = NotusHeuristics(
  18. formatRules: [],
  19. insertRules: [],
  20. deleteRules: [],
  21. );
  22. expect(() {
  23. heuristics.applyInsertRules(doc, 0, 'a');
  24. }, throwsStateError);
  25. expect(() {
  26. heuristics.applyDeleteRules(doc, 0, 1);
  27. }, throwsStateError);
  28. expect(() {
  29. heuristics.applyFormatRules(doc, 0, 1, NotusAttribute.bold);
  30. }, throwsStateError);
  31. });
  32. });
  33. }