mirror of
https://github.com/h7x4/unofficial_jisho_api_dart.git
synced 2025-11-09 08:46:22 +01:00
Added som local function tests
This commit is contained in:
@@ -197,7 +197,7 @@ String getGifUri(String kanji) {
|
|||||||
|
|
||||||
int getNewspaperFrequencyRank(String pageHtml) {
|
int getNewspaperFrequencyRank(String pageHtml) {
|
||||||
final frequencySection = getStringBetweenStrings(pageHtml, '<div class="frequency">', '</div>');
|
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) {
|
KanjiResult parseKanjiPageData(String pageHtml, String kanji) {
|
||||||
|
|||||||
@@ -91,23 +91,28 @@ void test_local_functions() async {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('getRadical', () {
|
test('getRadical', () {
|
||||||
|
final result = getRadical(kanjiPage);
|
||||||
|
expect(result, ['ジ']); //FIX
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getParts', () {
|
test('getParts', () {
|
||||||
|
final result = getParts(kanjiPage);
|
||||||
|
expect(result, ['土', '寸', '日']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getSvgUri', () {
|
test('getSvgUri', () {
|
||||||
|
final result = getSvgUri(kanjiPage);
|
||||||
|
expect(result, 'http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06642.svg');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getGifUri', () {
|
test('getGifUri', () {
|
||||||
|
final result = getGifUri(kanjiPage);
|
||||||
|
expect(result, 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/3c.gif');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getNewspaperFrequencyRank', () {
|
test('getNewspaperFrequencyRank', () {
|
||||||
|
final result = getNewspaperFrequencyRank(kanjiPage);
|
||||||
|
expect(result, 16); //This might change
|
||||||
});
|
});
|
||||||
|
|
||||||
test('parseKanjiPageData', () {
|
test('parseKanjiPageData', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user