blob: 7b82b512065bc0ffd0fe4794b281ea87d496b6c6 [file] [log] [blame]
import 'dart:html';
import 'package:mockito/mockito.dart';
/// A Mock implementation of the NetworkInformation API that allows
/// for external modification of its values.
class MockNetworkInformation extends Mock implements NetworkInformation {
/// The callback that will fire after the network information values change.
Function onchange;
/// Changes the desired values, and triggers the change event listener.
void mockChangeValue({
String type,
String effectiveType,
num downlink,
num rtt,
}) async {
when(this.type).thenAnswer((_) => type);
when(this.effectiveType).thenAnswer((_) => effectiveType);
when(this.downlink).thenAnswer((_) => downlink);
when(this.rtt).thenAnswer((_) => rtt);
onchange(Event('change'));
}
}