import 'package:flutter_test/flutter_test.dart';

import 'package:superport_v2/core/validation/password_rules.dart';

void main() {
  group('PasswordRules', () {
    test('정책을 모두 만족하면 위반 목록이 비어 있다', () {
      const password = 'Aa1!abcd';

      final result = PasswordRules.validate(password);

      expect(result, isEmpty);
      expect(PasswordRules.isValid(password), isTrue);
    });

    test('길이가 짧으면 tooShort 위반이 발생한다', () {
      final result = PasswordRules.validate('Aa1!');

      expect(result, contains(PasswordRuleViolation.tooShort));
      expect(result, isNot(contains(PasswordRuleViolation.tooLong)));
    });

    test('길이가 길면 tooLong 위반이 발생한다', () {
      const password =
          'Aa1!'
          'abcdefghijklmnopqrstu';

      final result = PasswordRules.validate(password);

      expect(result, contains(PasswordRuleViolation.tooLong));
    });

    test('대문자가 없으면 missingUppercase 위반이 발생한다', () {
      final result = PasswordRules.validate('aa1!aaaa');

      expect(result, contains(PasswordRuleViolation.missingUppercase));
    });

    test('소문자가 없으면 missingLowercase 위반이 발생한다', () {
      final result = PasswordRules.validate('AA1!AAAA');

      expect(result, contains(PasswordRuleViolation.missingLowercase));
    });

    test('숫자가 없으면 missingDigit 위반이 발생한다', () {
      final result = PasswordRules.validate('AAa!aaaa');

      expect(result, contains(PasswordRuleViolation.missingDigit));
    });

    test('특수 문자가 없으면 missingSpecial 위반이 발생한다', () {
      final result = PasswordRules.validate('AAa1aaaa');

      expect(result, contains(PasswordRuleViolation.missingSpecial));
    });
  });
}
