w3c-ccg / vc-api-issuer-test-suite

Test Suite for Issuers that implement the VC HTTP API

Home Page:https://w3c-ccg.github.io/vc-api-issuer-test-suite/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

credentialSubject maybe an object or an Array of objects

aljones15 opened this issue · comments

https://www.w3.org/TR/vc-data-model/#credential-subject

Currently our assertion on credentialSubject is that it is an object, but it can also be an Array (possibly because it is RDF).

Chai is a bit smart about this:

[].should.be.an('object') fails.

however typeof [] is object

So we need an assertion that ensures credentialSubject is either an object that is not an Array or is an Array that contains only objects.

This should probably be something like this:

if(Array.isArray(vc.credentialSubject)) {
  for(const subject of vc.credentialSubject) {
    subject.should.be.an('object');
  }
 return;
}
vc.credentialSubject.should.be.an('object');

That sounds like a new assertion which might be worth looking into.

closing as this has been addressed by PR 24