Files
English/kouyu_english/test/course_content_test.dart

60 lines
1.3 KiB
Dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:kouyu_english/core/courses/courses.dart';
import '../tool/courses/course_validator.dart';
void main() {
test('tokenize expands contractions and skips digits', () {
expect(tokenize("I'm Tom. Can't pay 15 dollars at 7 a.m.; let's go"), [
'i',
'am',
'tom',
'can',
'not',
'pay',
'dollars',
'at',
'am',
'let',
'us',
'go',
]);
});
test('match groups use AND across groups and OR inside a group', () {
expect(
matchesRule("Sorry, I don't understand.", [
['do not understand'],
]),
isTrue,
);
expect(
matchesRule('twelvee', [
['twelve'],
]),
isFalse,
);
expect(
matchesRule('What is this word?', [
['what does', 'what is'],
['mean'],
]),
isFalse,
);
});
test('course packs pass validation', () {
final report = CourseValidator(
projectRoot: Directory.current,
a0Texts: [
for (final item in a0CoreItems.values)
item.replaceAll(RegExp(r'\[[^\]]*\]'), ''),
for (final sentence in coreDictationSentences.values) sentence.sentence,
],
).validate();
expect(report.errors.map((issue) => '$issue'), isEmpty);
});
}