Skip to content

Commit

Permalink
Merge branch 'master' of github.com:truevault/truevault-js-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Mitchell committed Aug 21, 2018
2 parents e592f42 + 0c976bb commit 5dd656b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ should.Assertion.add('matchSchema', function (schema) {
}
});

should.Assertion.add('containItemWithId', function(id) {
const doesContainItemWithId = this.obj.some(function(item) {
return item.id == id;
});

if (!doesContainItemWithId) {
const failureMessage = `Item with id ${id} not found in ${JSON.stringify(this.obj)}.`;
should.fail(this.obj, id, failureMessage);
}
});

const client = new TrueVault({apiKey: TEST_USER_API_KEY}, TEST_TRUEVAULT_HOST);

describe('TrueVaultClient', function () {
Expand Down Expand Up @@ -658,6 +669,9 @@ describe('TrueVaultClient', function () {
const docsInSchema = await client.listDocumentsInSchema(vaultId, newSchema.id, true);
docsInSchema.should.matchSchema(docListSchema);

// Ensure the document was actually added to the schema
docsInSchema.items.should.containItemWithId(indexedDoc.id);

const searchResultsNotFull = await client.searchDocuments(vaultId, {
schema_id: newSchema.id,
filter: {
Expand Down Expand Up @@ -725,6 +739,11 @@ describe('TrueVaultClient', function () {
required: ['documents', 'info']
});

const user = await client.createUser(uniqueString(), uniqueString());
const docWithOwner = await client.createDocument(vaultId, undefined, {foo: 'who'}, user.id);
docWithOwner.owner_id.should.equal(user.id);


const newFields = [];
const newName = uniqueString();
const updateSchemaResponse = await client.updateSchema(vaultId, newSchema.id, newName, newFields);
Expand Down

0 comments on commit 5dd656b

Please sign in to comment.