24 lines
817 B
Dart
24 lines
817 B
Dart
import 'package:http/http.dart' as http;
|
|
import 'package:test/test.dart';
|
|
|
|
import 'helpers/fixture_loader.dart';
|
|
import 'helpers/mock_http_client.dart';
|
|
|
|
void main() {
|
|
test('test harness layout loads fixtures and the mock http client', () async {
|
|
final FixtureLoader fixtures = FixtureLoader();
|
|
final Map<String, dynamic> trade =
|
|
await fixtures.loadJson('alpaca_latest_trade.json');
|
|
expect(trade['symbol'], 'SPY');
|
|
expect(trade['trade'], isA<Map<String, dynamic>>());
|
|
|
|
final MockHttpClient client = MockHttpClient()
|
|
..whenGetJson('/trades/latest', trade);
|
|
final http.Response response = await client.get(
|
|
Uri.parse('https://data.alpaca.markets/v2/stocks/SPY/trades/latest'),
|
|
);
|
|
expect(response.statusCode, 200);
|
|
expect(client.requests, hasLength(1));
|
|
});
|
|
}
|