import { ItemBuffer } from "./item" ; import { Neovim , Buffer } from "neovim" ; import { BufferContainer } from "./container" ; import { CurrentTab , CurrentTabItem } from "./currentTab" ; import { TabRepository , Tab } from "../repository/tab" ; import { EventRegisterer } from "./event" ; import { BufferOptionStore } from "./option" ; describe ( "CurrentTab" , ( ) => { let vim ; let bufferContainer ; let itemBuffer ; let eventRegisterer ; let tabRepository ; let currentTab ; let bufferOptionStore ; let get ; let set ; let open ; let getOptionStore ; beforeEach ( ( ) => { const NeovimClass = jest . fn ( ( ) => ( { } ) ) as any ; vim = new NeovimClass ( ) ; set = jest . fn ( ) ; const BufferOptionStoreClass = jest . fn ( ( ) => ( { set : set , } ) ) as any ; bufferOptionStore = new BufferOptionStoreClass ( ) ; const BufferClass = jest . fn ( ( ) => ( { lines : [ ] , } ) ) as any ; const buffer = new BufferClass ( ) ; get = jest . fn ( ) . mockReturnValue ( buffer ) ; getOptionStore = jest . fn ( ) . mockReturnValue ( bufferOptionStore ) ; const BufferContainerClass = jest . fn ( ( ) => ( { get : get , getOptionStore : getOptionStore , } ) ) as any ; bufferContainer = new BufferContainerClass ( ) ; const ItemBufferClass = jest . fn ( ( ) => ( { } ) ) as any ; itemBuffer = new ItemBufferClass ( ) ; const EventRegistererClass = jest . fn ( ( ) => ( { } ) ) as any ; eventRegisterer = new EventRegistererClass ( ) ; open = jest . fn ( ) ; const TabRepositoryClass = jest . fn ( ( ) => ( { open : open , } ) ) as any ; tabRepository = new TabRepositoryClass ( ) ; currentTab = new CurrentTab ( vim , bufferContainer , itemBuffer , eventRegisterer , tabRepository ) ; } ) ; it ( "write does nothing when the buffer is empty" , async ( ) => { await currentTab . doAction ( "write" , 0 , 0 ) ; expect ( open ) . not . toHaveBeenCalled ( ) ; } ) ; it ( "write does nothing when the buffer is empty" , async ( ) => { const BufferClass = jest . fn ( ( ) => ( { lines : [ "title" , "url" ] , } ) ) as any ; const buffer = new BufferClass ( ) ; get = jest . fn ( ) . mockReturnValue ( buffer ) ; getOptionStore = jest . fn ( ) . mockReturnValue ( bufferOptionStore ) ; const BufferContainerClass = jest . fn ( ( ) => ( { get : get , getOptionStore : getOptionStore , } ) ) as any ; bufferContainer = new BufferContainerClass ( ) ; currentTab = new CurrentTab ( vim , bufferContainer , itemBuffer , eventRegisterer , tabRepository ) ; await currentTab . doAction ( "write" , 0 , 0 ) ; expect ( open ) . toHaveBeenCalledWith ( "url" ) ; } ) ; } ) ; describe ( "CurrentTabItem" , ( ) => { let item ; let tab ; beforeEach ( ( ) => { const TabClass = jest . fn ( ( ) => ( { title : "title" , url : "url" , } ) ) as any ; tab = new TabClass ( ) ; item = new CurrentTabItem ( tab ) ; } ) ; it ( "toString" , ( ) => { expect ( [ "title" , "url" ] ) . toEqual ( item . toStrings ( ) ) ; } ) ; it ( "value" , ( ) => { expect ( tab ) . toEqual ( item . value ) ; } ) ; } ) ;