"use strict"; define(["chai", "chai-jquery", "chai-backbone", "../../../../../../src/js/models/metadata/eml211/EMLOtherEntity"], function(chai, chaiJquery, chaiBackbone, EMLOtherEntity) { // Configure the Chai assertion library var should = chai.should(); var expect = chai.expect; // Pull in Jquery and Backbone-specific assertion libraries chai.use(chaiJquery); // exported from chai-jquery.js chai.use(chaiBackbone); // exported from chai-backbone.js describe("EMLOtherEntity Test Suite", function (){ var otherEntityXML; var emlOtherEntity; /* Setup */ before(function() { // If needed emlOtherEntity = new EMLOtherEntity({ objectDOM: $(OtherEntityUtil.getTestOtherEntityXML())[0] }, {parse: true}); }); /* Tear down */ after(function() { // If needed }); describe("The EMLOtherEntity object", function() { it('should exist', function() { expect(emlOtherEntity).to.exist; emlOtherEntity.should.exist; }); it('should have a type attribute of otherEntity', function() { emlOtherEntity.get("type").should.equal("otherEntity"); }); }); describe(".parse()", function() { it("should return an attribute object", function() { emlOtherEntity.attributes.should.be.an("object"); }); it("should return an xml id attribute", function() { emlOtherEntity.get("xmlID").should.be.a("string"); emlOtherEntity.get("xmlID").should.equal("entity.1.1"); }); it("should return an alternate identifier array", function() { emlOtherEntity.get("alternateIdentifier").should.be.an("array"); emlOtherEntity.get("alternateIdentifier")[0].should.equal("altid.1.1.png"); emlOtherEntity.get("alternateIdentifier")[1].should.equal("altid2.1.1.png"); }); it("should return an entity name", function() { emlOtherEntity.get("entityName").should.be.a("string"); emlOtherEntity.get("entityName").should.equal("temps.1.1.png"); }); it("should return an entity description", function() { emlOtherEntity.get("entityDescription").should.be.a("string"); emlOtherEntity.get("entityDescription").should.equal("Temperatures at sites"); }); it("should return an attribute list", function() { emlOtherEntity.get("attributeList").should.be.an("array"); emlOtherEntity.get("attributeList").length.should.equal(2); emlOtherEntity.get("attributeList")[0].should.be.an("object"); emlOtherEntity.get("attributeList")[1].should.be.an("object"); }); it("should return a nominal non-numeric site attribute", function() { var site = emlOtherEntity.get("attributeList")[0]; site.get("xmlID").should.equal("attr.1.1"); site.get("attributeName").should.equal("site"); site.get("attributeLabel")[0].should.equal("Site Code"); site.get("attributeDefinition").should.equal("The code given for each collection site"); site.get("storageType")[0].should.equal("string"); var mScale = site.get("measurementScale"); mScale.should.be.an("object"); mScale.get("measurementScale").should.equal("nominal"); var domain = mScale.get("nonNumericDomain"); domain.should.be.an("array"); domain[0].should.be.an("object"); domain[0].textDomain.should.be.an("object"); domain[0].textDomain.definition.should.equal("Any text"); domain[0].textDomain.pattern.should.be.an("array"); domain[0].textDomain.pattern[0].should.equal("*"); domain[0].textDomain.source.should.equal("Any source"); var temp = emlOtherEntity.get("attributeList")[1]; temp.get("xmlID").should.equal("attr.2.1"); temp.get("attributeName").should.equal("temp"); temp.get("attributeLabel")[0].should.equal("Temperature"); temp.get("attributeDefinition").should.equal("Air temperature at the site"); temp.get("storageType")[0].should.equal("float"); mScale = temp.get("measurementScale"); mScale.should.be.an("object"); mScale.get("measurementScale").should.equal("ratio"); mScale.get("unit").should.be.an("object"); mScale.get("unit").standardUnit.should.equal("celsius"); expect(mScale.get("precision")).to.be.null; mScale.get("numericDomain").should.be.an("object"); mScale.get("numericDomain").numberType.should.equal("float"); mScale.get("numericDomain").bounds.should.be.an("array"); mScale.get("numericDomain").bounds[0].should.be.an("object"); mScale.get("numericDomain").bounds[0].minimum.should.equal("-40.0"); mScale.get("numericDomain").bounds[0].maximum.should.equal("40.0"); }); it("should return an entity type", function() { emlOtherEntity.get("entityType").should.be.a("string"); emlOtherEntity.get("entityType").should.equal("Portable Network graphic image"); }); }); }); var OtherEntityUtil = { getTestOtherEntityXML: function() { var xml = []; xml.push( "\n", "\taltid.1.1.png\n", "\taltid2.1.1.png\n", "\ttemps.1.1.png\n", "\tTemperatures at sites\n", "\t\n", "\t\t\n", "\t\t\tsite\n", "\t\t\tSite Code\n", "\t\t\tThe code given for each collection site\n", "\t\t\tstring\n", "\t\t\t\n", "\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\t\t\t\n", "\t\t\t\t\t\t\tAny text\n", "\t\t\t\t\t\t\t*\n", "\t\t\t\t\t\t\tAny source\n", "\t\t\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\t\n", "\t\t\t\n", "\t\t\n", "\t\t\n", "\t\t\ttemp\n", "\t\t\tTemperature\n", "\t\t\tAir temperature at the site\n", "\t\t\tfloat\n", "\t\t\t\n", "\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\t\t\tcelsius\n", "\t\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\t\t\tfloat\n", "\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t-40.0\n", "\t\t\t\t\t\t\t40.0\n", "\t\t\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\t\n", "\t\t\t\n", "\t\t\n", "\t\n", "\tPortable Network graphic image\n", ""); return xml.join(""); } } });