import 'package:angel_framework/angel_framework.dart';
import 'package:angel_seo/angel_seo.dart';
import 'package:angel_static/angel_static.dart';
import 'package:angel_test/angel_test.dart';
import 'package:dart2_constant/convert.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:html/dom.dart' as html;
import 'package:html/parser.dart' as html;
import 'package:test/test.dart';
void main() {
group('inlineAssets', () {
group('buffer', inlineAssetsTests((app, dir) {
app.get('/', (ResponseContext res) async {
var indexHtml = dir.childFile('index.html');
var contents = await indexHtml.readAsString();
res
..headers['content-type'] = 'text/html; charset=utf-8'
..buffer.add(utf8.encode(contents));
});
app.responseFinalizers.add(inlineAssets(dir));
}));
group('virtual_directory', inlineAssetsTests((app, dir) {
var vDir = inlineAssetsFromVirtualDirectory(
new VirtualDirectory(app, dir.fileSystem, source: dir));
app.use(vDir.handleRequest);
}));
});
}
void Function() inlineAssetsTests(void Function(Angel, Directory) f) {
return () {
TestClient client;
setUp(() async {
var app = new Angel();
var fs = new MemoryFileSystem();
var dir = fs.currentDirectory;
f(app, dir);
client = await connectTo(app);
for (var path in contents.keys) {
var file = fs.file(path);
await file.writeAsString(contents[path].trim());
}
});
tearDown(() => client.close());
group('sends html', () {
html.Document doc;
setUp(() async {
var res = await client.get('/', headers: {'accept': 'text/html'});
doc = html.parse(res.body);
});
group('stylesheets', () {
test('replaces with