Skip to content

Commit

Permalink
chore(mediaviewer): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Oct 24, 2019
1 parent 9e874ba commit a91af2a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib/viewers/media/__tests__/MediaBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,30 @@ describe('lib/viewers/media/MediaBaseViewer', () => {
});
});

describe('refreshToken()', () => {
it('should return the same token if the tokenGenerator is a string', done => {
media.options.file = {
id: 'file_123',
};
media.options.tokenGenerator = 'new_token';
media.refreshToken().then(token => {
expect(token).to.equal('new_token');
done();
});
});

it('should return a new token if the tokenGenerator is a function', done => {
media.options.file = {
id: 'file_123',
};
media.options.tokenGenerator = id => Promise.resolve({ [id]: 'new_token' });
media.refreshToken().then(token => {
expect(token).to.equal('new_token');
done();
});
});
});

describe('errorHandler()', () => {
it('should handle download error if the viewer was not yet loaded', () => {
media.mediaUrl = 'foo';
Expand Down

0 comments on commit a91af2a

Please sign in to comment.