Files
DefinitelyTyped/types/keychain/keychain-tests.ts
Lucas Santos fa8b4f5020 🤖 Merge PR #64842 Add type definitions for Keychain NPM module by @khaosdoctor
* Add type definitions for Keychain module

* Fix tests and headers

Signed-off-by: Lucas Santos <lucas.santos@klarna.com>

* Adds enums and other utility types

* Update types to use module.exports

Signed-off-by: Lucas Santos <lucas.santos@klarna.com>

* Add non TS export

Signed-off-by: Lucas Santos <lucas.santos@klarna.com>

* Replace enum with union types

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

* Remove console and dom

* linter fixes

---------

Signed-off-by: Lucas Santos <lucas.santos@klarna.com>
Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
2023-03-23 13:31:12 -07:00

75 lines
1.5 KiB
TypeScript

import keychain = require('keychain');
/**
* setPassword
*/
// @ts-expect-error
// Errors when doesn't have the required properties
keychain.setPassword({ account: 'some-account' }, err => {
if (err) {
err; // $ExpectType KeychainError
}
});
// @ts-expect-error
// Another error when missing options
keychain.setPassword({ account: 'some-account', password: 'some-pass' }, err => {
if (err) {
err; // $ExpectType KeychainError
}
});
// Should pass
keychain.setPassword({ account: 'some-account', password: 'some-pass', service: 'some-service' }, err => {
if (err) {
err; // $ExpectType KeychainError
}
});
/**
* getPassword
*/
// @ts-expect-error
// Errors when doesn't have the required properties
keychain.getPassword({ account: 'some-account' }, (err, password) => {
if (err) {
err; // $ExpectType KeychainError
return;
}
return password;
});
// Should pass
keychain.getPassword({ account: 'some-account', service: 'some-service' }, (err, password) => {
if (err) {
err; // $ExpectType KeychainError
return;
}
return password;
});
/**
* deletePassword
*/
// @ts-expect-error
// Errors when doesn't have the required properties
keychain.deletePassword({ account: 'some-account' }, err => {
if (err) {
err; // $ExpectType KeychainError
return;
}
});
// Should pass
keychain.getPassword({ account: 'some-account', service: 'some-service' }, err => {
if (err) {
err; // $ExpectType KeychainError
return;
}
});