Ensuring the next character on learning finished is always a review one.
This commit is contained in:
parent
cf9aaf3541
commit
54fc631fa8
@ -9,7 +9,7 @@ use Moo;
|
||||
|
||||
use Crypt::URandom qw( urandom );
|
||||
|
||||
sub get($min = 1, $max = 100) {
|
||||
sub get($class, $min = 1, $max = 100) {
|
||||
my $rng = urandom(4);
|
||||
$rng = unpack 'L', $rng;
|
||||
$rng = ($rng % $max) + $min;
|
||||
|
@ -5,7 +5,7 @@ use v5.38.2;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::Most tests => 2;
|
||||
use Test::Most tests => 3;
|
||||
use Test::MockModule;
|
||||
use Path::Tiny;
|
||||
|
||||
@ -14,6 +14,7 @@ use File::Basename;
|
||||
use lib dirname(dirname(__FILE__)).'/lib';
|
||||
|
||||
use JapaChar::DB;
|
||||
use JapaChar::Random;
|
||||
|
||||
BEGIN {
|
||||
use_ok 'JapaChar::Characters';
|
||||
@ -24,5 +25,16 @@ BEGIN {
|
||||
$mock_db->mock(_db_path => sub {
|
||||
return path(__FILE__)->parent->child('all-learned-basic-characters.db');
|
||||
});
|
||||
my $mock_random = Test::MockModule->new('JapaChar::Random');
|
||||
$mock_random->mock(get => sub {
|
||||
return 100;
|
||||
});
|
||||
my $mock_characters = Test::MockModule->new('JapaChar::Characters');
|
||||
my $called_next_review_char = 0;
|
||||
$mock_characters->mock(_next_review_char => sub {
|
||||
$called_next_review_char = 1;
|
||||
return $mock_characters->original('_next_review_char')->(@_);
|
||||
});
|
||||
ok defined(JapaChar::Characters->new->next_char), 'The next char is defined.';
|
||||
ok $called_next_review_char, 'The next char is a review.';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user