Skip to content

Commit

Permalink
Merge pull request #196 from haiafara/depfu/update/yarn/jest-27.0.5
Browse files Browse the repository at this point in the history
Upgrade jest: 26.6.3 → 27.0.5 (major)
  • Loading branch information
janosrusiczki authored Jun 25, 2021
2 parents e61153e + cd16a94 commit fc69dac
Show file tree
Hide file tree
Showing 8 changed files with 764 additions and 1,006 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test": "jest"
},
"jest": {
"testEnvironment": "jsdom",
"moduleFileExtensions": [
"js",
"json",
Expand Down Expand Up @@ -83,7 +84,7 @@
"eslint-plugin-vue": "^7.11.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.2",
"jest": "^26.6.3",
"jest": "^27.0.5",
"mini-css-extract-plugin": "^1.6.0",
"rimraf": "^3.0.2",
"style-loader": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion specs/LightBox/LightBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('LightBox', () => {
let wrapper

beforeEach(() => {
jest.useFakeTimers()
jest.useFakeTimers('legacy')
wrapper = mount(LightBox, {
propsData: {
media: mediaWithNineImages,
Expand Down
4 changes: 2 additions & 2 deletions specs/LightBox/MediaArrayMultipleImages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('LightBox', () => {
let container

beforeEach(() => {
jest.useFakeTimers()
jest.useFakeTimers('legacy')
container = wrapper.findComponent({ ref: 'container' }).element
container.removeEventListener = jest.fn()
wrapper.destroy()
Expand All @@ -100,4 +100,4 @@ describe('LightBox', () => {
})
})
})
})
})
4 changes: 2 additions & 2 deletions specs/LightBox/MediaArrayOneImageWithoutType.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('LightBox', () => {

describe('mouse movement', () => {
beforeEach(() => {
jest.useFakeTimers()
jest.useFakeTimers('legacy')
})

describe('moving the mouse', () => {
Expand Down Expand Up @@ -162,4 +162,4 @@ describe('LightBox', () => {
})
})
})
})
})
42 changes: 42 additions & 0 deletions specs/LightBox/MediaArrayOneVideoWithAutoplay.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { mount } from '@vue/test-utils'
import LightBox from '@/LightBox'

import { mediaWithOneVideoWithAutoplay } from '../props'

describe('LightBox', () => {
describe('given one video with autoplay in the media array', () => {
let wrapper

const pauseStub = jest
.spyOn(window.HTMLMediaElement.prototype, 'pause')
.mockImplementation(() => {})
const playStub = jest
.spyOn(window.HTMLMediaElement.prototype, 'play')
.mockImplementation(() => {})

beforeEach(() => {
wrapper = mount(LightBox, {
propsData: {
media: mediaWithOneVideoWithAutoplay
}
})
})

afterEach(() => {
wrapper.destroy()
})

describe('showImage', () => {
test('calls play on the video', () => {
expect(playStub).toHaveBeenCalled()
})
})

describe('closeLightBox', () => {
test('calls pause on the video', async () => {
wrapper.vm.closeLightBox()
expect(pauseStub).toHaveBeenCalledTimes(1)
})
})
})
})
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { mount } from '@vue/test-utils'
import LightBox from '@/LightBox'

import { mediaWithOneVideo } from '../props'
import { mediaWithOneVideoWithoutAutoplay } from '../props'

describe('LightBox', () => {
describe('given one video in the media array', () => {
describe('given one video without autoplay in the media array', () => {
let wrapper

beforeEach(() => {
wrapper = mount(LightBox, {
propsData: {
media: mediaWithOneVideo
media: mediaWithOneVideoWithoutAutoplay
}
})
})
Expand Down
17 changes: 15 additions & 2 deletions specs/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mediaWithOneImageWithType = [
}
]

const mediaWithOneVideo = [
const mediaWithOneVideoWithoutAutoplay = [
{
type: 'video',
thumb: 'http://test/test-thumb.jpg',
Expand All @@ -25,6 +25,19 @@ const mediaWithOneVideo = [
}
]

const mediaWithOneVideoWithAutoplay = [
{
type: 'video',
thumb: 'http://test/test-thumb.jpg',
autoplay: true,
sources: [
{
src: 'http://test/test-video.mp4'
}
]
}
]

const mediaWithOneYoutube = [
{
type: 'youtube',
Expand Down Expand Up @@ -72,4 +85,4 @@ const mediaWithNineImages = [
}
]

export { mediaWithOneImageWithoutType, mediaWithOneImageWithType, mediaWithOneVideo, mediaWithOneYoutube, mediaWithNineImages }
export { mediaWithOneImageWithoutType, mediaWithOneImageWithType, mediaWithOneVideoWithoutAutoplay, mediaWithOneVideoWithAutoplay, mediaWithOneYoutube, mediaWithNineImages }
Loading

0 comments on commit fc69dac

Please sign in to comment.