Added som local function tests

This commit is contained in:
Oystein Kristoffer Tveit 2020-04-21 23:16:11 +02:00
parent 9394d7ea2e
commit a1a99a90dd
2 changed files with 11 additions and 6 deletions

View File

@ -197,7 +197,7 @@ String getGifUri(String kanji) {
int getNewspaperFrequencyRank(String pageHtml) {
final frequencySection = getStringBetweenStrings(pageHtml, '<div class="frequency">', '</div>');
return frequencySection ?? int.parse(getStringBetweenStrings(frequencySection, '<strong>', '</strong>'));
return frequencySection.isNotEmpty ? int.parse(getStringBetweenStrings(frequencySection, '<strong>', '</strong>')) : null;
}
KanjiResult parseKanjiPageData(String pageHtml, String kanji) {

View File

@ -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', () {