forked from creatint/dart-epub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epub_reader_tests.dart
31 lines (24 loc) · 970 Bytes
/
epub_reader_tests.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
library epubreadertest;
import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:epub/epub.dart';
main() async {
String fileName = "hittelOnGoldMines.epub";
String fullPath = path.join(io.Directory.current.path, "test", fileName);
var targetFile = new io.File(fullPath);
if (!(await targetFile.exists())) {
throw new Exception("Specified epub file not found: ${fullPath}");
}
List<int> bytes = await targetFile.readAsBytes();
await test("Test Epub Ref", () async {
EpubBookRef epubRef = await EpubReader.openBook(bytes);
expect(epubRef.Author, equals("John S. Hittell"));
expect(epubRef.Title, equals("Hittel on Gold Mines and Mining"));
});
await test("Test Epub Read", () async {
EpubBook epubRef = await EpubReader.readBook(bytes);
expect(epubRef.Author, equals("John S. Hittell"));
expect(epubRef.Title, equals("Hittel on Gold Mines and Mining"));
});
}