forked from firka/flutter
[web] Support custom url strategies (#59797)
This commit is contained in:
38
packages/flutter_web_plugins/test/navigation/utils_test.dart
Normal file
38
packages/flutter_web_plugins/test/navigation/utils_test.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
@TestOn('browser') // Uses web-only Flutter SDK
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_web_plugins/src/navigation/utils.dart';
|
||||
|
||||
void main() {
|
||||
test('checks base href', () {
|
||||
expect(() => checkBaseHref(null), throwsException);
|
||||
expect(() => checkBaseHref('foo'), throwsException);
|
||||
expect(() => checkBaseHref('/foo'), throwsException);
|
||||
expect(() => checkBaseHref('foo/bar'), throwsException);
|
||||
expect(() => checkBaseHref('/foo/bar'), throwsException);
|
||||
|
||||
expect(() => checkBaseHref('/'), returnsNormally);
|
||||
expect(() => checkBaseHref('/foo/'), returnsNormally);
|
||||
expect(() => checkBaseHref('/foo/bar/'), returnsNormally);
|
||||
});
|
||||
|
||||
test('extracts pathname from URL', () {
|
||||
expect(extractPathname('/'), '/');
|
||||
expect(extractPathname('/foo'), '/foo');
|
||||
expect(extractPathname('/foo/'), '/foo/');
|
||||
expect(extractPathname('/foo/bar'), '/foo/bar');
|
||||
expect(extractPathname('/foo/bar/'), '/foo/bar/');
|
||||
|
||||
expect(extractPathname('https://example.com'), '/');
|
||||
expect(extractPathname('https://example.com/'), '/');
|
||||
expect(extractPathname('https://example.com/foo'), '/foo');
|
||||
expect(extractPathname('https://example.com/foo#bar'), '/foo');
|
||||
expect(extractPathname('https://example.com/foo/#bar'), '/foo/');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user