2016-04-22 02:22:33 +00:00
|
|
|
import 'dart:async';
|
2024-10-13 01:45:27 +00:00
|
|
|
import 'package:protevus_framework/protevus_framework.dart';
|
|
|
|
import 'package:protevus_mustache/protevus_mustache.dart';
|
2021-06-20 12:37:20 +00:00
|
|
|
import 'package:file/file.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';
|
|
|
|
|
2021-06-20 12:37:20 +00:00
|
|
|
void main() async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var protevus = Protevus();
|
|
|
|
await protevus
|
|
|
|
.configure(mustache(const LocalFileSystem().directory('./test')));
|
2016-04-22 02:22:33 +00:00
|
|
|
|
|
|
|
test('can render templates', () async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var hello = await protevus.viewGenerator!('hello', {'name': 'world'});
|
|
|
|
var bar =
|
|
|
|
await protevus.viewGenerator!('foo/bar', {'framework': 'protevus'});
|
2016-04-22 02:22:33 +00:00
|
|
|
|
2021-06-20 12:37:20 +00:00
|
|
|
expect(hello, equals('Hello, world!'));
|
|
|
|
expect(bar, equals('angel_framework'));
|
2016-04-22 02:22:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('throws if view is not found', () {
|
2021-06-20 12:37:20 +00:00
|
|
|
expect(Future(() async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var fails =
|
|
|
|
await protevus.viewGenerator!('fail', {'this_should': 'fail'});
|
2017-11-18 18:39:10 +00:00
|
|
|
print(fails);
|
2021-06-20 12:37:20 +00:00
|
|
|
}), throwsA(isA<FileSystemException>()));
|
2016-04-22 02:22:33 +00:00
|
|
|
});
|
2016-05-02 23:28:37 +00:00
|
|
|
|
2021-06-20 12:37:20 +00:00
|
|
|
test('partials', () async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var withPartial = await protevus.viewGenerator!('with-partial');
|
2021-06-20 12:37:20 +00:00
|
|
|
expect(withPartial, equals('Hello, world!'));
|
2016-05-02 23:28:37 +00:00
|
|
|
});
|
2017-04-05 22:41:40 +00:00
|
|
|
}
|