platform/test/browser_test.dart

36 lines
913 B
Dart
Raw Normal View History

2017-01-20 23:57:42 +00:00
@TestOn('browser')
import 'package:angel_client/browser.dart';
import 'package:test/test.dart';
import 'for_browser_tests.dart';
main() {
test("list todos", () async {
var channel = spawnHybridCode(SERVER);
2017-03-29 01:52:19 +00:00
String url = await channel.stream.first;
2017-01-20 23:57:42 +00:00
print(url);
var app = new Rest(url);
var todoService = app.service("todos");
var todos = await todoService.index();
expect(todos, isEmpty);
});
test('create todos', () async {
var channel = spawnHybridCode(SERVER);
2017-03-29 01:52:19 +00:00
String url = await channel.stream.first;
2017-01-20 23:57:42 +00:00
print(url);
var app = new Rest(url);
var todoService = app.service("todos");
var data = {'hello': 'world'};
var response = await todoService.create(data);
print('Created response: $response');
var todos = await todoService.index();
expect(todos, hasLength(1));
Map todo = todos.first;
expect(todo, equals(data));
});
}