diff --git a/test/backend/assets/sidecar/metadata.jpg b/test/backend/assets/sidecar/metadata.jpg new file mode 100644 index 00000000..c3d685e8 Binary files /dev/null and b/test/backend/assets/sidecar/metadata.jpg differ diff --git a/test/backend/assets/sidecar/metadata.jpg.json b/test/backend/assets/sidecar/metadata.jpg.json new file mode 100644 index 00000000..dc452767 --- /dev/null +++ b/test/backend/assets/sidecar/metadata.jpg.json @@ -0,0 +1,12 @@ +{ + "size": { + "width": 10, + "height": 5 + }, + "creationDate": 1709057753000, + "fileSize": 4489, + "keywords": [ + "floor", + "book" + ] +} diff --git a/test/backend/assets/sidecar/metadata_v2.jpg b/test/backend/assets/sidecar/metadata_v2.jpg new file mode 100644 index 00000000..c3d685e8 Binary files /dev/null and b/test/backend/assets/sidecar/metadata_v2.jpg differ diff --git a/test/backend/assets/sidecar/metadata_v2.jpg.json b/test/backend/assets/sidecar/metadata_v2.jpg.json new file mode 100644 index 00000000..5c544af4 --- /dev/null +++ b/test/backend/assets/sidecar/metadata_v2.jpg.json @@ -0,0 +1,15 @@ +{ + "size": { + "width": 10, + "height": 5 + }, + "creationDate": 1709057753000, + "fileSize": 4489, + "keywords": [ + "floor", + "book", + "first", + "second" + ], + "rating": 0 +} diff --git a/test/backend/assets/sidecar/metadata_v2.xmp b/test/backend/assets/sidecar/metadata_v2.xmp new file mode 100644 index 00000000..532af7a5 --- /dev/null +++ b/test/backend/assets/sidecar/metadata_v2.xmp @@ -0,0 +1,18 @@ + + + + 0 + 0 + + + first + second + + + + + diff --git a/test/backend/unit/model/threading/MetaDataLoader.spec.ts b/test/backend/unit/model/threading/MetaDataLoader.spec.ts index 8865a67c..e3465079 100644 --- a/test/backend/unit/model/threading/MetaDataLoader.spec.ts +++ b/test/backend/unit/model/threading/MetaDataLoader.spec.ts @@ -117,6 +117,17 @@ describe('MetadataLoader', () => { expect(Utils.clone(data)).to.be.deep.equal(expected); }); + it('should read keywords from photo without sidecar file', async () => { + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/metadata.jpg')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata.jpg.json')); + expect(Utils.clone(data)).to.be.deep.equal(expected); + }); + + it('should merge keywords from photo with keywords from sidecar', async () => { + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.jpg')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.jpg.json')); //"metadata_v2.jpg" is identical to "metadata.jpg" and "metadata_v2.xmp" contains 2 different keywords expect(Utils.clone(data)).to.be.deep.equal(expected); + }); + describe('should load jpg with proper height and orientation', () => { it('jpg 1', async () => {