import 'package:flutter_test/flutter_test.dart';
import 'package:userfront/core/services/login_challenge_loop_guard.dart';

void main() {
  group('login_challenge_loop_guard', () {
    test('mark 이후 cooldown 내 재시도는 차단되고 clear 후 허용된다', () {
      const challenge = 'loop-guard-test-challenge';
      loginChallengeLoopGuard.clear(challenge);

      expect(loginChallengeLoopGuard.shouldAllowAutoAccept(challenge), isTrue);

      loginChallengeLoopGuard.markAutoAcceptAttempt(challenge);

      expect(
        loginChallengeLoopGuard.shouldAllowAutoAccept(
          challenge,
          cooldownMs: 60000,
        ),
        isFalse,
      );

      loginChallengeLoopGuard.clear(challenge);

      expect(loginChallengeLoopGuard.shouldAllowAutoAccept(challenge), isTrue);
    });
  });
}
