testing library
A fake Clikgate for your app's widget and unit tests.
import 'package:clikgate_flutter/testing.dart';
late ClikgateFake clikgate;
setUp(() => clikgate = ClikgateFake.install());
testWidgets('checkout counts the goal', (tester) async {
await tester.pumpWidget(const MyApp());
await tester.tap(find.text('Pay'));
await tester.pumpAndSettle();
expect(clikgate.goals.single.key, 'purchase');
});
ClikgateFake.install answers every call of package:clikgate_flutter/clikgate_flutter.dart
and of the Engage features (package:clikgate_flutter/engage.dart) without a device or a
network: it replaces the plugin's platform channels (com.clikgate/sdk,
com.clikgate/engage, com.clikgate/deep_links) and the HTTP client Engage uses to call the
Clikgate API from Dart. It records every call and removes itself when the test ends.
Only import this library from tests. Your app's code never imports it, so it isn't in your app's builds.
Classes
- ClikgateFake
- A fake Clikgate for widget and unit tests: see ClikgateFake.install.
- ClikgateFakeAppliedCode
-
A
Clikgate.referrals.applyCodecall seen by ClikgateFake. - ClikgateFakeGoal
-
A
Clikgate.goalcall seen by ClikgateFake, with the result it answered. - ClikgateFakeIdentify
-
A
Clikgate.identifyUsercall seen by ClikgateFake. - ClikgateFakeRequest
- A request the Engage features sent to the Clikgate API, seen by ClikgateFake.
-
An Engage share call seen by ClikgateFake: method is
shareLink(share.link,share.referralLink),shareText(share.system, orshare.whatsAppwhen WhatsApp didn't open) oropenUrl(share.whatsApp).