-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a4884bb
commit 8cfab36
Showing
2 changed files
with
132 additions
and
30 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
95 changes: 95 additions & 0 deletions
95
super_editor_markdown/test/attributed_text_markdown_test.dart
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,95 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:super_editor/super_editor.dart'; | ||
import 'package:super_editor_markdown/src/markdown.dart'; | ||
|
||
void main() { | ||
group("AttributedText markdown serializes", () { | ||
test("un-styled text", () { | ||
expect( | ||
AttributedText(text: "This is unstyled text.").toMarkdown(), | ||
"This is unstyled text.", | ||
); | ||
}); | ||
|
||
test("single character styles", () { | ||
expect( | ||
AttributedText( | ||
text: "This is single character styles.", | ||
spans: AttributedSpans( | ||
attributions: [ | ||
SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.end), | ||
SpanMarker(attribution: italicsAttribution, offset: 23, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: italicsAttribution, offset: 23, markerType: SpanMarkerType.end), | ||
], | ||
), | ||
).toMarkdown(), | ||
"This is **s**ingle characte*r* styles.", | ||
); | ||
}); | ||
|
||
test("bold text", () { | ||
expect( | ||
AttributedText( | ||
text: "This is bold text.", | ||
spans: AttributedSpans( | ||
attributions: [ | ||
SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: boldAttribution, offset: 11, markerType: SpanMarkerType.end), | ||
], | ||
), | ||
).toMarkdown(), | ||
"This is **bold** text.", | ||
); | ||
}); | ||
|
||
test("italics text", () { | ||
expect( | ||
AttributedText( | ||
text: "This is italics text.", | ||
spans: AttributedSpans( | ||
attributions: [ | ||
SpanMarker(attribution: italicsAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: italicsAttribution, offset: 14, markerType: SpanMarkerType.end), | ||
], | ||
), | ||
).toMarkdown(), | ||
"This is *italics* text.", | ||
); | ||
}); | ||
|
||
test("multiple styles across the same span", () { | ||
expect( | ||
AttributedText( | ||
text: "This is multiple styled text.", | ||
spans: AttributedSpans( | ||
attributions: [ | ||
SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: boldAttribution, offset: 22, markerType: SpanMarkerType.end), | ||
SpanMarker(attribution: italicsAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: italicsAttribution, offset: 22, markerType: SpanMarkerType.end), | ||
], | ||
), | ||
).toMarkdown(), | ||
"This is ***multiple styled*** text.", | ||
); | ||
}); | ||
|
||
test("partially overlapping styles", () { | ||
expect( | ||
AttributedText( | ||
text: "This is overlapping styles.", | ||
spans: AttributedSpans( | ||
attributions: [ | ||
SpanMarker(attribution: boldAttribution, offset: 8, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: boldAttribution, offset: 13, markerType: SpanMarkerType.end), | ||
SpanMarker(attribution: italicsAttribution, offset: 11, markerType: SpanMarkerType.start), | ||
SpanMarker(attribution: italicsAttribution, offset: 18, markerType: SpanMarkerType.end), | ||
], | ||
), | ||
).toMarkdown(), | ||
"This is **ove*rla**pping* styles.", | ||
); | ||
}); | ||
}); | ||
} |