-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
87 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'package:alice/alice.dart'; | ||
import 'package:alice/core/alice_adapter.dart'; | ||
import 'package:alice/core/alice_logger.dart'; | ||
import 'package:alice/core/alice_storage.dart'; | ||
import 'package:alice/model/alice_configuration.dart'; | ||
import 'package:alice/model/alice_http_call.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'mock/mocked_data.dart'; | ||
|
||
void main() { | ||
group("Alice", () { | ||
late Alice alice; | ||
late AliceStorage aliceStorage; | ||
late AliceLogger aliceLogger; | ||
setUp(() { | ||
aliceStorage = AliceMemoryStorage(maxCallsCount: 1000); | ||
aliceLogger = AliceLogger(maximumSize: 1000); | ||
alice = Alice( | ||
configuration: AliceConfiguration( | ||
showInspectorOnShake: false, | ||
showNotification: false, | ||
logger: aliceLogger, | ||
storage: aliceStorage, | ||
), | ||
); | ||
}); | ||
|
||
test("should set new navigator key", () { | ||
final navigatorKey = GlobalKey<NavigatorState>(); | ||
|
||
expect(alice.getNavigatorKey() != navigatorKey, true); | ||
|
||
alice.setNavigatorKey(navigatorKey); | ||
|
||
expect(alice.getNavigatorKey() == navigatorKey, true); | ||
}); | ||
|
||
test("should add log", () { | ||
final log = AliceLog(message: "test"); | ||
|
||
alice.addLog(log); | ||
|
||
expect(aliceLogger.logs, [log]); | ||
}); | ||
|
||
test("should add logs", () { | ||
final logs = [AliceLog(message: "test 1"), AliceLog(message: "test 2")]; | ||
|
||
alice.addLogs(logs); | ||
|
||
expect(aliceLogger.logs, logs); | ||
}); | ||
|
||
test("should add call", () { | ||
final call = MockedData.getFilledHttpCall(); | ||
|
||
alice.addHttpCall(call); | ||
|
||
expect(aliceStorage.getCalls(), [call]); | ||
}); | ||
|
||
test("should add adapter", () { | ||
final call = MockedData.getFilledHttpCall(); | ||
final adapter = FakeAdapter(); | ||
alice.addAdapter(adapter); | ||
|
||
adapter.addCallLog(call); | ||
|
||
expect(aliceStorage.getCalls(), [call]); | ||
}); | ||
|
||
test("should return is inspector opened flag", () { | ||
expect(alice.isInspectorOpened, false); | ||
}); | ||
}); | ||
} | ||
|
||
class FakeAdapter with AliceAdapter { | ||
void addCallLog(AliceHttpCall call) { | ||
aliceCore.addCall(call); | ||
} | ||
} |
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
File renamed without changes.