Rich text editor for Flutter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

56 lines
1.9 KiB

import 'package:flutter_quill/quill_delta.dart';
import 'package:flutter_quill/src/models/documents/delta_x.dart';
import 'package:test/test.dart';
void main() {
const htmlWithEmp =
'<p>This is a normal sentence, and this section has greater emp<em>hasis.</em></p>';
const htmlWithUnderline =
'<p>This is a normal sentence, and this section has greater <u>underline</u>';
const htmlWithIframeVideo =
'<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="YouTube video player"></iframe>';
const htmlWithVideoTag =
'''<video src="https://www.youtube.com/embed/dQw4w9WgXcQ">Your browser does not support the video tag.</video>
''';
final expectedDeltaEmp = Delta.fromOperations([
Operation.insert(
'This is a normal sentence, and this section has greater emp'),
Operation.insert('hasis.', {'italic': true}),
Operation.insert('\n'),
]);
final expectedDeltaUnderline = Delta.fromOperations([
Operation.insert(
'This is a normal sentence, and this section has greater '),
Operation.insert('underline', {'underline': true}),
Operation.insert('\n'),
]);
final expectedDeltaVideo = Delta.fromOperations([
Operation.insert({'video': 'https://www.youtube.com/embed/dQw4w9WgXcQ'}),
Operation.insert('\n'),
]);
test('should detect emphasis and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithEmp);
expect(delta, expectedDeltaEmp);
});
test('should detect underline and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithUnderline);
expect(delta, expectedDeltaUnderline);
});
test('should detect iframe and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithIframeVideo);
expect(delta, expectedDeltaVideo);
});
test('should detect video and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithVideoTag);
expect(delta, expectedDeltaVideo);
});
}