Files
cxyz/cxyz-android/test/mangatown_urls_test.dart
nsrb a7c6058540 Add cxyz Android project structure and initial configuration
- Introduced a new Flutter project for the cxyz Android manga/comic reader, including essential files such as pubspec.yaml, AndroidManifest.xml, and Gradle configuration.
- Added .gitignore files to exclude unnecessary files and directories for both the main project and Android-specific files.
- Implemented initial README.md with project description, features, setup instructions, and API details for ComicLand, MangaRead, and MangaTown.
- Configured analysis options and dependencies in pubspec.yaml to support Flutter development.
- Established a pnpm workspace and lockfile for dependency management.
- Included various Android resources such as icons, styles, and launch backgrounds for a complete application setup.
2026-08-29 17:50:31 +07:00

115 lines
3.7 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:cxyz_android/sources/mangatown/urls.dart';
import 'package:cxyz_android/sources/source.dart';
void main() {
group('mangatown catalog URLs', () {
test('latest page 1 and 2', () {
expect(catalogLatestUrl(), 'https://m.mangatown.com/latest');
expect(catalogLatestUrl(page: 2), 'https://m.mangatown.com/latest/2.html');
});
test('hot total and period queries with pagination', () {
expect(catalogHotUrl(), 'https://m.mangatown.com/hot');
expect(
catalogHotUrl(page: 2),
'https://m.mangatown.com/hot/2.html',
);
expect(
catalogHotUrl(period: MangaTownHotPeriod.today),
'https://m.mangatown.com/hot?tviews.za',
);
expect(
catalogHotUrl(period: MangaTownHotPeriod.week, page: 2),
'https://m.mangatown.com/hot/2.html?wviews.za',
);
expect(
catalogHotUrl(period: MangaTownHotPeriod.month, page: 2),
'https://m.mangatown.com/hot/2.html?mviews.za',
);
});
test('directory default and filters', () {
expect(
directoryUrl(const CatalogBrowseParams()),
'https://m.mangatown.com/directory/0-0-0-0-0-0',
);
expect(
directoryUrl(
const CatalogBrowseParams(
demographic: 'seinen',
genre: 'action',
status: 'ongoing',
initial: 'a',
),
page: 2,
),
'https://m.mangatown.com/directory/seinen-action-0-ongoing-a-0/2.html',
);
});
test('search URL', () {
expect(
catalogSearchUrl(query: 'naruto'),
'https://m.mangatown.com/search?name=naruto',
);
expect(
catalogSearchUrl(query: 'naruto', page: 2),
'https://m.mangatown.com/search/2.html?name=naruto',
);
});
});
group('mangatown series/chapter helpers', () {
test('mangaSlugFromUrl and listingUrlForSlug', () {
expect(
mangaSlugFromUrl('https://m.mangatown.com/manga/ao_no_souyoku/c005/'),
'ao_no_souyoku',
);
expect(
listingUrlForSlug('ao_no_souyoku'),
'https://m.mangatown.com/manga/ao_no_souyoku',
);
});
test('chapterBaseUrl and chapterPageUrl', () {
expect(
chapterBaseUrl('https://m.mangatown.com/manga/ao_no_souyoku/c005/3.html'),
'https://m.mangatown.com/manga/ao_no_souyoku/c005/',
);
expect(
chapterPageUrl('https://m.mangatown.com/manga/ao_no_souyoku/c005/', 1),
'https://m.mangatown.com/manga/ao_no_souyoku/c005/',
);
expect(
chapterPageUrl('https://m.mangatown.com/manga/ao_no_souyoku/c005/', 5),
'https://m.mangatown.com/manga/ao_no_souyoku/c005/5.html',
);
});
test('chapterKeyFromUrl and chapterNumberFromTitle', () {
expect(
chapterKeyFromUrl('https://m.mangatown.com/manga/ao_no_souyoku/c005/'),
'c005',
);
expect(chapterNumberFromTitle('C.5'), '5');
expect(chapterNumberFromTitle('C.031'), '031');
});
test('absoluteUrl upgrades protocol-relative', () {
expect(
absoluteUrl('//zjcdn.mangahere.org/a.jpg', 'https://m.mangatown.com/'),
'https://zjcdn.mangahere.org/a.jpg',
);
});
test('hotPeriodForMenu mapping', () {
expect(hotPeriodForMenu(CatalogMenuKind.popular), MangaTownHotPeriod.total);
expect(hotPeriodForMenu(CatalogMenuKind.hotToday), MangaTownHotPeriod.today);
expect(hotPeriodForMenu(CatalogMenuKind.hotWeek), MangaTownHotPeriod.week);
expect(hotPeriodForMenu(CatalogMenuKind.hotMonth), MangaTownHotPeriod.month);
expect(hotPeriodForMenu(CatalogMenuKind.latest), isNull);
});
});
}