import 'package:commons_core/commons_core.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/services/wot_settings.dart';

import '../support/test_support.dart';

void main() {
  late WotSettings settings;
  setUp(() => settings = WotSettings(InMemorySecretStore()));

  test('defaults to the Duniter parameters', () async {
    expect(await settings.params(), WotParams.duniter);
  });

  test('persists saved parameters', () async {
    const custom = WotParams(
        sigQty: 3, stepMax: 4, sigValidity: Duration(days: 180));
    await settings.save(custom);
    expect(await settings.params(), custom);
  });

  test('reset restores the Duniter defaults', () async {
    await settings.save(const WotParams(
        sigQty: 1, stepMax: 1, sigValidity: Duration(days: 30)));
    await settings.reset();
    expect(await settings.params(), WotParams.duniter);
  });
}
