mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
[Persistence] Spec for CouchDocument
Fill in spec for CouchDocument, which wraps domain object models with suitable metadata for persistence. WTD-537.
This commit is contained in:
parent
aef6f44cb5
commit
bb719a137a
@ -8,8 +8,34 @@ define(
|
||||
function (CouchDocument) {
|
||||
"use strict";
|
||||
|
||||
// Don't complain about _id or _rev; these are the CouchDB
|
||||
// fields that must be used.
|
||||
/*jslint nomen: true */
|
||||
describe("A couch document", function () {
|
||||
it("includes an id", function () {
|
||||
expect(new CouchDocument("testId", {})._id)
|
||||
.toEqual("testId");
|
||||
});
|
||||
|
||||
it("includes a rev only when one is provided", function () {
|
||||
expect(new CouchDocument("testId", {})._rev)
|
||||
.not.toBeDefined();
|
||||
expect(new CouchDocument("testId", {}, "testRev")._rev)
|
||||
.toEqual("testRev");
|
||||
});
|
||||
|
||||
it("includes the provided model", function () {
|
||||
var model = { someKey: "some value" };
|
||||
expect(new CouchDocument("testId", model).model)
|
||||
.toEqual(model);
|
||||
});
|
||||
|
||||
it("marks documents as deleted only on request", function () {
|
||||
expect(new CouchDocument("testId", {}, "testRev")._deleted)
|
||||
.not.toBeDefined();
|
||||
expect(new CouchDocument("testId", {}, "testRev", true)._deleted)
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user