mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
Adds an initial unit test
This commit is contained in:
45
test/api_test.dart
Normal file
45
test/api_test.dart
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Unit tests for the API class
|
||||
*/
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:inventree/api.dart';
|
||||
import 'package:inventree/user_profile.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
setUp(() async {
|
||||
// Ensure we have a user profile available
|
||||
// This profile will match the dockerized InvenTree setup, running locally
|
||||
|
||||
print("Creating user profile");
|
||||
await UserProfileDBManager().addProfile(UserProfile(
|
||||
username: "testuser",
|
||||
password: "testpassword""",
|
||||
server: "http://localhost:12345",
|
||||
selected: true,
|
||||
));
|
||||
|
||||
final profiles = await UserProfileDBManager().getAllProfiles();
|
||||
|
||||
// Ensure we have one profile available
|
||||
expect(profiles.length, equals(1));
|
||||
|
||||
// Select the profile
|
||||
await UserProfileDBManager().selectProfile(profiles.first.key ?? 1);
|
||||
|
||||
});
|
||||
|
||||
test("Select Profile", () async {
|
||||
// Ensure that we can select a user profile
|
||||
final prf = await UserProfileDBManager().getSelectedProfile();
|
||||
|
||||
expect(prf, isNot(null));
|
||||
|
||||
expect(prf?.username, equals("testuser"));
|
||||
expect(prf?.password, equals("testpassword"));
|
||||
expect(prf?.server, equals("http://localhost:12345"));
|
||||
});
|
||||
|
||||
}
|
Reference in New Issue
Block a user