2016-04-22 02:22:33 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
|
|
|
import 'package:angel_mustache/angel_mustache.dart';
|
2017-11-18 18:39:10 +00:00
|
|
|
import 'package:file/local.dart';
|
2016-04-22 02:22:33 +00:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2016-05-02 23:28:37 +00:00
|
|
|
main() async {
|
2016-04-22 02:22:33 +00:00
|
|
|
Angel angel = new Angel();
|
2017-11-18 18:39:10 +00:00
|
|
|
await angel.configure(mustache(const LocalFileSystem().directory('./test')));
|
2016-04-22 02:22:33 +00:00
|
|
|
|
|
|
|
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', () {
|
2017-11-18 18:39:10 +00:00
|
|
|
expect(new Future(() async {
|
|
|
|
var fails = await angel.viewGenerator('fail', {'this_should': 'fail'});
|
|
|
|
print(fails);
|
|
|
|
}), throws);
|
2016-04-22 02:22:33 +00:00
|
|
|
});
|
2016-05-02 23:28:37 +00:00
|
|
|
|
|
|
|
test("partials", () async {
|
|
|
|
var withPartial = await angel.viewGenerator('with-partial');
|
|
|
|
expect(withPartial, equals("Hello, world!"));
|
|
|
|
});
|
2017-04-05 22:41:40 +00:00
|
|
|
}
|