[Core] Specs for model service components

Fill in specs for model service components, part of
bundle platform/core; WTD-573.
This commit is contained in:
Victor Woeltjen
2014-11-21 17:25:10 -08:00
parent 99f9203e71
commit c34c16e51c
5 changed files with 158 additions and 3 deletions

View File

@@ -9,6 +9,57 @@ define(
"use strict";
describe("The persisted model provider", function () {
var mockQ,
mockPersistenceService,
SPACE = "some space",
provider;
function mockPromise(value) {
return {
then: function (callback) {
return mockPromise(callback(value));
},
testValue: value
};
}
function mockAll(mockPromises) {
return mockPromise(mockPromises.map(function (p) {
return p.testValue;
}));
}
beforeEach(function () {
mockQ = { when: mockPromise, all: mockAll };
mockPersistenceService = {
readObject: function (space, id) {
return mockPromise({
space: space,
id: id
});
}
};
provider = new PersistedModelProvider(
mockPersistenceService,
mockQ,
SPACE
);
});
it("reads object models from persistence", function () {
var models;
provider.getModels(["a", "x", "zz"]).then(function (m) {
models = m;
});
expect(models).toEqual({
a: { space: SPACE, id: "a" },
x: { space: SPACE, id: "x" },
zz: { space: SPACE, id: "zz" }
});
});
});
}