openmct/platform/commonUI/browse/test/creation/CreateActionProviderSpec.js
Victor Woeltjen 48ff8c4c03 [Common UI] Continue filling in Browse specs
Continue filling in specs for scripts introduced as part
of bundle platform/commonUI/browse, which is responsible
for browse mode. WTD-574.
2014-11-25 20:26:37 -08:00

73 lines
2.3 KiB
JavaScript

/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
/**
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
*/
define(
["../../src/creation/CreateActionProvider"],
function (CreateActionProvider) {
"use strict";
describe("The create action provider", function () {
var mockTypeService,
mockDialogService,
mockCreationService,
provider;
function createMockType(name) {
var mockType = jasmine.createSpyObj(
"type" + name,
[
"getKey",
"getGlyph",
"getName",
"getDescription",
"getProperties",
"getInitialModel"
]
);
mockType.getName.andReturn(name);
return mockType;
}
beforeEach(function () {
mockTypeService = jasmine.createSpyObj(
"typeService",
[ "listTypes" ]
);
mockDialogService = jasmine.createSpyObj(
"dialogService",
[ "getUserInput" ]
);
mockCreationService = jasmine.createSpyObj(
"creationService",
[ "createObject" ]
);
mockTypeService.listTypes.andReturn(
[ "A", "B", "C" ].map(createMockType)
);
provider = new CreateActionProvider(
mockTypeService,
mockDialogService,
mockCreationService
);
});
it("exposes one create action per type", function () {
expect(provider.getActions({
key: "create",
domainObject: {}
}).length).toEqual(3);
});
it("exposes no non-create actions", function () {
expect(provider.getActions({
key: "somethingElse",
domainObject: {}
}).length).toEqual(0);
});
});
}
);