@@ -5,20 +5,14 @@ import {
55 getDefaultAccountOverrideAccountId ,
66 getDefaultAccountOverrideFilePath ,
77} from '../defaultAccountOverride' ;
8- import * as config from '../index' ;
98import { PersonalAccessKeyConfigAccount } from '../../types/Accounts' ;
109import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from '../../constants/auth' ;
1110
1211vi . mock ( 'fs-extra' ) ;
1312vi . mock ( 'findup-sync' ) ;
14- vi . mock ( '../index' ) ;
1513
1614const mockFs = fs as Mocked < typeof fs > ;
1715const mockFindup = findup as MockedFunction < typeof findup > ;
18- const mockGetAllConfigAccounts =
19- config . getAllConfigAccounts as MockedFunction <
20- typeof config . getAllConfigAccounts
21- > ;
2216
2317const PAK_ACCOUNT : PersonalAccessKeyConfigAccount = {
2418 name : 'test-account' ,
@@ -36,27 +30,25 @@ describe('defaultAccountOverride', () => {
3630 describe ( 'getDefaultAccountOverrideAccountId()' , ( ) => {
3731 it ( 'returns null when override file does not exist' , ( ) => {
3832 mockFindup . mockReturnValueOnce ( null ) ;
39- expect ( getDefaultAccountOverrideAccountId ( ) ) . toBeNull ( ) ;
33+ expect ( getDefaultAccountOverrideAccountId ( [ PAK_ACCOUNT ] ) ) . toBeNull ( ) ;
4034 } ) ;
4135
4236 it ( 'throws an error when override file exists but is not a number' , ( ) => {
4337 mockFindup . mockReturnValueOnce ( '.hsaccount' ) ;
4438 mockFs . readFileSync . mockReturnValueOnce ( 'string' ) ;
45- expect ( ( ) => getDefaultAccountOverrideAccountId ( ) ) . toThrow ( ) ;
39+ expect ( ( ) => getDefaultAccountOverrideAccountId ( [ PAK_ACCOUNT ] ) ) . toThrow ( ) ;
4640 } ) ;
4741
4842 it ( 'throws an error when account specified in override file does not exist in config' , ( ) => {
4943 mockFindup . mockReturnValueOnce ( '.hsaccount' ) ;
5044 mockFs . readFileSync . mockReturnValueOnce ( '234' ) ;
51- mockGetAllConfigAccounts . mockReturnValueOnce ( [ PAK_ACCOUNT ] ) ;
52- expect ( ( ) => getDefaultAccountOverrideAccountId ( ) ) . toThrow ( ) ;
45+ expect ( ( ) => getDefaultAccountOverrideAccountId ( [ PAK_ACCOUNT ] ) ) . toThrow ( ) ;
5346 } ) ;
5447
5548 it ( 'returns the account ID when an account with that ID exists in config' , ( ) => {
5649 mockFindup . mockReturnValueOnce ( '.hsaccount' ) ;
5750 mockFs . readFileSync . mockReturnValueOnce ( '123' ) ;
58- mockGetAllConfigAccounts . mockReturnValueOnce ( [ PAK_ACCOUNT ] ) ;
59- expect ( getDefaultAccountOverrideAccountId ( ) ) . toBe ( 123 ) ;
51+ expect ( getDefaultAccountOverrideAccountId ( [ PAK_ACCOUNT ] ) ) . toBe ( 123 ) ;
6052 } ) ;
6153 } ) ;
6254
0 commit comments