46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:boxchecker/data_util.dart' as data;
|
|
import 'package:hive/hive.dart';
|
|
|
|
void main() {
|
|
Hive.init("lists");
|
|
Hive.registerAdapter(data.ListAdapter());
|
|
Hive.registerAdapter(data.CheckAdapter());
|
|
test('opening box', () async {
|
|
var box = await Hive.openBox<data.List>("lists");
|
|
expect(box, isNotNull);
|
|
box.close();
|
|
});
|
|
test('adding lists to box', () async {
|
|
var box = await Hive.openBox<data.List>("lists");
|
|
await box.clear();
|
|
expect(box.length, 0);
|
|
final data.List list = data.List("test_list");
|
|
box.add(list);
|
|
|
|
expect(box.length, 1);
|
|
|
|
var l = box.get(0);
|
|
expect(l, isNotNull);
|
|
box.close();
|
|
});
|
|
test('adding chekcs to lists', () async {
|
|
var box = await Hive.openBox<data.List>("lists");
|
|
var l = box.get(0);
|
|
expect(l, isNotNull);
|
|
|
|
expect(l!.checks, isEmpty);
|
|
//print(l.checks);
|
|
|
|
l.checks.add(data.Check("test Check", false));
|
|
expect(l.checks, isNotEmpty);
|
|
|
|
var l2 = box.get(0);
|
|
expect(l2, isNotNull);
|
|
expect(l2!.checks, isNotEmpty);
|
|
});
|
|
}
|