import { Deck , DeckOperations } from "../../src" ; import SlideNotFoundWithId from "../../src/errors/SlideNotFoundWithId" ; import { getSlideIds , makeSlides } from "./testUtils" ; describe ( "DeckOperations.deleteSlide" , ( ) => { it ( "throws SlideNotFoundWithId when no slide exists with the specified id" , ( ) => { const deck = { commonExcalidrawElements : [ ] , printableArea : { width : 100 , height : 100 } , slides : makeSlides ( [ "0" ] ) , } ; expect ( ( ) => DeckOperations . deleteSlide ( deck , "non-existing-id" ) ) . toThrow ( SlideNotFoundWithId ) ; } ) ; it ( "when the deck contains slides other than the to-be-deleted one, deletes the to-be-deleted slide from the deck" , ( ) => { const deck = { commonExcalidrawElements : [ ] , printableArea : { width : 100 , height : 100 } , slides : makeSlides ( [ "0" , "1" ] ) , } ; const newDeck = DeckOperations . deleteSlide ( deck , "0" ) ; expect ( getSlideIds ( newDeck ) ) . toEqual ( [ "1" ] ) ; } ) ; it ( "when the deck only contains the to-be-deleted slide, replaces it with an empty one" , ( ) => { const deck = { commonExcalidrawElements : [ ] , printableArea : { width : 100 , height : 100 } , slides : makeSlides ( [ "0" ] ) , } ; const newDeck = DeckOperations . deleteSlide ( deck , "0" ) ; expect ( getSlideIds ( newDeck ) ) . toHaveLength ( 1 ) ; } ) ; } ) ;