manifesto.js
Advanced tools
Comparing version
@@ -138,2 +138,7 @@ "use strict"; | ||
} | ||
else if (rawVal["@value"]) { | ||
// Single IIIF v2 property value without language | ||
var parsed = LocalizedValue.parseV2Value(rawVal); | ||
return new PropertyValue(parsed !== null ? [parsed] : [], defaultLocale); | ||
} | ||
else { | ||
@@ -140,0 +145,0 @@ // IIIF v3 property value |
@@ -136,2 +136,7 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
else if (rawVal["@value"]) { | ||
// Single IIIF v2 property value without language | ||
var parsed = LocalizedValue.parseV2Value(rawVal); | ||
return new PropertyValue(parsed !== null ? [parsed] : [], defaultLocale); | ||
} | ||
else { | ||
@@ -138,0 +143,0 @@ // IIIF v3 property value |
{ | ||
"name": "manifesto.js", | ||
"version": "4.2.11", | ||
"version": "4.2.13", | ||
"description": "IIIF Presentation API utility library for client and server", | ||
@@ -5,0 +5,0 @@ "main": "./dist-commonjs/index.js", |
{ | ||
"v2": { | ||
"singleString": "A single string", | ||
"multipleStrings": ["One string", "another string"], | ||
"singleLocalized": {"@language": "de", "@value": "Ich bin ein Berliner."}, | ||
"multipleStrings": [ | ||
"One string", | ||
"another string" | ||
], | ||
"singleLocalized": { | ||
"@language": "de", | ||
"@value": "Ich bin ein Berliner." | ||
}, | ||
"singleLocalizedWithoutLanguage": { | ||
"@value": "Ich bin ein Berliner." | ||
}, | ||
"multipleLocalized": [ | ||
{"@language": "es", "@value": "Yo La Tengo"}, | ||
{"@language": "fr", "@value": "Sous les pavés, la plage"} | ||
{ | ||
"@language": "es", | ||
"@value": "Yo La Tengo" | ||
}, | ||
{ | ||
"@language": "fr", | ||
"@value": "Sous les pavés, la plage" | ||
} | ||
], | ||
"multipleMixed": [ | ||
{"@language": "en", "@value": "Hello!"}, | ||
{ | ||
"@language": "en", | ||
"@value": "Hello!" | ||
}, | ||
"Saluton!", | ||
{"@language": "zh-Latn", "@value": "Nǐ hǎo!"}, | ||
{"@language": "zh", "@value": "你好!"}, | ||
{"@language": "jp-Hira", "@value": "こんにちは"}, | ||
{"@language": "jp-Han", "@value": "今日は"}, | ||
{"@language": "jp-Latn", "@value": "Konnichi wa"}, | ||
{ | ||
"@language": "zh-Latn", | ||
"@value": "Nǐ hǎo!" | ||
}, | ||
{ | ||
"@language": "zh", | ||
"@value": "你好!" | ||
}, | ||
{ | ||
"@language": "jp-Hira", | ||
"@value": "こんにちは" | ||
}, | ||
{ | ||
"@language": "jp-Han", | ||
"@value": "今日は" | ||
}, | ||
{ | ||
"@language": "jp-Latn", | ||
"@value": "Konnichi wa" | ||
}, | ||
"\ud83d\udc4b" | ||
@@ -31,4 +64,6 @@ ] | ||
], | ||
"none": [ "Whistler (1871)" ] | ||
"none": [ | ||
"Whistler (1871)" | ||
] | ||
} | ||
} |
@@ -1,52 +0,63 @@ | ||
var expect = require('chai').expect; | ||
var manifesto = require('../../dist-commonjs'); | ||
var expect = require("chai").expect; | ||
var manifesto = require("../../dist-commonjs"); | ||
var fixtures = require('../fixtures/propertyvalues.json'); | ||
var fixtures = require("../fixtures/propertyvalues.json"); | ||
describe('PropertyValue', function() { | ||
it('should parse and handle simple v2 string values', function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.singleString); | ||
expect(val.getValue()).to.eq('A single string'); | ||
expect(val.getValue('en')).to.eq('A single string'); | ||
val = manifesto.PropertyValue.parse(fixtures.v2.multipleStrings); | ||
expect(val.getValue('zh')).to.eq('One string'); | ||
expect(val.getValue('jp', '\n')).to.eq('One string\nanother string'); | ||
expect(val.getValues('kr')).to.have.members(['One string', 'another string']); | ||
}) | ||
describe("PropertyValue", function() { | ||
it("should parse and handle simple v2 string values", function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.singleString); | ||
expect(val.getValue()).to.eq("A single string"); | ||
expect(val.getValue("en")).to.eq("A single string"); | ||
val = manifesto.PropertyValue.parse(fixtures.v2.multipleStrings); | ||
expect(val.getValue("zh")).to.eq("One string"); | ||
expect(val.getValue("jp", "\n")).to.eq("One string\nanother string"); | ||
expect(val.getValues("kr")).to.have.members([ | ||
"One string", | ||
"another string", | ||
]); | ||
}); | ||
it('should parse and handle localized v2 values', function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.singleLocalized); | ||
expect(val.getValue()).to.eq('Ich bin ein Berliner.'); | ||
expect(val.getValue('en')).to.eq('Ich bin ein Berliner.'); | ||
expect(val.getValue('de')).to.eq('Ich bin ein Berliner.'); | ||
val = manifesto.PropertyValue.parse(fixtures.v2.multipleLocalized); | ||
expect(val.getValue('es')).to.eq('Yo La Tengo'); | ||
expect(val.getValue('fr')).to.eq("Sous les pavés, la plage"); | ||
expect(val.getValue()).to.eq('Yo La Tengo'); | ||
expect(val.getValues()).to.have.members(['Yo La Tengo']); | ||
}); | ||
it("should parse and handle localized v2 values", function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.singleLocalized); | ||
expect(val.getValue()).to.eq("Ich bin ein Berliner."); | ||
expect(val.getValue("en")).to.eq("Ich bin ein Berliner."); | ||
expect(val.getValue("de")).to.eq("Ich bin ein Berliner."); | ||
val = manifesto.PropertyValue.parse(fixtures.v2.multipleLocalized); | ||
expect(val.getValue("es")).to.eq("Yo La Tengo"); | ||
expect(val.getValue("fr")).to.eq("Sous les pavés, la plage"); | ||
expect(val.getValue()).to.eq("Yo La Tengo"); | ||
expect(val.getValues()).to.have.members(["Yo La Tengo"]); | ||
}); | ||
it('should parse and handle mixed v2 values', function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.multipleMixed); | ||
expect(val.getValue()).to.eq('Saluton!'); | ||
expect(val.getValue(undefined, '\n')).to.eq('Saluton!\n\ud83d\udc4b'); | ||
expect(val.getValue('en')).to.eq('Hello!'); | ||
expect(val.getValue('de')).to.eq('Saluton!'); | ||
expect(val.getValue('zh')).to.eq('你好!'); | ||
expect(val.getValue('zh-Latn')).to.eq('Nǐ hǎo!'); | ||
expect(val.getValue('jp')).to.eq('こんにちは'); | ||
expect(val.getValues('jp')).to.have.members(['こんにちは']); | ||
}); | ||
// omeka S manifests exclude @language - easier to fix here than in omeka | ||
it("should parse and handle localized v2 values without @language", function() { | ||
var val = manifesto.PropertyValue.parse( | ||
fixtures.v2.singleLocalizedWithoutLanguage | ||
); | ||
expect(val.getValue()).to.eq("Ich bin ein Berliner."); | ||
}); | ||
it('should parse and handle v3 values', function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v3); | ||
expect(val.getValue()).to.eq('Whistler (1871)'); | ||
expect(val.getValue('en')).to.eq('Whistler\'s Mother'); | ||
expect(val.getValues('en')).to.have.members([ | ||
"Whistler's Mother", | ||
"Arrangement in Grey and Black No. 1: The Artist's Mother" | ||
]); | ||
expect(val.getValue('fr')).to.eq('Arrangement en gris et noir no 1'); | ||
expect(val.getValue('jp')).to.eq('Whistler (1871)'); | ||
}); | ||
}); | ||
it("should parse and handle mixed v2 values", function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v2.multipleMixed); | ||
expect(val.getValue()).to.eq("Saluton!"); | ||
expect(val.getValue(undefined, "\n")).to.eq("Saluton!\n\ud83d\udc4b"); | ||
expect(val.getValue("en")).to.eq("Hello!"); | ||
expect(val.getValue("de")).to.eq("Saluton!"); | ||
expect(val.getValue("zh")).to.eq("你好!"); | ||
expect(val.getValue("zh-Latn")).to.eq("Nǐ hǎo!"); | ||
expect(val.getValue("jp")).to.eq("こんにちは"); | ||
expect(val.getValues("jp")).to.have.members(["こんにちは"]); | ||
}); | ||
it("should parse and handle v3 values", function() { | ||
var val = manifesto.PropertyValue.parse(fixtures.v3); | ||
expect(val.getValue()).to.eq("Whistler (1871)"); | ||
expect(val.getValue("en")).to.eq("Whistler's Mother"); | ||
expect(val.getValues("en")).to.have.members([ | ||
"Whistler's Mother", | ||
"Arrangement in Grey and Black No. 1: The Artist's Mother", | ||
]); | ||
expect(val.getValue("fr")).to.eq("Arrangement en gris et noir no 1"); | ||
expect(val.getValue("jp")).to.eq("Whistler (1871)"); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
36651521
0277936
0.02%