Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
• 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.
  • Loading branch information
Nightsd01 committed Dec 7, 2018
1 parent cef7773 commit 27ddffe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions pubspec.yaml
Expand Up @@ -14,6 +14,7 @@ dependencies:
sdk: flutter

dev_dependencies:
test: ^1.5.1
flutter_test:
sdk: flutter

Expand Down
7 changes: 7 additions & 0 deletions test/mock_channel.dart
Expand Up @@ -64,6 +64,12 @@ class OneSignalMockChannelController {
case "OneSignal#deleteTags":
this.state.deleteTags = call.arguments;
return {"success": true};
case "OneSignal#setExternalUserId":
this.state.externalId = (call.arguments as Map<dynamic, dynamic>)['externalUserId'] as String;
return {"success" : true};
case "OneSignal#removeExternalUserId":
this.state.externalId = null;
return {"success" : true};
}
}
}
Expand All @@ -90,6 +96,7 @@ class OneSignalState {
bool locationShared;
OSNotificationDisplayType inFocusDisplayType;
bool subscriptionState;
String externalId;

// tags
Map<dynamic, dynamic> tags;
Expand Down
12 changes: 12 additions & 0 deletions test/onesignal_test.dart
Expand Up @@ -111,4 +111,16 @@ void main() {
expect(channelController.state.deleteTags, ['test1']);
}));
});

test('setting external user ID', () {
onesignal.setExternalUserId('test_ext_id').then(expectAsync1((v) {
expect(channelController.state.externalId, 'test_ext_id');
}));
});

test('removing external user ID', () {
onesignal.removeExternalUserId().then(expectAsync1((v) {
expect(channelController.state.externalId, null);
}));
});
}

0 comments on commit 27ddffe

Please sign in to comment.