import 'package:flutter_test/flutter_test.dart';
import 'package:openim_common/openim_common.dart';

void main() {
  test('把 OpenIM 公开资料映射成我的信息可用字段', () {
    final info = UserFullInfoMapper.fromImJson({
      'userID': '10001',
      'nickname': '张三',
      'faceURL': 'http://example/a.png',
      'ex': '',
      'globalRecvMsgOpt': 0,
    });
    expect(info.userID, '10001');
    expect(info.nickname, '张三');
    expect(info.faceURL, 'http://example/a.png');
    expect(info.globalRecvMsgOpt, 0);
  });

  test('不把 chat 业务字段当成仍可从账号服务拿到', () {
    final info = UserFullInfoMapper.fromImJson({
      'userID': '10001',
      'nickname': '张三',
      'phoneNumber': '13800000000',
      'email': 'a@b.c',
      'gender': 1,
    });
    expect(info.userID, '10001');
    expect(info.nickname, '张三');
    expect(info.phoneNumber, isNull);
    expect(info.email, isNull);
    expect(info.gender, isNull);
  });

  test('空列表保持为空', () {
    expect(UserFullInfoMapper.fromImList(const []), isEmpty);
  });
}
