2020-09-19 19:21:33 +02:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:fluffychat/utils/matrix_identifier_string_extension.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
group('Matrix Identifier String Extension', () {
|
|
|
|
test('parseIdentifierIntoParts', () {
|
|
|
|
var res = '#alias:beep'.parseIdentifierIntoParts();
|
2020-12-27 11:46:53 +01:00
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, null);
|
2020-09-19 19:21:33 +02:00
|
|
|
expect(res.queryString, null);
|
|
|
|
res = 'blha'.parseIdentifierIntoParts();
|
|
|
|
expect(res, null);
|
|
|
|
res = '#alias:beep/\$event'.parseIdentifierIntoParts();
|
2020-12-27 11:46:53 +01:00
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, '\$event');
|
2020-09-19 19:21:33 +02:00
|
|
|
expect(res.queryString, null);
|
|
|
|
res = '#alias:beep?blubb'.parseIdentifierIntoParts();
|
2020-12-27 11:46:53 +01:00
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, null);
|
2020-09-19 19:21:33 +02:00
|
|
|
expect(res.queryString, 'blubb');
|
|
|
|
res = '#alias:beep/\$event?blubb'.parseIdentifierIntoParts();
|
2020-12-27 11:46:53 +01:00
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, '\$event');
|
2020-09-19 19:21:33 +02:00
|
|
|
expect(res.queryString, 'blubb');
|
|
|
|
res = '#/\$?:beep/\$event?blubb?b'.parseIdentifierIntoParts();
|
2020-12-27 11:46:53 +01:00
|
|
|
expect(res.primaryIdentifier, '#/\$?:beep');
|
|
|
|
expect(res.secondaryIdentifier, '\$event');
|
2020-09-19 19:21:33 +02:00
|
|
|
expect(res.queryString, 'blubb?b');
|
2020-12-27 11:46:53 +01:00
|
|
|
|
|
|
|
res = 'https://matrix.to/#/#alias:beep'.parseIdentifierIntoParts();
|
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, null);
|
|
|
|
expect(res.queryString, null);
|
|
|
|
res = 'https://matrix.to/#/%23alias%3abeep'.parseIdentifierIntoParts();
|
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, null);
|
|
|
|
expect(res.queryString, null);
|
|
|
|
res = 'https://matrix.to/#/%23alias%3abeep?boop%F0%9F%A7%A1%F0%9F%A6%8A'
|
|
|
|
.parseIdentifierIntoParts();
|
|
|
|
expect(res.primaryIdentifier, '#alias:beep');
|
|
|
|
expect(res.secondaryIdentifier, null);
|
|
|
|
expect(res.queryString, 'boop%F0%9F%A7%A1%F0%9F%A6%8A');
|
2020-09-19 19:21:33 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|