38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:friendly_map/modules/sharing/sharing.dart';
|
|
import 'package:friendly_map/modules/storage/storage.dart';
|
|
|
|
ShareRecord _card({int? sent = 100, int? ended}) => ShareRecord(
|
|
id: 's', unit: 'card', targetId: 'c', peerId: 'p',
|
|
startedAt: 1, endedAt: ended, sentVersion: sent, updatedAt: 1,
|
|
);
|
|
|
|
void main() {
|
|
test('보낸 뒤 명함을 고치지 않았으면 최신', () {
|
|
expect(shareStatusOf(_card(), 100), ShareStatus.upToDate);
|
|
});
|
|
|
|
test('보낸 뒤 명함을 고쳤으면 다시 보내야 함', () {
|
|
expect(shareStatusOf(_card(), 101), ShareStatus.needsResend);
|
|
});
|
|
|
|
test('끝낸 공유는 끝남', () {
|
|
expect(shareStatusOf(_card(ended: 5), 999), ShareStatus.ended);
|
|
});
|
|
|
|
test('대화방 공유는 다시 보낼 것이 없음', () {
|
|
const room = ShareRecord(
|
|
id: 's', unit: 'room', targetId: 'r', peerId: 'p', startedAt: 1, updatedAt: 1,
|
|
);
|
|
expect(shareStatusOf(room, 999), ShareStatus.upToDate);
|
|
});
|
|
|
|
test('다시 보내기는 내용과 시점만 바꾼다', () {
|
|
final r = _card().resent(snapshot: '{}', sentVersion: 200, updatedAt: 201);
|
|
expect(r.sentVersion, 200);
|
|
expect(r.snapshot, '{}');
|
|
expect(r.id, 's');
|
|
expect(r.startedAt, 1);
|
|
});
|
|
}
|