-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests and Documentation update for In-app message delegate
- Loading branch information
1 parent
9e03bbb
commit 265b973
Showing
10 changed files
with
872 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'package:exponea/exponea.dart'; | ||
import 'package:exponea/src/data/encoder/main.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'base.dart'; | ||
|
||
void main() { | ||
group('InAppMessageAction', () { | ||
const encode = InAppMessageActionEncoder.encode; | ||
const decode = InAppMessageActionEncoder.decode; | ||
|
||
final data = readMapData('in_app_message_action'); | ||
test('check data', () async { | ||
expect(data.length, 3); | ||
}); | ||
final noData = data[0]; | ||
final minData = data[1]; | ||
final fullData = data[2]; | ||
|
||
group('encode', () { | ||
test('minimal', () async { | ||
const inAppMessageAction = InAppMessageAction( | ||
message: InAppMessage( | ||
id: 'mock-id', | ||
name: 'mock-name', | ||
frequency: 'mock-frequency', | ||
variantId: 1, | ||
variantName: 'mock-variantName', | ||
messageType: 'mock-messageType', | ||
payload: {'mock-payload-param': 'mock-payload-content'}, | ||
trigger: {'mock-trigger-param': 'mock-trigger-content'}, | ||
dateFilter: {'mock-dateFilter-param': 'mock-dateFilter-content'}, | ||
loadPriority: 1, | ||
loadDelay: 1000, | ||
closeTimeout: 2000, | ||
payloadHtml: 'mock-payloadHtml', | ||
isHtml: true, | ||
hasTrackingConsent: true, | ||
consentCategoryTracking: 'mock-consentCategoryTracking', | ||
), | ||
interaction: true, | ||
); | ||
expect(encode(inAppMessageAction), minData); | ||
}); | ||
|
||
test('full', () async { | ||
const inAppMessageAction = InAppMessageAction( | ||
message: InAppMessage( | ||
id: 'mock-id', | ||
name: 'mock-name', | ||
frequency: 'mock-frequency', | ||
variantId: 1, | ||
variantName: 'mock-variantName', | ||
messageType: 'mock-messageType', | ||
payload: {'mock-payload-param': 'mock-payload-content'}, | ||
trigger: {'mock-trigger-param': 'mock-trigger-content'}, | ||
dateFilter: {'mock-dateFilter-param': 'mock-dateFilter-content'}, | ||
loadPriority: 1, | ||
loadDelay: 1000, | ||
closeTimeout: 2000, | ||
payloadHtml: 'mock-payloadHtml', | ||
isHtml: true, | ||
hasTrackingConsent: true, | ||
consentCategoryTracking: 'mock-consentCategoryTracking', | ||
), | ||
interaction: true, | ||
button: InAppMessageButton( | ||
text: 'button', | ||
url: "https://a.b.c", | ||
)); | ||
expect(encode(inAppMessageAction), fullData); | ||
}); | ||
}); | ||
|
||
group('decode', () { | ||
test('no data', () async { | ||
expect(() => decode(noData), throwsStateError); | ||
}); | ||
|
||
test('minimal', () async { | ||
final decoded = decode(minData); | ||
expect(decoded.message, isA<InAppMessage>()); | ||
expect(decoded.interaction, true); | ||
expect(decoded.button, null); | ||
}); | ||
|
||
test('full data', () async { | ||
final decoded = decode(fullData); | ||
expect(decoded.message, isA<InAppMessage>()); | ||
expect(decoded.interaction, true); | ||
expect(decoded.button, isA<InAppMessageButton>()); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:exponea/exponea.dart'; | ||
import 'package:exponea/src/data/encoder/main.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'base.dart'; | ||
|
||
void main() { | ||
group('InAppMessageButton', () { | ||
const encode = InAppMessageButtonEncoder.encode; | ||
const decode = InAppMessageButtonEncoder.decode; | ||
|
||
final data = readMapData('in_app_message_button'); | ||
test('check data', () async { | ||
expect(data.length, 3); | ||
}); | ||
final noData = data[0]; | ||
final textOnlyData = data[1]; | ||
final fullData = data[2]; | ||
|
||
group('encode', () { | ||
test('no data', () { | ||
const inAppMessageButton = InAppMessageButton(); | ||
expect(encode(inAppMessageButton), noData); | ||
}); | ||
|
||
test('text only', () async { | ||
const inAppMessageButton = InAppMessageButton(text: 'button'); | ||
expect(encode(inAppMessageButton), textOnlyData); | ||
}); | ||
|
||
test('full data', () async { | ||
const inAppMessageButton = InAppMessageButton(text: 'button', url: 'https://a.b.c'); | ||
expect(encode(inAppMessageButton), fullData); | ||
}); | ||
}); | ||
|
||
group('decode', () { | ||
test('no data', () async { | ||
const expected = InAppMessageButton(); | ||
final decoded = decode(noData); | ||
|
||
expect(decoded.text, null); | ||
expect(decoded.url, null); | ||
}); | ||
|
||
test('text only', () async { | ||
final decoded = decode(textOnlyData); | ||
|
||
expect(decoded.text, 'button'); | ||
expect(decoded.url, null); | ||
}); | ||
|
||
test('full data', () async { | ||
final decoded = decode(fullData); | ||
|
||
expect(decoded.text, 'button'); | ||
expect(decoded.url, 'https://a.b.c'); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.