forked from 4akloon/epub_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepub_reader_test.dart
56 lines (45 loc) · 1.41 KB
/
epub_reader_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
library epubreadertest;
import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:epub_plus/epub_plus.dart';
void main() async {
const fileName = "alicesAdventuresUnderGround.epub";
String fullPath = path.join(
io.Directory.current.path,
"assets",
fileName,
);
final targetFile = io.File(fullPath);
late EpubBookRef epubRef;
setUpAll(() async {
if (!(await targetFile.exists())) {
throw Exception("Specified epub file not found: $fullPath");
}
final bytes = await targetFile.readAsBytes();
epubRef = await EpubReader.openBook(bytes);
});
group('EpubReader', () {
test("Epub version", () async {
expect(epubRef.schema?.package?.version, equals(EpubVersion.epub2));
});
test("Chapters count", () async {
var t = epubRef.getChapters();
expect(t.length, equals(2));
});
test("Author and title", () async {
expect(epubRef.author, equals("Lewis Carroll"));
expect(
epubRef.title,
equals(
'''Alice's Adventures Under Ground / Being a facsimile of the original Ms. book afterwards developed into "Alice's Adventures in Wonderland"'''),
);
});
test("Cover", () async {
final cover = await epubRef.readCover();
expect(cover, isNotNull);
expect(cover?.width, equals(581));
expect(cover?.height, equals(1034));
});
});
}