url_test.dart 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:flutter_test/flutter_test.dart';
  2. import 'package:gmus/utils/url.dart';
  3. void main() {
  4. test('formattedUrl should format a root URL', () {
  5. expect(
  6. formattedUrl('my.api.com', '/foo/bar').toString(),
  7. 'https://my.api.com/foo/bar',
  8. );
  9. });
  10. test('formattedUrl should format a root URL with query', () {
  11. expect(
  12. formattedUrl('my.api.com', '/foo/bar', {
  13. 'baz': 'yes',
  14. }).toString(),
  15. 'https://my.api.com/foo/bar?baz=yes',
  16. );
  17. });
  18. test('formattedUrl should format a non-root URL', () {
  19. expect(
  20. formattedUrl('my.api.com/api', '/foo/bar').toString(),
  21. 'https://my.api.com/api/foo/bar',
  22. );
  23. });
  24. test('formattedUrl should format a non-root URL with query', () {
  25. expect(
  26. formattedUrl('my.api.com/api', '/foo/bar', {
  27. 'baz': 'yes',
  28. }).toString(),
  29. 'https://my.api.com/api/foo/bar?baz=yes',
  30. );
  31. });
  32. }