mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[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:
parent
9b47e47e93
commit
a6fc9badfe
@ -5,6 +5,11 @@ define(
|
|||||||
function (CouchDocument) {
|
function (CouchDocument) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// JSLint doesn't like dangling _'s, but CouchDB uses these, so
|
||||||
|
// hide this behind variables.
|
||||||
|
var REV = "_rev",
|
||||||
|
ID = "_id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CouchPersistenceProvider reads and writes JSON documents
|
* The CouchPersistenceProvider reads and writes JSON documents
|
||||||
* (more specifically, domain object models) to/from a CouchDB
|
* (more specifically, domain object models) to/from a CouchDB
|
||||||
@ -50,10 +55,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a domain object model out of CouchDB's response
|
// Get a domain object model out of CouchDB's response
|
||||||
/*jslint nomen: true */ // Allow the _id and _rev that couch provides
|
|
||||||
function getModel(response) {
|
function getModel(response) {
|
||||||
if (response && response.model) {
|
if (response && response.model) {
|
||||||
revs[response._id] = response._rev;
|
revs[response[ID]] = response[REV];
|
||||||
return response.model;
|
return response.model;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -8,19 +8,22 @@ define(
|
|||||||
function (CouchDocument) {
|
function (CouchDocument) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Don't complain about _id or _rev; these are the CouchDB
|
// JSLint doesn't like dangling _'s, but CouchDB uses these, so
|
||||||
// fields that must be used.
|
// hide this behind variables.
|
||||||
/*jslint nomen: true */
|
var REV = "_rev",
|
||||||
|
ID = "_id",
|
||||||
|
DELETED = "_deleted";
|
||||||
|
|
||||||
describe("A couch document", function () {
|
describe("A couch document", function () {
|
||||||
it("includes an id", function () {
|
it("includes an id", function () {
|
||||||
expect(new CouchDocument("testId", {})._id)
|
expect(new CouchDocument("testId", {})[ID])
|
||||||
.toEqual("testId");
|
.toEqual("testId");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes a rev only when one is provided", function () {
|
it("includes a rev only when one is provided", function () {
|
||||||
expect(new CouchDocument("testId", {})._rev)
|
expect(new CouchDocument("testId", {})[REV])
|
||||||
.not.toBeDefined();
|
.not.toBeDefined();
|
||||||
expect(new CouchDocument("testId", {}, "testRev")._rev)
|
expect(new CouchDocument("testId", {}, "testRev")[REV])
|
||||||
.toEqual("testRev");
|
.toEqual("testRev");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,9 +34,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("marks documents as deleted only on request", function () {
|
it("marks documents as deleted only on request", function () {
|
||||||
expect(new CouchDocument("testId", {}, "testRev")._deleted)
|
expect(new CouchDocument("testId", {}, "testRev")[DELETED])
|
||||||
.not.toBeDefined();
|
.not.toBeDefined();
|
||||||
expect(new CouchDocument("testId", {}, "testRev", true)._deleted)
|
expect(new CouchDocument("testId", {}, "testRev", true)[DELETED])
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user