From a1a99a90dd8f3db2e73662e9911cc06a894c6f8c Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 21 Apr 2020 23:16:11 +0200 Subject: [PATCH] Added som local function tests --- lib/src/unofficial_jisho_api_base.dart | 2 +- test/local_function_test_cases.dart | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/src/unofficial_jisho_api_base.dart b/lib/src/unofficial_jisho_api_base.dart index 7970bfe..a27a79b 100644 --- a/lib/src/unofficial_jisho_api_base.dart +++ b/lib/src/unofficial_jisho_api_base.dart @@ -197,7 +197,7 @@ String getGifUri(String kanji) { int getNewspaperFrequencyRank(String pageHtml) { final frequencySection = getStringBetweenStrings(pageHtml, '
', '
'); - return frequencySection ?? int.parse(getStringBetweenStrings(frequencySection, '', '')); + return frequencySection.isNotEmpty ? int.parse(getStringBetweenStrings(frequencySection, '', '')) : null; } KanjiResult parseKanjiPageData(String pageHtml, String kanji) { diff --git a/test/local_function_test_cases.dart b/test/local_function_test_cases.dart index 9efc3ed..065807f 100644 --- a/test/local_function_test_cases.dart +++ b/test/local_function_test_cases.dart @@ -91,23 +91,28 @@ void test_local_functions() async { }); test('getRadical', () { - + final result = getRadical(kanjiPage); + expect(result, ['ジ']); //FIX }); test('getParts', () { - + final result = getParts(kanjiPage); + expect(result, ['土', '寸', '日']); }); test('getSvgUri', () { - + final result = getSvgUri(kanjiPage); + expect(result, 'http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06642.svg'); }); test('getGifUri', () { - + final result = getGifUri(kanjiPage); + expect(result, 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/3c.gif'); }); test('getNewspaperFrequencyRank', () { - + final result = getNewspaperFrequencyRank(kanjiPage); + expect(result, 16); //This might change }); test('parseKanjiPageData', () {