mirror of
https://github.com/nasa/openmct.git
synced 2025-06-21 16:49:42 +00:00
Update test specs to use Jasmine 3 (#2089)
* Updated Karma and Jasmine versions * Added DOMObserver class. Supports promise-based testing of DOM changes Update asynchronous test specs to use promises or done() instead of waitsFor/runs * Modified ActionCapability to duplicate context object properties as own properties for better object equality comparisons * Global find + replace to fix syntax issues * Fixed various issues caused by non-deterministic runtime order of tests in Jasmine 3. Fixed issues caused by changes to determination of object equality * Addressed review comments * Resolved merge conflicts with master * Fixed style errors * Use spy.calls.count() instead of manually tracking
This commit is contained in:
committed by
Pete Richards
parent
013eba744d
commit
433dee0314
@ -46,7 +46,7 @@ define(
|
||||
["error", "warn", "info", "debug"]
|
||||
);
|
||||
|
||||
mockLoader.load.andReturn(Promise.resolve(Constructor));
|
||||
mockLoader.load.and.returnValue(Promise.resolve(Constructor));
|
||||
|
||||
resolver = new ExtensionResolver(mockLoader, mockLog);
|
||||
});
|
||||
@ -56,22 +56,9 @@ define(
|
||||
sources: "x",
|
||||
extensions: { tests: [{ implementation: "y/z.js" }] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
extension = bundle.getExtensions("tests")[0];
|
||||
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
return resolver.resolve(extension).then(function (result) {
|
||||
// Verify that the right file was requested
|
||||
expect(mockLoader.load).toHaveBeenCalledWith("w/x/y/z.js");
|
||||
|
||||
@ -90,26 +77,13 @@ define(
|
||||
implementation: "y/z.js"
|
||||
}] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
extension = bundle.getExtensions("tests")[0];
|
||||
|
||||
mockLoader.load.andReturn(Promise.reject(new Error("test error")));
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
mockLoader.load.and.returnValue(Promise.reject(new Error("test error")));
|
||||
|
||||
waitsFor(
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
return resolver.resolve(extension).then(function (result) {
|
||||
// Should have gotten a warning
|
||||
expect(mockLog.warn).toHaveBeenCalled();
|
||||
|
||||
// We should have resolved to the plain definition from above
|
||||
expect(typeof result).not.toEqual('function');
|
||||
expect(result.someOtherKey).toEqual("some other value");
|
||||
@ -121,25 +95,11 @@ define(
|
||||
sources: "x",
|
||||
extensions: { tests: [{ implementation: "y/z.js" }] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
extension = bundle.getExtensions("tests")[0];
|
||||
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
return resolver.resolve(extension).then(function (result) {
|
||||
// Verify that the right file was requested
|
||||
expect(mockLoader.load).toHaveBeenCalledWith("w/x/y/z.js");
|
||||
|
||||
// We should have resolved to the constructor from above
|
||||
expect(typeof result).toEqual('function');
|
||||
expect(result().someKey).toEqual("some value");
|
||||
|
Reference in New Issue
Block a user