Add Canvas nullcheck to render function

This commit is contained in:
Marty Oehme 2018-08-25 14:10:56 +02:00
parent 572406b963
commit 4c6dff35c3
3 changed files with 19 additions and 9 deletions

View file

@ -1,12 +1,22 @@
@TestOn('browser')
import 'dart:html';
import 'package:rules_of_living/src/Engine.dart';
import 'package:test/test.dart';
void main() {
test("Engine can be instantiated without canvas", () {
expect(Engine(), isNot(throwsA(anything)));
expect(Engine(), isNot(throwsNoSuchMethodError));
});
test("Engine does not throw errors when calling render directly", () {
Engine sut = new Engine();
// anonymous function necessary since throws can not use functions with args
expect(() => sut.render(), isNot(throwsNoSuchMethodError));
});
test("Engine does not throw errors when processing without attached canvas", () {
Engine sut = new Engine();
// anonymous function necessary since throws can not use functions with args
expect(() => sut.process(1000), isNot(throwsNoSuchMethodError));
});
}