import 'package:flutter_test/flutter_test.dart';

import 'package:superport_v2/core/permissions/permission_resources.dart';

void main() {
  group('PermissionResources.normalize', () {
    test('경로 별칭을 서버 표준 경로로 변환한다', () {
      expect(
        PermissionResources.normalize('/inventory/inbound'),
        PermissionResources.stockTransactions,
      );
      expect(
        PermissionResources.normalize('/approvals/templates'),
        PermissionResources.approvalTemplates,
      );
    });

    test('대소문자/공백/슬래시를 정리한다', () {
      expect(
        PermissionResources.normalize('  inventory/inbound/  '),
        PermissionResources.stockTransactions,
      );
      expect(
        PermissionResources.normalize('stock-transactions'),
        PermissionResources.stockTransactions,
      );
    });

    test('쿼리/프래그먼트/URL을 제거한다', () {
      expect(
        PermissionResources.normalize(
          '/Inventory/Inbound?page=2&status=submit',
        ),
        PermissionResources.stockTransactions,
      );
      expect(
        PermissionResources.normalize(
          'https://example.com/approvals/templates#section',
        ),
        PermissionResources.approvalTemplates,
      );
    });

    test('비어 있는 입력은 빈 문자열을 반환한다', () {
      expect(PermissionResources.normalize('   '), isEmpty);
    });
  });
}
