Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ jobs:
run: cd splitio/; flutter pub get
- name: Run flutter test
run: cd splitio/; flutter test
- name: Run flutter splitio_android test
run: cd splitio_android/; flutter test
- name: Run flutter splitio_ios test
run: cd splitio_ios/; flutter test
138 changes: 134 additions & 4 deletions splitio_android/test/splitio_android_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ void main() {
case 'getTreatment':
return '';
case 'getTreatments':
case 'getTreatmentsByFlagSet':
case 'getTreatmentsByFlagSets':
return {'split1': 'on', 'split2': 'off'};
case 'getTreatmentsWithConfig':
case 'getTreatmentsWithConfigByFlagSet':
case 'getTreatmentsWithConfigByFlagSets':
return {
'split1': {'treatment': 'on', 'config': null},
'split2': {'treatment': 'off', 'config': null}
Expand All @@ -54,6 +58,8 @@ void main() {
case 'removeAttribute':
case 'clearAttributes':
return true;
case 'getUserConsent':
return 'declined';
}
return null;
});
Expand Down Expand Up @@ -183,6 +189,130 @@ void main() {
'attributes': {'attr1': true}
});
});

test('getTreatmentsByFlagSet without attributes', () async {
_platform.getTreatmentsByFlagSet(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSet: 'set_1');

expect(methodName, 'getTreatmentsByFlagSet');
expect(methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsByFlagSet with attributes', () async {
_platform.getTreatmentsByFlagSet(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSet: 'set_1',
attributes: {'attr1': true});

expect(methodName, 'getTreatmentsByFlagSet');
expect(methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsByFlagSets without attributes', () async {
_platform.getTreatmentsByFlagSets(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSets: ['set_1', 'set_2']);

expect(methodName, 'getTreatmentsByFlagSets');
expect(methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsByFlagSets with attributes', () async {
_platform.getTreatmentsByFlagSets(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSets: ['set_1', 'set_2'],
attributes: {'attr1': true});

expect(methodName, 'getTreatmentsByFlagSets');
expect(methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsWithConfigByFlagSet without attributes', () async {
_platform.getTreatmentsWithConfigByFlagSet(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSet: 'set_1');

expect(methodName, 'getTreatmentsWithConfigByFlagSet');
expect(methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsWithConfigByFlagSet with attributes', () async {
_platform.getTreatmentsWithConfigByFlagSet(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSet: 'set_1',
attributes: {'attr1': true});

expect(methodName, 'getTreatmentsWithConfigByFlagSet');
expect(methodArguments, {
'flagSet': 'set_1',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});

test('getTreatmentsWithConfigByFlagSets without attributes', () async {
_platform.getTreatmentsWithConfigByFlagSets(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSets: ['set_1', 'set_2']);

expect(methodName, 'getTreatmentsWithConfigByFlagSets');
expect(methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {}
});
});

test('getTreatmentsWithConfigByFlagSets with attributes', () async {
_platform.getTreatmentsWithConfigByFlagSets(
matchingKey: 'matching-key',
bucketingKey: 'bucketing-key',
flagSets: ['set_1', 'set_2'],
attributes: {'attr1': true});

expect(methodName, 'getTreatmentsWithConfigByFlagSets');
expect(methodArguments, {
'flagSets': ['set_1', 'set_2'],
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'attributes': {'attr1': true}
});
});
});

group('track', () {
Expand Down Expand Up @@ -349,7 +479,7 @@ void main() {
expect(methodArguments, {
'apiKey': 'api-key',
'matchingKey': 'matching-key',
'sdkConfiguration': {}
'sdkConfiguration': {'readyTimeout': 10}
});
});

Expand All @@ -363,7 +493,7 @@ void main() {
'apiKey': 'api-key',
'matchingKey': 'matching-key',
'bucketingKey': 'bucketing-key',
'sdkConfiguration': {}
'sdkConfiguration': {'readyTimeout': 10}
});
});

Expand Down Expand Up @@ -527,14 +657,14 @@ void main() {
_platform.setUserConsent(true);

expect(methodName, 'setUserConsent');
expect(methodArguments, {'enabled': true});
expect(methodArguments, {'value': true});
});

test('set user consent disabled', () {
_platform.setUserConsent(false);

expect(methodName, 'setUserConsent');
expect(methodArguments, {'enabled': false});
expect(methodArguments, {'value': false});
});
});
}
Loading