Skip to content

Commit 5ed6152

Browse files
committed
#11 Add tests for video/audio tags on Jest
1 parent 41e5637 commit 5ed6152

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ typings/
6060
# next.js build output
6161
.next
6262

63-
/*.js
63+
index.js
6464
!babel.config.js
6565
package-lock.json

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
"watch": "babel -w src --out-dir . --ignore **/*.test.js"
3333
},
3434
"dependencies": {
35-
"fs-extra": "^7.0.1",
36-
"htmlparser2": "^4.1.0",
37-
"unist-util-visit": "^1.4.0"
35+
"fs-extra": "^9.0.1",
36+
"htmlparser2": "^5.0.0",
37+
"unist-util-visit": "^2.0.3"
3838
},
3939
"devDependencies": {
40-
"@babel/cli": "^7.4.3",
41-
"@babel/core": "^7.4.3",
42-
"@babel/preset-env": "^7.4.3",
43-
"cross-env": "^5.2.0",
44-
"jest": "^24.7.1",
45-
"remark": "^10.0.1",
46-
"rewire": "^4.0.1"
40+
"@babel/cli": "^7.11.6",
41+
"@babel/core": "^7.11.6",
42+
"@babel/preset-env": "^7.11.5",
43+
"cross-env": "^7.0.2",
44+
"jest": "^26.5.2",
45+
"remark": "^12.0.1",
46+
"rewire": "^5.0.0"
4747
}
4848
}

src/index.test.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,47 @@ describe('gatsby-remark-copy-relative-linked-files', () => {
241241
})
242242
})
243243

244+
describe('HTML', () => {
245+
test('<video>', async () => {
246+
const file = 'sample.mp4'
247+
const markdownAST = remark.parse(`<video src="${file}"></video>`)
248+
await Plugin({
249+
files: getFiles(file),
250+
markdownAST,
251+
markdownNode,
252+
getNode
253+
})
254+
255+
expect(FsExtra.copy).toHaveBeenCalled()
256+
})
257+
258+
test('<source>', async () => {
259+
const file = 'sample.mp4'
260+
const markdownAST = remark.parse(`<video><source src='sample.mp4' type="video/mp4"></video>`)
261+
await Plugin({
262+
files: getFiles(file),
263+
markdownAST,
264+
markdownNode,
265+
getNode
266+
})
267+
268+
expect(FsExtra.copy).toHaveBeenCalled()
269+
})
270+
271+
test('<audio>', async () => {
272+
const file = 'sample.mp3'
273+
const markdownAST = remark.parse(`<audio src="${file}"></video>`)
274+
await Plugin({
275+
files: getFiles(file),
276+
markdownAST,
277+
markdownNode,
278+
getNode
279+
})
280+
281+
expect(FsExtra.copy).toHaveBeenCalled()
282+
})
283+
})
284+
244285
describe('manifest', () => {
245286
test('One file', async () => {
246287
const path = 'sample.thumb.jpg'
@@ -316,7 +357,6 @@ describe('gatsby-remark-copy-relative-linked-files', () => {
316357
const isIgnore = Module.__get__('isIgnore')
317358

318359
test('Not igonre', () => {
319-
const extensions = ['.pdf']
320360
expect(isIgnore('sample.pdf')).toBeFalsy()
321361
})
322362

0 commit comments

Comments
 (0)