platform/test/browser_test.dart
2017-03-28 21:52:19 -04:00

35 lines
913 B
Dart

@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);
String url = await channel.stream.first;
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);
String url = await channel.stream.first;
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));
});
}