[Persistence] Hide dangling underscores

Hide dangling underscores; JSLint considers these a problem
and the command line build fails as a consequence when they
are present directly in the code, but CouchDB provides these
so we cannot avoid them entirely. So, hide them behind
variables and use []-style lookup.

Concludes transition work for the CouchDB persistence adapter,
WTD-537.
This commit is contained in:
Victor Woeltjen
2014-12-03 08:59:40 -08:00
parent 9b47e47e93
commit a6fc9badfe
2 changed files with 17 additions and 10 deletions

View File

@@ -8,19 +8,22 @@ define(
function (CouchDocument) {
"use strict";
// Don't complain about _id or _rev; these are the CouchDB
// fields that must be used.
/*jslint nomen: true */
// JSLint doesn't like dangling _'s, but CouchDB uses these, so
// hide this behind variables.
var REV = "_rev",
ID = "_id",
DELETED = "_deleted";
describe("A couch document", function () {
it("includes an id", function () {
expect(new CouchDocument("testId", {})._id)
expect(new CouchDocument("testId", {})[ID])
.toEqual("testId");
});
it("includes a rev only when one is provided", function () {
expect(new CouchDocument("testId", {})._rev)
expect(new CouchDocument("testId", {})[REV])
.not.toBeDefined();
expect(new CouchDocument("testId", {}, "testRev")._rev)
expect(new CouchDocument("testId", {}, "testRev")[REV])
.toEqual("testRev");
});
@@ -31,9 +34,9 @@ define(
});
it("marks documents as deleted only on request", function () {
expect(new CouchDocument("testId", {}, "testRev")._deleted)
expect(new CouchDocument("testId", {}, "testRev")[DELETED])
.not.toBeDefined();
expect(new CouchDocument("testId", {}, "testRev", true)._deleted)
expect(new CouchDocument("testId", {}, "testRev", true)[DELETED])
.toBe(true);
});
});