Skip to content

Commit f76fcae

Browse files
authored
Merge pull request #15 from github/bestra/add-is-video
2 parents ac7dc52 + 79895d6 commit f76fcae

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/attachment.ts

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export default class Attachment {
4343
return ['image/gif', 'image/png', 'image/jpg', 'image/jpeg'].indexOf(this.file.type) > -1
4444
}
4545

46+
isVideo(): boolean {
47+
return ['video/mp4', 'video/quicktime'].indexOf(this.file.type) > -1
48+
}
49+
4650
saving(percent: number): void {
4751
if (this.state !== 'pending' && this.state !== 'saving') {
4852
throw new Error(`Unexpected transition from ${this.state} to saving`)

test/test.js

+18
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ describe('file-attachment', function () {
3939
assert(attachment.isImage())
4040
})
4141

42+
it('detects mp4 video types', function () {
43+
const file = new File(['hubot'], 'test.mp4', {type: 'video/mp4'})
44+
const attachment = new Attachment(file)
45+
assert(attachment.isVideo())
46+
})
47+
48+
it('detects quicktime video types', function () {
49+
const file = new File(['hubot'], 'test.mov', {type: 'video/quicktime'})
50+
const attachment = new Attachment(file)
51+
assert(attachment.isVideo())
52+
})
53+
54+
it('detects non video types', function () {
55+
const file = new File(['hubot'], 'test.txt', {type: 'text/plain'})
56+
const attachment = new Attachment(file)
57+
assert(!attachment.isVideo())
58+
})
59+
4260
it('transitions through save states', function () {
4361
const file = new File(['hubot'], 'test.txt', {type: 'text/plain'})
4462
const attachment = new Attachment(file)

0 commit comments

Comments
 (0)