Skip to content

Commit 27ddffe

Browse files
committed
Fix Tests
• Fixes an issue with the tests. Apparently Flutter no longer bundles its test framework automatically and it must now be included as an explicit dependency.
1 parent cef7773 commit 27ddffe

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies:
1414
sdk: flutter
1515

1616
dev_dependencies:
17+
test: ^1.5.1
1718
flutter_test:
1819
sdk: flutter
1920

test/mock_channel.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ class OneSignalMockChannelController {
6464
case "OneSignal#deleteTags":
6565
this.state.deleteTags = call.arguments;
6666
return {"success": true};
67+
case "OneSignal#setExternalUserId":
68+
this.state.externalId = (call.arguments as Map<dynamic, dynamic>)['externalUserId'] as String;
69+
return {"success" : true};
70+
case "OneSignal#removeExternalUserId":
71+
this.state.externalId = null;
72+
return {"success" : true};
6773
}
6874
}
6975
}
@@ -90,6 +96,7 @@ class OneSignalState {
9096
bool locationShared;
9197
OSNotificationDisplayType inFocusDisplayType;
9298
bool subscriptionState;
99+
String externalId;
93100

94101
// tags
95102
Map<dynamic, dynamic> tags;

test/onesignal_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,16 @@ void main() {
111111
expect(channelController.state.deleteTags, ['test1']);
112112
}));
113113
});
114+
115+
test('setting external user ID', () {
116+
onesignal.setExternalUserId('test_ext_id').then(expectAsync1((v) {
117+
expect(channelController.state.externalId, 'test_ext_id');
118+
}));
119+
});
120+
121+
test('removing external user ID', () {
122+
onesignal.removeExternalUserId().then(expectAsync1((v) {
123+
expect(channelController.state.externalId, null);
124+
}));
125+
});
114126
}

0 commit comments

Comments
 (0)