From 70226d61e1e5be9e6e93b8743339e460a8651a19 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 11 Dec 2024 13:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Update=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/delegates_test.dart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/delegates_test.dart b/test/delegates_test.dart index 2698964b..6ae1386a 100644 --- a/test/delegates_test.dart +++ b/test/delegates_test.dart @@ -2,10 +2,40 @@ // Use of this source code is governed by an Apache license that can be found // in the LICENSE file. +import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:wechat_assets_picker/wechat_assets_picker.dart'; void main() { + group(AssetPickerTextDelegate, () { + test('returns the default when available', () { + expect( + assetPickerTextDelegateFromLocale(null), + equals(const AssetPickerTextDelegate()), + ); + expect( + assetPickerTextDelegateFromLocale(const Locale('zh')), + equals(const AssetPickerTextDelegate()), + ); + expect( + assetPickerTextDelegateFromLocale(const Locale('zxx')), + equals(const AssetPickerTextDelegate()), + ); + }); + + test('each delegate can be obtained by its locale definition', () { + for (final delegate in assetPickerTextDelegates) { + final locale = Locale.fromSubtags( + languageCode: delegate.languageCode, + scriptCode: delegate.scriptCode, + countryCode: delegate.countryCode, + ); + final matchedDelegate = assetPickerTextDelegateFromLocale(locale); + expect(matchedDelegate, equals(delegate)); + } + }); + }); + test('Sort paths correctly', () { final List> paths = >[