import 'package:flutter_test/flutter_test.dart'; import 'package:twp_softphone/models/queue_state.dart'; void main() { group('QueueInfo', () { test('parses from JSON with all fields', () { final json = { 'id': 1, 'name': 'General', 'type': 'general', 'extension': '100', 'waiting_count': 3, }; final queue = QueueInfo.fromJson(json); expect(queue.id, 1); expect(queue.name, 'General'); expect(queue.type, 'general'); expect(queue.extension, '100'); expect(queue.waitingCount, 3); }); test('parses from JSON with string numbers', () { final json = { 'id': '5', 'name': 'Support', 'type': 'personal', 'waiting_count': '0', }; final queue = QueueInfo.fromJson(json); expect(queue.id, 5); expect(queue.waitingCount, 0); expect(queue.extension, isNull); }); test('handles missing fields gracefully', () { final json = {}; final queue = QueueInfo.fromJson(json); expect(queue.id, 0); expect(queue.name, ''); expect(queue.type, ''); expect(queue.extension, isNull); expect(queue.waitingCount, 0); }); }); group('QueueCall', () { test('parses from JSON', () { final json = { 'call_sid': 'CA123abc', 'from_number': '+18005551234', 'to_number': '+19095737372', 'position': 1, 'status': 'waiting', 'wait_time': 45, }; final call = QueueCall.fromJson(json); expect(call.callSid, 'CA123abc'); expect(call.fromNumber, '+18005551234'); expect(call.toNumber, '+19095737372'); expect(call.position, 1); expect(call.status, 'waiting'); expect(call.waitTime, 45); }); test('handles string wait_time', () { final json = { 'call_sid': 'CA456', 'from_number': '+1800', 'to_number': '+1900', 'position': '2', 'status': 'waiting', 'wait_time': '120', }; final call = QueueCall.fromJson(json); expect(call.position, 2); expect(call.waitTime, 120); }); test('handles missing fields gracefully', () { final json = {}; final call = QueueCall.fromJson(json); expect(call.callSid, ''); expect(call.fromNumber, ''); expect(call.position, 0); expect(call.waitTime, 0); }); }); }