Skip to content

Commit

Permalink
DTM-10778 Loading mitt for tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronius committed Nov 9, 2017
1 parent a87fe5f commit 9aa9a5b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions coreModulePackages/loadScript/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@
var loadScript = require('./index');

describe('loadScript', function() {
// "about:" is used so we don't have to make any actual file requests during testing.
// Typically you would use a legit URL.
it('returns a promise', function() {
var promise = loadScript('./base/testIndex.js');
var promise = loadScript('https://unpkg.com/mitt/dist/mitt.umd.js');
expect(promise.then).toBeDefined();
expect(promise.catch).toBeDefined();
});

it('should fulfill with script element when the script is loaded', function(done) {
loadScript('./base/testIndex.js').then(function(script) {
loadScript('https://unpkg.com/mitt/dist/mitt.umd.js').then(function(script) {
expect(script).toEqual(jasmine.any(HTMLScriptElement));
done();
});
});

it('should reject with error when script fails to load', function(done) {
loadScript('./nonexistant.js').catch(function(error) {
loadScript('https://unpkg.com/mitt/dist/mitt-nonexistant.umd.js').catch(function(error) {
expect(error).toEqual(jasmine.any(Error));
expect(error.message).toBe('Failed to load script ./nonexistant.js');
expect(error.message)
.toBe('Failed to load script https://unpkg.com/mitt/dist/mitt-nonexistant.umd.js');
done();
});
});
Expand Down

0 comments on commit 9aa9a5b

Please sign in to comment.