import 'package:flutter_test/flutter_test.dart'; import 'package:warp/matrix/client.dart'; import 'package:warp/util/format.dart'; void main() { group('formatBytes', () { test('bytes', () => expect(formatBytes(980), '980 B')); test('kilobytes', () => expect(formatBytes(12345), '12 KB')); test('small megabytes keep a decimal', () { expect(formatBytes(3400000), '3.4 MB'); }); test('gigabytes', () => expect(formatBytes(2000000000), '2.0 GB')); }); group('formatListTime', () { final now = DateTime(2026, 10, 18, 15, 30); test('today is the time', () { expect(formatListTime(DateTime(2026, 10, 18, 9, 5), now: now), '09:05'); }); test('yesterday', () { expect(formatListTime(DateTime(2026, 10, 17, 23), now: now), 'Yesterday'); }); test('this week is the weekday', () { expect(formatListTime(DateTime(2026, 10, 14), now: now), 'Wed'); }); }); group('formatDay', () { final now = DateTime(2026, 10, 18, 15, 30); test( 'today', () => expect(formatDay(DateTime(2026, 10, 18), now: now), 'Today'), ); test('yesterday', () { expect(formatDay(DateTime(2026, 10, 17), now: now), 'Yesterday'); }); }); group('serverOfUserId', () { test('a full user ID', () { expect(serverOfUserId('@alice:example.org'), 'example.org'); }); test('with a port', () { expect(serverOfUserId(' @bob:localhost:8008 '), 'localhost:8008'); }); test('a bare username', () => expect(serverOfUserId('alice'), isNull)); test('no server', () => expect(serverOfUserId('@alice:'), isNull)); }); }