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.

48 lines
1.6 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 htmlWithVideo =
'<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="YouTube video player"></iframe>';
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 video and parse correctly', () {
final delta = DeltaX.fromHtml(htmlWithVideo);
expect(delta, expectedDeltaVideo);
});
}