Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/del_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("jsonld.del", function() {
db.jsonld.del(manu, function() {
db.get({}, function(err, triples) {
// getting the full db
expect(triples).to.have.property("length", 0);
expect(triples).to.be.empty;
done();
});
});
Expand All @@ -38,7 +38,7 @@ describe("jsonld.del", function() {
db.jsonld.del(tesla, function() {
db.get({}, function(err, triples) {
// getting the full db
expect(triples).to.have.property("length", 0);
expect(triples).to.be.empty;
done();
});
});
Expand All @@ -50,7 +50,7 @@ describe("jsonld.del", function() {
db.jsonld.del(manu["@id"], function() {
db.get({}, function(err, triples) {
// getting the full db
expect(triples).to.have.property("length", 0);
expect(triples).to.be.empty;
done();
});
});
Expand All @@ -63,7 +63,7 @@ describe("jsonld.del", function() {
db.jsonld.del(tesla, function() {
db.get({}, function(err, triples) {
// getting the full db
expect(triples).to.have.property("length", 2);
expect(triples).to.have.length(2);
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/get_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("jsonld.get", function() {

it("should load it", function(done) {
db.jsonld.get(manu["@id"], { "@context": manu["@context"] }, function(err, obj) {
expect(obj).to.be.eql(manu);
expect(obj).to.eql(manu);
done();
});
});
Expand Down
34 changes: 19 additions & 15 deletions test/put_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("jsonld.put", function() {
, predicate: "http://xmlns.com/foaf/0.1/name"
, object: "Manu Sporny"
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
Expand All @@ -38,7 +38,7 @@ describe("jsonld.put", function() {
db.get({
subject: "http://manu.sporny.org#person"
}, function(err, triples) {
expect(triples).to.have.property("length", 2);
expect(triples).to.have.length(2);
done();
});
});
Expand All @@ -49,7 +49,7 @@ describe("jsonld.put", function() {
db.get({
subject: "http://manu.sporny.org#person"
}, function(err, triples) {
expect(triples).to.have.property("length", 2);
expect(triples).to.have.length(2);
done();
});
});
Expand All @@ -63,32 +63,36 @@ describe("jsonld.put", function() {
, predicate: "http://xmlns.com/foaf/0.1/name"
, object: "Manu Sporny"
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
});

it("should generate an @id for unknown objects", function(done) {
delete manu["@id"];
var baseString = "http://levelgraph.org/tests/";
var baseRegEx = /^http:\/\/levelgraph.org\/tests\//;

db.jsonld.put(manu, { base: "http://levelgraph.org/tests/" }, function() {
db.jsonld.put(manu, { base: baseString }, function() {
db.join({
subject: db.v("subject")
, predicate: "http://xmlns.com/foaf/0.1/name"
, object: "Manu Sporny"
}, function(err, contexts) {
expect(contexts[0].subject.indexOf("http://levelgraph.org/tests/")).to.equal(0);
expect(contexts[0].subject).to.match(baseRegEx);
done();
});
});
});

it("should pass the generated @id to callback", function(done) {
delete manu["@id"];
var baseString = "http://levelgraph.org/tests/";
var baseRegEx = /^http:\/\/levelgraph.org\/tests\//;

db.jsonld.put(manu, { base: "http://levelgraph.org/tests/" }, function(err, obj) {
expect(obj["@id"].indexOf("http://levelgraph.org/tests/")).to.equal(0);
db.jsonld.put(manu, { base: baseString }, function(err, obj) {
expect(obj["@id"]).to.match(baseRegEx);
done();
});
});
Expand All @@ -100,7 +104,7 @@ describe("jsonld.put", function() {
, predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
, object: "http://purl.org/goodrelations/v1#Offering"
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
Expand All @@ -115,7 +119,7 @@ describe("jsonld.put", function() {
, predicate: "http://xmlns.com/foaf/0.1/homepage"
, object: "http://another/website"
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
Expand All @@ -133,7 +137,7 @@ describe("jsonld.put", function() {
, predicate: "http://xmlns.com/foaf/0.1/age"
, object: 42
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
Expand All @@ -149,7 +153,7 @@ describe("jsonld.put", function() {
subject: "http://manu.sporny.org#person"
, predicate: "http://xmlns.com/foaf/0.1/homepage"
}, function(err, triples) {
expect(triples).to.have.property("length", 0);
expect(triples).to.be.empty;
done();
});
});
Expand All @@ -165,7 +169,7 @@ describe("jsonld.put", function() {
subject: "http://example.org/cars/for-sale#tesla"
, predicate: "http://purl.org/goodrelations/v1#"
}, function(err, triples) {
expect(triples).to.have.property("length", 0);
expect(triples).to.be.empty;
done();
});
});
Expand Down Expand Up @@ -194,7 +198,7 @@ describe("jsonld.put with default base", function() {
, predicate: "http://xmlns.com/foaf/0.1/name"
, object: "Manu Sporny"
}, function(err, triples) {
expect(triples).to.have.property("length", 1);
expect(triples).to.have.length(1);
done();
});
});
Expand Down Expand Up @@ -237,7 +241,7 @@ describe("jsonld.put with default base", function() {

db.jsonld.put(nested, function() {
db.get({}, function(err, triples) {
expect(triples).to.have.property("length", 5);
expect(triples).to.have.length(5);
done();
});
});
Expand Down