import 'package:flutter_test/flutter_test.dart';

import 'package:chanora_flutter/services/ts3_server_link.dart';

void main() {
  test('parses encoded add-bookmark TeamSpeak link', () {
    final link = parseTs3ServerLink(
      'ts3server://teamspeak.app%3Faddbookmark%3DVigorous%20Pro/',
    );

    expect(link, isNotNull);
    expect(link!.host, 'teamspeak.app');
    expect(link.hostWithPort, 'teamspeak.app');
    expect(link.addBookmark, 'Vigorous Pro');
  });

  test('parses full TeamSpeak server link parameters', () {
    final link = parseTs3ServerLink(
      'ts3server://ts3.hoster.com?port=9987&nickname=UserNickname'
      '&password=serverPassword&channel=MyDefaultChannel&cid=123'
      '&channelpassword=defaultChannelPassword&token=TokenKey'
      '&addbookmark=MyBookMarkLabel',
    );

    expect(link, isNotNull);
    expect(link!.host, 'ts3.hoster.com');
    expect(link.hostWithPort, 'ts3.hoster.com:9987');
    expect(link.port, 9987);
    expect(link.nickname, 'UserNickname');
    expect(link.password, 'serverPassword');
    expect(link.channel, 'MyDefaultChannel');
    expect(link.cid, '123');
    expect(link.channelPassword, 'defaultChannelPassword');
    expect(link.token, 'TokenKey');
    expect(link.addBookmark, 'MyBookMarkLabel');
  });

  test('keeps explicit host port without duplicating port query', () {
    final link = parseTs3ServerLink('ts3server://ts3.hoster.com:9987');

    expect(link, isNotNull);
    expect(link!.hostWithPort, 'ts3.hoster.com:9987');
  });
}
