]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/entry.t
Remove parent Object method
[chaz/p5-File-KDBX] / t / entry.t
index 988e71214c0ba441315798fb12bfcc2cfe24cb6a..8a6d5ebdb15b251c8bb2e96c4adb826ea293be18 100644 (file)
--- a/t/entry.t
+++ b/t/entry.t
@@ -30,7 +30,12 @@ subtest 'Construction' => sub {
     is $entry->username, 'bar', 'username is set correctly as the UserName string';
 
     cmp_deeply $entry, noclass({
-        auto_type => {},
+        auto_type => {
+            associations => [],
+            data_transfer_obfuscation => 0,
+            default_sequence => "{USERNAME}{TAB}{PASSWORD}{ENTER}",
+            enabled => bool(1),
+        },
         background_color => "",
         binaries => {},
         custom_data => {},
@@ -139,4 +144,29 @@ subtest 'Update UUID' => sub {
         or diag explain $entry2->url;
 };
 
+subtest 'Auto-type' => sub {
+    my $kdbx = File::KDBX->new;
+
+    my $entry = $kdbx->add_entry(title => 'Meh');
+    $entry->add_auto_type_association({
+        window              => 'Boring Store',
+        keystroke_sequence  => 'yeesh',
+    });
+    $entry->add_auto_type_association({
+        window              => 'Friendly Bank',
+        keystroke_sequence  => 'blah',
+    });
+
+    my $window_title = 'Friendly';
+    my $entries = $kdbx->entries(auto_type => 1)
+    ->filter(sub {
+        my ($ata) = grep { $_->{window} =~ /\Q$window_title\E/i } @{$_->auto_type_associations};
+        return [$_, $ata->{keystroke_sequence} || $_->auto_type_default_sequence] if $ata;
+    });
+    cmp_ok $entries->count, '==', 1, 'Find auto-type window association';
+
+    (undef, my $keys) = @{$entries->next};
+    is $keys, 'blah', 'Select the correct association';
+};
+
 done_testing;
This page took 0.018513 seconds and 4 git commands to generate.