Skip to content

Commit

Permalink
Added a test for the c_comment_annotation_camera example manifest
Browse files Browse the repository at this point in the history
demonstrating the TextualBody class
  • Loading branch information
vincentmarchetti committed Aug 12, 2024
1 parent a607494 commit f2ac4cc
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ function run_iiif3d_tests(){
importTest('orthographic_camera_lookat_point', './tests_3d/2_cameras/orthographic_camera_lookat_point.js');
});

describe("xx_whale_comments" , function(){
importTest('c_comments_with_camera', './tests_3d/xx_whale_comments/c_comment_annotation_camera.js');

});
}


Expand Down
72 changes: 72 additions & 0 deletions test/tests_3d/xx_whale_comments/c_comment_annotation_camera.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var expect = require('chai').expect;
var should = require('chai').should();
var manifesto = require('../../../dist-commonjs/');
//var manifests_3d = require('../fixtures/manifests_3d');


var ExternalResourceType = require('@iiif/vocabulary/dist-commonjs/').ExternalResourceType;
var MediaType = require('@iiif/vocabulary/dist-commonjs/').MediaType;


let manifest, scene , annotations, body;

let manifest_url = {
local: "",
remote : "https://raw.githubusercontent.com/IIIF/3d/whale_anno/manifests/xx_whale_comments/c_comment_annotation_camera.json"
}.remote;

describe('c_comment_annotation_camera', function() {

it('loads successfully', function(done) {
manifesto.loadManifest(manifest_url).then(function(data) {
manifest = manifesto.parseManifest(data);
done();
});
});



it('has a scene', function() {
sequence = manifest.getSequenceByIndex(0);
scene = sequence.getScenes()[0];
expect(scene).to.exist;
expect(scene.isScene()).to.be.ok;
});


it('with 4 annotation', function(){
var annotations = scene.getContent();
expect(annotations.length).to.equal(4);
});

it('annotation 3 is TextualBody', function(){
var annotations = scene.getContent();
expect(annotations.length).to.equal(4);
var textBody = annotations[2].getBody()[0];
expect(textBody.isTextualBody).to.equal(true);
expect(textBody.Value).to.exist;
});

it('annotation 4 is a camera', function(){
var annotations = scene.getContent();
expect(annotations.length).to.equal(4);
var body = annotations[3].getBody()[0];
expect(body).to.exist;
var camera = body.isSpecificResource?body.Source:body;


expect(camera.isCamera).to.equal(true);
expect(camera.isPerspectiveCamera).to.equal(true);
});

it('all annotation have a body', function(){
var annotations = scene.getContent();
for (var i = 0; i < annotations.length; ++i){
var custom_message = "annotation " + i + " body fails exist";
var body = annotations[i].getBody()[0];
expect(body, custom_message).to.exist;
}
});


});

0 comments on commit f2ac4cc

Please sign in to comment.