jest . mock ( '../crawler_single_domain_logic' , ( ) => ( { CrawlerSingleDomainLogic : { actions : { updateEntryPoints : jest . fn ( ) , } , } , } ) ) ; import { LogicMounter , mockFlashMessageHelpers } from '../../../../__mocks__/kea_logic' ; import { CrawlerSingleDomainLogic } from '../crawler_single_domain_logic' ; import { EntryPointsTableLogic } from './entry_points_table_logic' ; describe ( 'EntryPointsTableLogic' , ( ) => { const { mount } = new LogicMounter ( EntryPointsTableLogic ) ; const { clearFlashMessages , flashSuccessToast } = mockFlashMessageHelpers ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; } ) ; describe ( 'listeners' , ( ) => { describe ( 'onAdd' , ( ) => { it ( 'should update the entry points for the current domain, and clear flash messages' , ( ) => { const entryThatWasAdded = { id : '2' , value : 'bar' } ; const updatedEntries = [ { id : '1' , value : 'foo' } , { id : '2' , value : 'bar' } , ] ; mount ( ) ; EntryPointsTableLogic . actions . onAdd ( entryThatWasAdded , updatedEntries ) ; expect ( CrawlerSingleDomainLogic . actions . updateEntryPoints ) . toHaveBeenCalledWith ( updatedEntries ) ; expect ( clearFlashMessages ) . toHaveBeenCalled ( ) ; } ) ; } ) ; describe ( 'onDelete' , ( ) => { it ( 'should update the entry points for the current domain, clear flash messages, and show a success toast' , ( ) => { const entryThatWasDeleted = { id : '2' , value : 'bar' } ; const updatedEntries = [ { id : '1' , value : 'foo' } ] ; mount ( ) ; EntryPointsTableLogic . actions . onDelete ( entryThatWasDeleted , updatedEntries ) ; expect ( CrawlerSingleDomainLogic . actions . updateEntryPoints ) . toHaveBeenCalledWith ( updatedEntries ) ; expect ( clearFlashMessages ) . toHaveBeenCalled ( ) ; expect ( flashSuccessToast ) . toHaveBeenCalled ( ) ; } ) ; } ) ; describe ( 'onUpdate' , ( ) => { it ( 'should update the entry points for the current domain, clear flash messages, and show a success toast' , ( ) => { const entryThatWasUpdated = { id : '2' , value : 'baz' } ; const updatedEntries = [ { id : '1' , value : 'foo' } , { id : '2' , value : 'baz' } , ] ; mount ( ) ; EntryPointsTableLogic . actions . onUpdate ( entryThatWasUpdated , updatedEntries ) ; expect ( CrawlerSingleDomainLogic . actions . updateEntryPoints ) . toHaveBeenCalledWith ( updatedEntries ) ; expect ( clearFlashMessages ) . toHaveBeenCalled ( ) ; } ) ; } ) ; } ) ; } ) ;