mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 15:10:50 +00:00
[Framework] Initial spec for bundle loader
Add first test case for bundle loader, WTD-518.
This commit is contained in:
parent
dac05d7841
commit
8e1eb2f22f
@ -55,7 +55,7 @@ define(
|
|||||||
bootstrapper.bootstrap(mockApp);
|
bootstrapper.bootstrap(mockApp);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// The tests.
|
// The tests.
|
||||||
|
|
||||||
it("waits for the provided document element to be ready", function () {
|
it("waits for the provided document element to be ready", function () {
|
||||||
|
@ -1,14 +1,63 @@
|
|||||||
/*global define,Promise,describe,it,expect,beforeEach*/
|
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,runs,jasmine*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BundleLoaderSpec. Created by vwoeltje on 11/6/14.
|
* BundleLoaderSpec. Created by vwoeltje on 11/6/14.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[],
|
["../../src/load/BundleLoader"],
|
||||||
function () {
|
function (BundleLoader) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("", function () {
|
describe("The bundle loader", function () {
|
||||||
|
var loader,
|
||||||
|
mockCallback,
|
||||||
|
mockHttp,
|
||||||
|
mockLog,
|
||||||
|
testBundles;
|
||||||
|
|
||||||
|
// Used to wait for then-chain resolution;
|
||||||
|
// native promises may not resolve synchronously,
|
||||||
|
// even when values are immediately available.
|
||||||
|
function mockCallbackResolved() {
|
||||||
|
return mockCallback.calls.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
testBundles = [
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
mockCallback = jasmine.createSpy("callback");
|
||||||
|
mockHttp = jasmine.createSpyObj("$http", ["get"]);
|
||||||
|
mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
||||||
|
loader = new BundleLoader(mockHttp, mockLog);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts a JSON file name and loads all bundles", function () {
|
||||||
|
// Set up; just return an empty set of bundles for this test
|
||||||
|
mockHttp.get.andReturn(Promise.resolve({data: []}));
|
||||||
|
|
||||||
|
// Call load bundles
|
||||||
|
loader.loadBundles("test-filename.json").then(mockCallback);
|
||||||
|
|
||||||
|
waitsFor(mockCallbackResolved, "then-chain resolution", 100);
|
||||||
|
|
||||||
|
runs(function () {
|
||||||
|
// Should have loaded the file via $http
|
||||||
|
expect(mockHttp.get).toHaveBeenCalledWith("test-filename.json");
|
||||||
|
|
||||||
|
// Should have gotten an empty bundle list
|
||||||
|
expect(mockCallback).toHaveBeenCalledWith([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user