mirror of https://gitee.com/bigwinds/arangodb
fixed jslint
This commit is contained in:
parent
969826af27
commit
fd944eee8e
|
@ -1,5 +1,5 @@
|
||||||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||||
/*global require, exports */
|
/*global require, exports, arguments */
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Graph functionality
|
/// @brief Graph functionality
|
||||||
|
@ -46,8 +46,7 @@ var collection = require("org/arangodb/arango-collection");
|
||||||
|
|
||||||
|
|
||||||
var stringToArray = function (x) {
|
var stringToArray = function (x) {
|
||||||
|
if (typeof(x) === "string") {
|
||||||
if (typeof x === "String") {
|
|
||||||
return [x];
|
return [x];
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
|
@ -60,14 +59,13 @@ var stringToArray = function (x) {
|
||||||
|
|
||||||
|
|
||||||
var isValidCollectionsParameter = function (x) {
|
var isValidCollectionsParameter = function (x) {
|
||||||
|
|
||||||
if (!x) {
|
if (!x) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Array.isArray(x) && x.length === 0) {
|
if (Array.isArray(x) && x.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (typeof x !== "String" && !Array.isArray(x)) {
|
if (typeof(x) !== "string" && !Array.isArray(x)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -90,7 +88,7 @@ var isValidCollectionsParameter = function (x) {
|
||||||
|
|
||||||
var _undirectedRelationDefinition = function (relationName, vertexCollections) {
|
var _undirectedRelationDefinition = function (relationName, vertexCollections) {
|
||||||
|
|
||||||
if (_undirectedRelationDefinition.arguments.length < 2) {
|
if (arguments.length < 2) {
|
||||||
throw "method _undirectedRelationDefinition expects 2 arguments";
|
throw "method _undirectedRelationDefinition expects 2 arguments";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +113,10 @@ var _undirectedRelationDefinition = function (relationName, vertexCollections) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
var _directedRelationDefinition = function (relationName, fromVertexCollections, toVertexCollections) {
|
var _directedRelationDefinition = function (
|
||||||
|
relationName, fromVertexCollections, toVertexCollections) {
|
||||||
|
|
||||||
if (_directedRelationDefinition.arguments.length < 3) {
|
if (arguments.length < 3) {
|
||||||
throw "method _undirectedRelationDefinition expects 3 arguments";
|
throw "method _undirectedRelationDefinition expects 3 arguments";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +140,19 @@ var _directedRelationDefinition = function (relationName, fromVertexCollections,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief create a list of edge definitions
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
var edgeDefinitions = function () {
|
||||||
|
|
||||||
|
return arguments;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,6 +162,7 @@ var _directedRelationDefinition = function (relationName, fromVertexCollections,
|
||||||
|
|
||||||
exports._undirectedRelationDefinition = _undirectedRelationDefinition;
|
exports._undirectedRelationDefinition = _undirectedRelationDefinition;
|
||||||
exports._directedRelationDefinition = _directedRelationDefinition;
|
exports._directedRelationDefinition = _directedRelationDefinition;
|
||||||
|
exports.edgeDefinitions = edgeDefinitions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,24 @@ function GeneralGraphCreationSuite() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
test_undirectedRelationDefinitionWithSingleCollection : function () {
|
||||||
|
var r;
|
||||||
|
|
||||||
|
try {
|
||||||
|
r = graph._undirectedRelationDefinition("relationName", "vertexC1");
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log("aaaaa", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(r, {
|
||||||
|
collection: "relationName",
|
||||||
|
from: ["vertexC1"],
|
||||||
|
to: ["vertexC1"]
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
test_undirectedRelationDefinitionWithMissingName : function () {
|
test_undirectedRelationDefinitionWithMissingName : function () {
|
||||||
var r, exception;
|
var r, exception;
|
||||||
try {
|
try {
|
||||||
|
@ -177,6 +195,32 @@ function GeneralGraphCreationSuite() {
|
||||||
|
|
||||||
assertEqual(exception, "<toVertexCollections> must be a not empty string or array");
|
assertEqual(exception, "<toVertexCollections> must be a not empty string or array");
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
testEdgeDefinitions : function () {
|
||||||
|
|
||||||
|
|
||||||
|
//with empty args
|
||||||
|
assertEqual(graph.edgeDefinitions(), []);
|
||||||
|
|
||||||
|
//with args
|
||||||
|
assertEqual(graph.edgeDefinitions(
|
||||||
|
graph._undirectedRelationDefinition("relationName", "vertexC1"),
|
||||||
|
graph._directedRelationDefinition("relationName",
|
||||||
|
["vertexC1", "vertexC2"], ["vertexC3", "vertexC4"])
|
||||||
|
), [
|
||||||
|
{
|
||||||
|
collection: "relationName",
|
||||||
|
from: ["vertexC1"],
|
||||||
|
to: ["vertexC1"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
collection: "relationName",
|
||||||
|
from: ["vertexC1", "vertexC2"],
|
||||||
|
to: ["vertexC3", "vertexC4"]
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue