@@ -26,40 +26,36 @@ void main() {
2626 expect (result, expected);
2727 });
2828
29- test ('decode italic with container attribute' , () {
30- final i = NotusAttribute .italic.toJson ();
31- final ic = Map <String , dynamic >.from (i);
32- ic.addAll (NotusAttribute .container.withValue ({
33- "i" : {"foo" : "bar" }
34- }).toJson ());
35- final delta = Delta ()..insert ('txt' , ic)..insert ('\n ' );
36- final html = '<i foo="bar">txt</i>\n ' ;
29+ test ('decode italic attribute' , () {
30+ final i = NotusAttribute .italic.key;
31+ final attributes = {i: true };
32+ final delta = Delta ()..insert ('txt' , attributes)..insert ('\n ' );
33+ final html = '<i>txt</i>\n ' ;
3734 final result = notusHTML.decode (html);
3835 expect (result.toString (), delta.toString ());
3936 });
40- test ('decode bold with container attribute' , () {
41- final b = NotusAttribute .bold.toJson ();
42- final bc = Map <String , dynamic >.from (b);
43- bc.addAll (NotusAttribute .container.withValue ({
44- "b" : {"foo" : "bar" }
45- }).toJson ());
46- final delta = Delta ()..insert ('txt' , bc)..insert ('\n ' );
47- final html = '<b foo="bar">txt</b>\n ' ;
48- final result = notusHTML.decode (html);
49- expect (result.toString (), delta.toString ());
50- });
51- test ('decode multiple container attribute' , () {
52- final b = NotusAttribute .bold.toJson ();
53- final bc = Map <String , dynamic >.from (b);
54- bc.addAll (NotusAttribute .container.withValue ({
55- "b" : {"foo" : "bar" , "hidden" : null }
56- }).toJson ());
57- final delta = Delta ()..insert ('txt' , bc)..insert ('\n ' );
58- final html = '<b foo="bar" hidden>txt</b>\n ' ;
37+
38+ test ('decode bold attribute' , () {
39+ final b = NotusAttribute .bold.key;
40+ final attributes = {b: true };
41+ final delta = Delta ()..insert ('txt' , attributes)..insert ('\n ' );
42+ final html = '<b>txt</b>\n ' ;
5943 final result = notusHTML.decode (html);
6044 expect (result.toString (), delta.toString ());
6145 });
6246
47+ // test('decode multiple container attribute', () {
48+ // final b = NotusAttribute.bold.toJson();
49+ // final bc = Map<String, dynamic>.from(b);
50+ // bc.addAll(NotusAttribute.container.withValue({
51+ // "b": {"foo": "bar", "hidden": null}
52+ // }).toJson());
53+ // final delta = Delta()..insert('txt', bc)..insert('\n');
54+ // final html = '<b foo="bar" hidden>txt</b>\n';
55+ // final result = notusHTML.decode(html);
56+ // expect(result.toString(), delta.toString());
57+ // });
58+
6359 test ('empty text' , () {
6460 final delta = Delta ()..insert ('\n ' );
6561 final html = "" ;
@@ -188,9 +184,6 @@ void main() {
188184 test ('decode heading styles with container attribute' , () {
189185 runFor (NotusAttribute <int > attribute, String source, String html) {
190186 final attr = attribute.toJson ();
191- attr.addAll (NotusAttribute .container.withValue ({
192- "heading" : {"foo" : "bar" }
193- }).toJson ());
194187 final delta = new Delta ()..insert (source)..insert ('\n ' , attr);
195188 final result = notusHTML.decode (html);
196189 expect (result.toString (), delta.toString ());
@@ -203,25 +196,18 @@ void main() {
203196
204197 test ('decode singe block with container: quote' , () {
205198 runFor (NotusAttribute <String > attribute, String source, String html) {
206- var attr = attribute.toJson ();
207- attr.addAll (NotusAttribute .container.withValue ({
208- "block" : {"foo" : "bar" }
209- }).toJson ());
210- final delta = Delta ()..insert (source)..insert ('\n ' , attr);
199+ final delta = Delta ()..insert (source)..insert ('\n ' , attribute.toJson ());
211200 final result = notusHTML.decode (html);
212201 expect (result.toString (), delta.toString ());
213202 }
214203
215204 runFor (NotusAttribute .bq, 'item' ,
216205 '<blockquote foo="bar">\n item\n </blockquote>\n ' );
217206 });
207+
218208 test ('decode singe block with container: list' , () {
219209 runFor (NotusAttribute <String > attribute, String source, String html) {
220- var attr = NotusAttribute .container.withValue ({
221- "block" : {"foo" : "bar" }
222- }).toJson ();
223- attr.addAll (attribute.toJson ());
224- final delta = Delta ()..insert (source)..insert ('\n ' , attr);
210+ final delta = Delta ()..insert (source)..insert ('\n ' , attribute.toJson ());
225211 final result = notusHTML.decode (html);
226212 expect (result.toString (), delta.toString ());
227213 }
@@ -344,9 +330,6 @@ void main() {
344330 "insert" : String .fromCharCode (8203 ),
345331 "attributes" : {
346332 "embed" : {"type" : "hr" },
347- "container" : {
348- "embed" : {"foo" : "bar" }
349- }
350333 },
351334 },
352335 ])
@@ -366,40 +349,36 @@ void main() {
366349 expect (result, 'First line\n Second line\n ' );
367350 });
368351
369- test ('encode italic with container attribute' , () {
352+ test ('encode italic attribute' , () {
370353 final i = NotusAttribute .italic.toJson ();
371354 final ic = Map <String , dynamic >.from (i);
372- ic.addAll (NotusAttribute .container.withValue ({
373- "i" : {"foo" : "bar" }
374- }).toJson ());
375355 final delta = Delta ()..insert ('txt' , ic)..insert ('\n ' );
376- final expected = '<i foo="bar">txt</i>\n ' ;
377- final result = notusHTML.encode (delta);
378- expect (result.toString (), expected.toString ());
379- });
380- test ('encode bold with container attribute' , () {
381- final b = NotusAttribute .bold.toJson ();
382- final bc = Map <String , dynamic >.from (b);
383- bc.addAll (NotusAttribute .container.withValue ({
384- "b" : {"foo" : "bar" }
385- }).toJson ());
386- final delta = Delta ()..insert ('txt' , bc)..insert ('\n ' );
387- final expected = '<b foo="bar">txt</b>\n ' ;
356+ final expected = '<i>txt</i>\n ' ;
388357 final result = notusHTML.encode (delta);
389358 expect (result.toString (), expected.toString ());
390359 });
391- test ('encode bold with multiple container attribute' , () {
360+
361+ test ('encode bold attribute' , () {
392362 final b = NotusAttribute .bold.toJson ();
393363 final bc = Map <String , dynamic >.from (b);
394- bc.addAll (NotusAttribute .container.withValue ({
395- "b" : {"foo" : "bar" , "hidden" : null }
396- }).toJson ());
397364 final delta = Delta ()..insert ('txt' , bc)..insert ('\n ' );
398- final expected = '<b foo="bar" hidden >txt</b>\n ' ;
365+ final expected = '<b>txt</b>\n ' ;
399366 final result = notusHTML.encode (delta);
400367 expect (result.toString (), expected.toString ());
401368 });
402369
370+ // test('encode bold with multiple container attribute', () {
371+ // final b = NotusAttribute.bold.toJson();
372+ // final bc = Map<String, dynamic>.from(b);
373+ // bc.addAll(NotusAttribute.container.withValue({
374+ // "b": {"foo": "bar", "hidden": null}
375+ // }).toJson());
376+ // final delta = Delta()..insert('txt', bc)..insert('\n');
377+ // final expected = '<b foo="bar" hidden>txt</b>\n';
378+ // final result = notusHTML.encode(delta);
379+ // expect(result.toString(), expected.toString());
380+ // });
381+
403382 test ('encode bold italic' , () {
404383 runFor (NotusAttribute <bool > attribute, String expected) {
405384 final delta = new Delta ()
@@ -540,39 +519,30 @@ void main() {
540519 runFor (NotusAttribute .h2, 'Title' , '<h2>Title</h2>\n ' );
541520 runFor (NotusAttribute .h3, 'Title' , '<h3>Title</h3>\n ' );
542521 });
543- test ('encode heading styles with container attribute ' , () {
522+ test ('encode heading styles' , () {
544523 runFor (NotusAttribute <int > attribute, String source, String expected) {
545524 final attr = attribute.toJson ();
546- attr.addAll (NotusAttribute .container.withValue ({
547- "heading" : {"foo" : "bar" }
548- }).toJson ());
549525 final delta = new Delta ()..insert (source)..insert ('\n ' , attr);
550526 final result = notusHTML.encode (delta);
551527 expect (result, expected);
552528 }
553529
554- runFor (NotusAttribute .h1, 'Title' , '<h1 foo="bar" >Title</h1>\n ' );
555- runFor (NotusAttribute .h2, 'Title' , '<h2 foo="bar" >Title</h2>\n ' );
556- runFor (NotusAttribute .h3, 'Title' , '<h3 foo="bar" >Title</h3>\n ' );
530+ runFor (NotusAttribute .h1, 'Title' , '<h1>Title</h1>\n ' );
531+ runFor (NotusAttribute .h2, 'Title' , '<h2>Title</h2>\n ' );
532+ runFor (NotusAttribute .h3, 'Title' , '<h3>Title</h3>\n ' );
557533 });
558534
559- test ('encode singe block with container ' , () {
535+ test ('encode singe block' , () {
560536 runFor (NotusAttribute <String > attribute, String source, String expected) {
561537 var attr = attribute.toJson ();
562- attr.addAll (NotusAttribute .container.withValue ({
563- "block" : {"foo" : "bar" }
564- }).toJson ());
565538 final delta = Delta ()..insert (source)..insert ('\n ' , attr);
566539 final result = notusHTML.encode (delta);
567540 expect (result, expected);
568541 }
569542
570- runFor (
571- NotusAttribute .ul, 'item' , '<ul foo="bar">\n <li>item</li>\n </ul>\n ' );
572- runFor (
573- NotusAttribute .ol, 'item' , '<ol foo="bar">\n <li>item</li>\n </ol>\n ' );
574- runFor (NotusAttribute .bq, 'item' ,
575- '<blockquote foo="bar">item</blockquote>\n ' );
543+ runFor (NotusAttribute .ul, 'item' , '<ul>\n <li>item</li>\n </ul>\n ' );
544+ runFor (NotusAttribute .ol, 'item' , '<ol>\n <li>item</li>\n </ol>\n ' );
545+ runFor (NotusAttribute .bq, 'item' , '<blockquote>item</blockquote>\n ' );
576546 });
577547
578548 test ('encode block styles: ol, ul' , () {
@@ -641,16 +611,13 @@ void main() {
641611
642612 runFor ('<hr />\n ' );
643613 });
644- test ('encode hr with container attribute' , () {
614+ test ('encode hr attribute' , () {
645615 runFor (String expected) {
646616 final delta = Delta .fromJson ([
647617 {
648618 "insert" : "" ,
649619 "attributes" : {
650620 "embed" : {"type" : "hr" },
651- "container" : {
652- "embed" : {"foo" : "bar" }
653- }
654621 },
655622 },
656623 ])
@@ -659,7 +626,7 @@ void main() {
659626 expect (result, expected);
660627 }
661628
662- runFor ('<hr foo="bar" />\n ' );
629+ runFor ('<hr />\n ' );
663630 });
664631 test ('encode multiline blocks' , () {
665632 runFor (NotusAttribute <String > attribute, String source, String expected) {
@@ -678,8 +645,6 @@ void main() {
678645 '<ol>\n <li>text</li>\n <li>text</li>\n </ol>\n ' );
679646 runFor (
680647 NotusAttribute .bq, 'text' , '<blockquote>text\n text</blockquote>\n ' );
681-
682- // runFor(NotusAttribute.code, 'text', '```\ntext\ntext\n```\n\n');
683648 });
684649
685650 test ('encode multiple styles' , () {
0 commit comments