diff --git a/.vscode/launch.json b/.vscode/launch.json index 31597a2..7df09d7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { @@ -9,6 +6,8 @@ "request": "launch", "name": "Jest (Current File)", "program": "${workspaceFolder}/node_modules/.bin/jest", + "runtimeExecutable": "~/.config/nvm/13.11.0/bin/node", + "console": "integratedTerminal", "args": [ "${relativeFile}", "--coverage", diff --git a/src/kittik-deck/spec/Deck.spec.ts b/src/kittik-deck/spec/Deck.spec.ts index 3bcac00..2fb6ad8 100644 --- a/src/kittik-deck/spec/Deck.spec.ts +++ b/src/kittik-deck/spec/Deck.spec.ts @@ -3,51 +3,59 @@ import { Deck, DeckDeclaration } from '../src/Deck'; const DECK_DECLARATION: DeckDeclaration = { cursor: Canvas.create(), - shapes: [{ - name: 'Global Shape', - type: 'Text', - options: { - text: 'Hello, World!' + shapes: [ + { + name: 'Global Shape', + type: 'Text', + options: { + text: 'Hello, World!' + } } - }], - animations: [{ - name: 'Global Animation', - type: 'Print', - options: { - duration: 1 + ], + animations: [ + { + name: 'Global Animation', + type: 'Print', + options: { + duration: 1 + } } - }], - slides: [{ - shapes: [], - order: [{ - shape: 'Global Shape', - animations: [ - 'Global Animation' - ] - }] - }] + ], + slides: [ + { + shapes: [], + order: [{ + shape: 'Global Shape', + animations: [ + 'Global Animation' + ] + }] + }, + { + shapes: [], + order: [{ + shape: 'Global Shape', + animations: [ + 'Global Animation' + ] + }] + } + ] }; -describe.skip('Deck', () => { - it('Should properly render next slide', async () => { +describe('Deck', () => { + it('Should properly render next and previous slides', async () => { const deck = new Deck(DECK_DECLARATION); const renderSpy = jest.spyOn(deck, 'renderSlide').mockResolvedValue(); await deck.nextSlide(); - deck.exit(); - - expect(renderSpy).toBeCalledTimes(1); - expect(renderSpy).toBeCalledWith(0); - }); - - it('Should properly render previous slide', async () => { - const deck = new Deck(DECK_DECLARATION); - const renderSpy = jest.spyOn(deck, 'renderSlide').mockResolvedValue(); - + await deck.nextSlide(); + await deck.previousSlide(); await deck.previousSlide(); deck.exit(); - expect(renderSpy).toBeCalledTimes(1); + expect(renderSpy).toBeCalledTimes(2); expect(renderSpy).toBeCalledWith(0); + expect(renderSpy).toBeCalledWith(1); }); }); diff --git a/src/kittik-deck/src/Deck.ts b/src/kittik-deck/src/Deck.ts index 3434da2..bad4294 100644 --- a/src/kittik-deck/src/Deck.ts +++ b/src/kittik-deck/src/Deck.ts @@ -78,7 +78,8 @@ export class Deck { } exit(): void { + process.stdin.pause(); + this.cursor.showCursor().restoreScreen().reset(); - process.stdin.removeAllListeners(); } }