2014-12-03 01:26:16 +00:00
|
|
|
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DomainObjectProviderSpec. Created by vwoeltje on 11/6/14.
|
|
|
|
*/
|
|
|
|
define(
|
|
|
|
["../src/CouchDocument"],
|
|
|
|
function (CouchDocument) {
|
|
|
|
"use strict";
|
|
|
|
|
2014-12-03 01:31:30 +00:00
|
|
|
// Don't complain about _id or _rev; these are the CouchDB
|
|
|
|
// fields that must be used.
|
|
|
|
/*jslint nomen: true */
|
2014-12-03 01:26:16 +00:00
|
|
|
describe("A couch document", function () {
|
2014-12-03 01:31:30 +00:00
|
|
|
it("includes an id", function () {
|
|
|
|
expect(new CouchDocument("testId", {})._id)
|
|
|
|
.toEqual("testId");
|
|
|
|
});
|
2014-12-03 01:26:16 +00:00
|
|
|
|
2014-12-03 01:31:30 +00:00
|
|
|
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);
|
|
|
|
});
|
2014-12-03 01:26:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|