Skip to content

Commit 52bd1b5

Browse files
committed
test: update test with matcher
1 parent cbb1cc8 commit 52bd1b5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dev_dependencies:
3131
sdk: flutter
3232
flutter_lints: ^3.0.0
3333
test: ^1.25.2
34+
matcher: ^0.12.17
3435

3536
# For information on the generic Dart part of this file, see the
3637
# following page: https://dart.dev/tools/pub/pubspec

test/web_callkit_method_channel_test.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:web_callkit/src/core/enums/ck_call_state.dart';
55
import 'package:web_callkit/src/core/enums/ck_call_type.dart';
66
import 'package:web_callkit/src/method_channel/web_callkit_method_channel.dart';
77
import 'package:web_callkit/src/models/call/ck_call.dart';
8+
import 'package:matcher/matcher.dart' as matcher;
89

910
void main() {
1011
TestWidgetsFlutterBinding.ensureInitialized();
@@ -34,11 +35,11 @@ void main() {
3435
final call = CKCall.init(uuid: id, localizedName: name);
3536
expect(call.uuid, id, reason: 'Call uuid should be $id');
3637
expect(call.localizedName, name, reason: 'Call name should be $name');
37-
expect(call.dateStarted, isNotNull,
38+
expect(call.dateStarted, matcher.isNotNull,
3839
reason: 'Call dateStarted should not be null');
39-
expect(call.dateUpdated, isNotNull,
40+
expect(call.dateUpdated, matcher.isNotNull,
4041
reason: 'Call dateUpdated should not be null');
41-
expect(call.attributes, isNotNull,
42+
expect(call.attributes, matcher.isNotNull,
4243
reason: 'Call attributes should not be null');
4344
expect(call.callType, CKCallType.audio,
4445
reason: 'Call callType should be audio');
@@ -71,7 +72,7 @@ void main() {
7172
final dateStarted = call.dateStarted;
7273
final copyWith = call.copyWith(dateStarted: DateTime.now());
7374
final newDateStarted = copyWith.dateStarted;
74-
expect(dateStarted, isNot(newDateStarted),
75+
expect(dateStarted, matcher.isNot(newDateStarted),
7576
reason: 'Call dateStarted should not be equal to new dateStarted');
7677
});
7778

@@ -151,7 +152,7 @@ void main() {
151152
await platform
152153
.updateCallAttributes('123', attributes: {CKCallAttributes.hold});
153154
final call = platform.getCall('123');
154-
expect(call, isNull, reason: 'Call should be null');
155+
expect(call, matcher.isNull, reason: 'Call should be null');
155156
});
156157

157158
test('updateCallAttributes: perform hold toggle', () async {
@@ -166,7 +167,7 @@ void main() {
166167
await platform.updateCallAttributes(id, attributes: {});
167168
final notholding = platform.getCall(id);
168169

169-
expect(call, isNotNull, reason: 'Call should not be null');
170+
expect(call, matcher.isNotNull, reason: 'Call should not be null');
170171
expect(call!.isHolding, false, reason: 'Call should not be holding');
171172
expect(holding!.isHolding, true, reason: 'Call should be holding');
172173
expect(notholding!.isHolding, true,
@@ -180,7 +181,7 @@ void main() {
180181
test('updateCallStatus: does not exist', () async {
181182
await platform.updateCallStatus('123', callStatus: CKCallState.active);
182183
final call = platform.getCall('123');
183-
expect(call, isNull, reason: 'Call should be null');
184+
expect(call, matcher.isNull, reason: 'Call should be null');
184185
});
185186

186187
test('updateCallStatus: ringing to active to ended', () async {
@@ -194,16 +195,16 @@ void main() {
194195
await platform.updateCallStatus(id, callStatus: CKCallState.disconnected);
195196
final disconnected = platform.getCall(id);
196197

197-
expect(call, isNotNull, reason: 'Call should not be null');
198+
expect(call, matcher.isNotNull, reason: 'Call should not be null');
198199
expect(call!.uuid, '123', reason: 'Call uuid should be "123"');
199200
expect(call.localizedName, "handle",
200201
reason: 'Call handle should be "handle"');
201202

202-
expect(active, isNotNull, reason: 'Call active should not be null');
203+
expect(active, matcher.isNotNull, reason: 'Call active should not be null');
203204
expect(active!.state, CKCallState.active,
204205
reason: 'Call state should be active');
205206

206-
expect(disconnected, isNotNull,
207+
expect(disconnected, matcher.isNotNull,
207208
reason: 'Call disconnected should not be null');
208209
expect(disconnected!.state, CKCallState.disconnected,
209210
reason: 'Call state should be disconnected');

0 commit comments

Comments
 (0)