platform/packages/mustache/test/all_test.dart
2021-06-26 18:24:52 +08:00

31 lines
1,023 B
Dart

import 'dart:async';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_mustache/angel3_mustache.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:test/test.dart';
void main() async {
var angel = Angel();
await angel.configure(mustache(const LocalFileSystem().directory('./test')));
test('can render templates', () async {
var hello = await angel.viewGenerator!('hello', {'name': 'world'});
var bar = await angel.viewGenerator!('foo/bar', {'framework': 'angel'});
expect(hello, equals('Hello, world!'));
expect(bar, equals('angel_framework'));
});
test('throws if view is not found', () {
expect(Future(() async {
var fails = await angel.viewGenerator!('fail', {'this_should': 'fail'});
print(fails);
}), throwsA(isA<FileSystemException>()));
});
test('partials', () async {
var withPartial = await angel.viewGenerator!('with-partial');
expect(withPartial, equals('Hello, world!'));
});
}