71 lines
2.3 KiB
Dart
71 lines
2.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:friendly_map/modules/storage/storage.dart';
|
|
|
|
void main() {
|
|
test('내 명함 맵 변환 왕복', () {
|
|
const c = MyCard(
|
|
id: 'a', kind: 'company', title: '회사 명함',
|
|
fieldsJson: '{"name":"이미영"}', updatedAt: 123, shareDefault: true,
|
|
);
|
|
final back = MyCard.fromMap(c.toMap());
|
|
expect(back.id, 'a');
|
|
expect(back.shareDefault, true);
|
|
expect(back.updatedAt, 123);
|
|
});
|
|
|
|
test('대화 맵 변환 왕복', () {
|
|
const m = Message(
|
|
id: 'm', roomId: 'r', senderId: 's', body: '안녕', sentAt: 1, updatedAt: 2,
|
|
);
|
|
final back = Message.fromMap(m.toMap());
|
|
expect(back.body, '안녕');
|
|
expect(back.archived, false);
|
|
});
|
|
|
|
test('설정 기본값은 텍스트 1MB, 저장 공간 80%, 복구 조각 5개 중 3개', () {
|
|
final s = AppSettings.fromMap({});
|
|
expect(s.separateTextBytes, 1024 * 1024);
|
|
expect(s.storageUsagePercent, 80);
|
|
expect(s.recoveryShares, 5);
|
|
expect(s.recoveryThreshold, 3);
|
|
});
|
|
|
|
test('설정 저장 형태 왕복', () {
|
|
const s = AppSettings(storageUsagePercent: 90, exchangeMode: 'auto');
|
|
final back = AppSettings.fromMap(s.toMap());
|
|
expect(back.storageUsagePercent, 90);
|
|
expect(back.exchangeMode, 'auto');
|
|
});
|
|
|
|
test('ID 는 32자 16진수이고 매번 다르다', () {
|
|
final a = newId();
|
|
final b = newId();
|
|
expect(a.length, 32);
|
|
expect(a == b, false);
|
|
});
|
|
|
|
test('전화번호는 어떻게 적어도 같은 키가 된다', () {
|
|
const want = '+821028475821';
|
|
expect(normalizePhone('010-2847-5821'), want);
|
|
expect(normalizePhone('01028475821'), want);
|
|
expect(normalizePhone('+82 10-2847-5821'), want);
|
|
expect(normalizePhone('821028475821'), want);
|
|
expect(normalizePhone('0082 10 2847 5821'), want);
|
|
});
|
|
|
|
test('번호가 아니면 null', () {
|
|
expect(normalizePhone(''), null);
|
|
expect(normalizePhone('abc'), null);
|
|
expect(normalizePhone('123'), null);
|
|
});
|
|
|
|
test('사람은 번호표(id)와 현재 번호·이름을 가진다', () {
|
|
const p = Person(
|
|
id: 'p1', name: '정민호', phone: '+821028475821', createdAt: 1, updatedAt: 2);
|
|
final back = Person.fromMap(p.toMap());
|
|
expect(back.id, 'p1');
|
|
expect(back.phone, '+821028475821');
|
|
expect(back.name, '정민호');
|
|
});
|
|
}
|