platform/packages/html_builder/test/render_test.dart

35 lines
847 B
Dart
Raw Normal View History

2021-05-01 02:48:36 +00:00
import 'package:html/parser.dart' as html5;
2021-05-15 11:47:48 +00:00
import 'package:angel3_html_builder/elements.dart';
import 'package:angel3_html_builder/angel3_html_builder.dart';
2021-05-01 02:48:36 +00:00
import 'package:test/test.dart';
2021-05-15 11:47:48 +00:00
void main() {
2021-05-01 02:48:36 +00:00
test('pretty', () {
var $dom = html(
lang: 'en',
c: [
head(c: [
title(c: [text('Hello, world!')])
]),
body(
p: {'unresolved': true},
c: [
h1(c: [text('Hello, world!')]),
br(),
hr(),
],
)
],
);
var rendered = StringRenderer().render($dom);
print(rendered);
var $parsed = html5.parse(rendered);
var $title = $parsed.querySelector('title')!;
expect($title.text.trim(), 'Hello, world!');
var $h1 = $parsed.querySelector('h1')!;
expect($h1.text.trim(), 'Hello, world!');
});
}