-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Only check flash for SWF files (#747)
- Loading branch information
Showing
3 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ dist | |
src/i18n/json | ||
jsconfig.json | ||
functional-tests/output | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,47 @@ | ||
/* eslint-disable no-unused-expressions */ | ||
import SWFLoader from '../SWFLoader'; | ||
import AssetLoader from '../../AssetLoader'; | ||
import Browser from '../../../Browser'; | ||
import PreviewError from '../../../PreviewError'; | ||
|
||
const sandbox = sinon.sandbox.create(); | ||
let file; | ||
|
||
describe('lib/viewers/SWFLoader', () => { | ||
afterEach(() => { | ||
sandbox.verifyAndRestore(); | ||
}); | ||
|
||
describe('determineViewer()', () => { | ||
beforeEach(() => { | ||
file = { | ||
extension: 'swf', | ||
representations: { | ||
entries: [ | ||
{ | ||
representation: 'ORIGINAL' | ||
} | ||
] | ||
} | ||
}; | ||
}); | ||
|
||
it('should throw a preview error if flash is not supported', () => { | ||
sandbox.stub(Browser, 'hasFlash').returns(false); | ||
expect(() => SWFLoader.determineViewer()).to.throw(PreviewError); | ||
expect(() => SWFLoader.determineViewer(file)).to.throw(PreviewError); | ||
}); | ||
|
||
it('should call the superclass determineViewer if flash is suported', () => { | ||
sandbox.stub(Browser, 'hasFlash').returns(true); | ||
const stub = sandbox.stub(AssetLoader.prototype, 'determineViewer'); | ||
SWFLoader.determineViewer(); | ||
expect(stub).to.have.been.called; // eslint-disable-line no-unused-expressions | ||
SWFLoader.determineViewer(file); | ||
expect(stub).to.be.called; | ||
}); | ||
|
||
it('should not check Flash if file is not SWF', () => { | ||
sandbox.stub(Browser, 'hasFlash'); | ||
file.extension = 'jpg'; | ||
expect(Browser.hasFlash).to.not.be.called; | ||
}); | ||
}); | ||
}); |