add tests
This commit is contained in:
@@ -9,6 +9,8 @@ void main() {
|
||||
expect(options.baseUrl, 'https://chat-us-east-1.stream-io-api.com');
|
||||
expect(options.connectTimeout, const Duration(seconds: 6));
|
||||
expect(options.receiveTimeout, const Duration(seconds: 6));
|
||||
expect(options.queryParams, const {});
|
||||
expect(options.headers, const {});
|
||||
});
|
||||
|
||||
test('should override all the default set params', () {
|
||||
@@ -16,11 +18,19 @@ void main() {
|
||||
baseUrl: 'base-url',
|
||||
connectTimeout: Duration(seconds: 3),
|
||||
receiveTimeout: Duration(seconds: 3),
|
||||
headers: {
|
||||
'test': 'test',
|
||||
},
|
||||
queryParams: {
|
||||
'123': '123',
|
||||
},
|
||||
);
|
||||
expect(options.location, isNull);
|
||||
expect(options.baseUrl, 'base-url');
|
||||
expect(options.connectTimeout, const Duration(seconds: 3));
|
||||
expect(options.receiveTimeout, const Duration(seconds: 3));
|
||||
expect(options.headers, {'test': 'test'});
|
||||
expect(options.queryParams, {'123': '123'});
|
||||
});
|
||||
|
||||
group('should create baseUrl according to provided location', () {
|
||||
|
||||
@@ -87,30 +87,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('loggingInterceptor should log requests', () async {
|
||||
const apiKey = 'api-key';
|
||||
final logger = MockLogger();
|
||||
final client = StreamHttpClient(apiKey, logger: logger);
|
||||
|
||||
try {
|
||||
await client.get('path');
|
||||
} catch (_) {}
|
||||
|
||||
verify(() => logger.info(any())).called(16);
|
||||
});
|
||||
|
||||
test('loggingInterceptor should log error', () async {
|
||||
const apiKey = 'api-key';
|
||||
final logger = MockLogger();
|
||||
final client = StreamHttpClient(apiKey, logger: logger);
|
||||
|
||||
try {
|
||||
await client.get('path');
|
||||
} catch (_) {}
|
||||
|
||||
verify(() => logger.severe(any())).called(8);
|
||||
});
|
||||
|
||||
test('`.lock` should lock the dio client', () async {
|
||||
final client = StreamHttpClient('api-key');
|
||||
expect(client.httpClient.interceptors.requestLock.locked, isFalse);
|
||||
|
||||
Reference in New Issue
Block a user