2016-12-10 18:51:02 +00:00
|
|
|
import 'package:angel/angel.dart';
|
2017-10-19 21:53:33 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
2016-12-10 18:51:02 +00:00
|
|
|
import 'package:angel_test/angel_test.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2017-06-10 15:24:36 +00:00
|
|
|
// Angel also includes facilities to make testing easier.
|
|
|
|
//
|
|
|
|
// `package:angel_test` ships a client that can test
|
|
|
|
// both plain HTTP and WebSockets.
|
|
|
|
//
|
|
|
|
// Tests do not require your server to actually be mounted on a port,
|
|
|
|
// so they will run faster than they would in other frameworks, where you
|
|
|
|
// would have to first bind a socket, and then account for network latency.
|
|
|
|
//
|
|
|
|
// See the documentation here:
|
|
|
|
// https://github.com/angel-dart/test
|
|
|
|
//
|
|
|
|
// If you are unfamiliar with Dart's advanced testing library, you can read up
|
|
|
|
// here:
|
|
|
|
// https://github.com/dart-lang/test
|
|
|
|
|
2021-03-07 12:52:36 +00:00
|
|
|
void main() async {
|
2016-12-10 18:51:02 +00:00
|
|
|
TestClient client;
|
|
|
|
|
|
|
|
setUp(() async {
|
2018-12-11 03:30:48 +00:00
|
|
|
var app = Angel();
|
2017-10-19 21:53:33 +00:00
|
|
|
await app.configure(configureServer);
|
|
|
|
|
2016-12-25 17:23:48 +00:00
|
|
|
client = await connectTo(app);
|
2016-12-10 18:51:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() async {
|
|
|
|
await client.close();
|
|
|
|
});
|
|
|
|
|
2017-10-19 21:53:33 +00:00
|
|
|
test('index returns 200', () async {
|
2017-06-10 15:24:36 +00:00
|
|
|
// Request a resource at the given path.
|
2017-10-19 21:53:33 +00:00
|
|
|
var response = await client.get('/');
|
2016-12-10 18:51:02 +00:00
|
|
|
|
2017-10-19 21:53:33 +00:00
|
|
|
// Expect a 200 response.
|
|
|
|
expect(response, hasStatus(200));
|
2016-12-10 18:51:02 +00:00
|
|
|
});
|
|
|
|
}
|