Skip to content

Commit

Permalink
Improve importing screenfull within test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Hattori committed Sep 10, 2019
1 parent c679e3f commit 91df4b8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/templates/bespoke.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/** @jest-environment jsdom */
import Marp from '@marp-team/marp-core'
import { Element as MarpitElement } from '@marp-team/marpit'
import { default as screenfull, Screenfull } from 'screenfull'
import { Key } from 'ts-keycode-enum'
import bespoke from '../../src/templates/bespoke/bespoke'

import screenfull = require('screenfull')

jest.mock('screenfull')
jest.useFakeTimers()

Expand Down Expand Up @@ -206,17 +205,17 @@ describe("Bespoke template's browser context", () => {

it('injects deck.fullscreen() to toggle fullscreen', async () => {
await deck.fullscreen()
expect((screenfull as screenfull.Screenfull).toggle).toBeCalled()
expect((screenfull as Screenfull).toggle).toBeCalled()
})

it('toggles fullscreen by hitting f key', () => {
keydown({ which: Key.F })
expect((screenfull as screenfull.Screenfull).toggle).toBeCalled()
expect((screenfull as Screenfull).toggle).toBeCalled()
})

it('toggles fullscreen by hitting F11 key', () => {
keydown({ which: Key.F11 })
expect((screenfull as screenfull.Screenfull).toggle).toBeCalled()
expect((screenfull as Screenfull).toggle).toBeCalled()
})
})

Expand Down Expand Up @@ -502,7 +501,7 @@ describe("Bespoke template's browser context", () => {
context('when browser does not support fullscreen', () => {
it('hides fullscreen button', () => {
jest
.spyOn(screenfull as screenfull.Screenfull, 'isEnabled', 'get')
.spyOn(screenfull as Screenfull, 'isEnabled', 'get')
.mockImplementation(() => false)

bespoke()
Expand Down

0 comments on commit 91df4b8

Please sign in to comment.