Skip to content

Commit

Permalink
chore: test for fallback skip
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Jul 10, 2024
1 parent d0bd062 commit 312c950
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions test/loaders/file_translation_loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ void main() {

test('should deep merge fallback map', () async {
var instance = FileTranslationLoader(
forcedLocale: Locale.fromSubtags(languageCode: "fr"),
fallbackFile: "en"
);
forcedLocale: Locale.fromSubtags(languageCode: "fr"),
fallbackFile: "en");
instance.assetBundle = TestAssetBundleFallbackFrToEn();

var result = await instance.load();
Expand All @@ -44,28 +43,50 @@ void main() {
expect(block["label2"], equals("Bonjour"));
});

test('should skip merge fallback map', () async {
var instance = FileTranslationLoader(
forcedLocale: Locale.fromSubtags(languageCode: "fr"),
fallbackFile: null);
instance.assetBundle = TestAssetBundleFallbackFrToEn();

var result = await instance.load();

expect(result, isMap);
expect(result, isNotEmpty);
expect(result["title"], equals("flutter_18n_fr"));
expect(result["sub_title"], equals(null));
var block = result["block"];
expect(block, isMap);
expect(block, isNotEmpty);
expect(block["label1"], equals(null));
expect(block["label2"], equals("Bonjour"));
});

test('`loadString` should load correct string', () async {
final instance = TestJsonLoader();
final result = await instance.loadString("_fileName", "_extension");
expect(result, contains("_fileName"));
expect(result, contains("_extension"));
});

test('`load` should load correct map from JSON with initial values', () async {
test('`load` should load correct map from JSON with initial values',
() async {
final instance = TestJsonLoader();
final result = await instance.load();
expect(result["fileName"], "en");
expect(result["extension"], "json");
});

test('`load` should load correct map from YAML with initial values', () async {
test('`load` should load correct map from YAML with initial values',
() async {
final instance = TestYamlLoader();
final result = await instance.load();
expect(result["fileName"], "en");
expect(result["extension"], "yaml");
});

test('`load` should load correct map from TOML with initial values', () async {
test('`load` should load correct map from TOML with initial values',
() async {
final instance = TestTomlLoader();
final result = await instance.load();
expect(result["fileName"], "en");
Expand Down

0 comments on commit 312c950

Please sign in to comment.