1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-08 04:03:48 +02:00

test-fixing

This commit is contained in:
grasdk 2024-03-14 10:41:41 +01:00
parent 6a52d84881
commit 35839ef732
15 changed files with 34 additions and 18 deletions

View File

@ -154,7 +154,7 @@ export class Utils {
if (UTCTimestamp && timestamp) {
//offset in minutes is the difference between gps timestamp and given timestamp
//to calculate this correctly, we have to work with the same offset
const offsetMinutes = (timestampToMS(timestamp, '+00:00')- timestampToMS(UTCTimestamp, '+00:00')) / 1000 / 60;
const offsetMinutes = (Utils.timestampToMS(timestamp, '+00:00')- Utils.timestampToMS(UTCTimestamp, '+00:00')) / 1000 / 60;
return Utils.getOffsetString(offsetMinutes);
} else {
return undefined;

View File

@ -7,7 +7,7 @@
"make": "samsung",
"model": "SM-A715F"
},
"creationDate": 1704621779177,
"creationDate": 1704625379177,
"creationDateOffset": "+01:00",
"fileSize": 15126,
"size": {

View File

@ -8,7 +8,7 @@
"make": "NIKON CORPORATION",
"model": "NIKON Z 30"
},
"creationDate": 1705829040930,
"creationDate": 1705832640930,
"creationDateOffset": "+01:00",
"fileSize": 25556,
"size": {

View File

@ -1,6 +1,6 @@
{
"bitRate": 184871,
"creationDate": 1706432060000,
"creationDate": 1706435660000,
"duration": 1000,
"fileSize": 23132,
"size": {

View File

@ -1,6 +1,6 @@
{
"bitRate": 183168,
"creationDate": 1706436545000,
"creationDate": 1706440145000,
"duration": 1000,
"fileSize": 22896,
"size": {

View File

@ -8,7 +8,7 @@
"make": "NIKON CORPORATION",
"model": "NIKON Z 30"
},
"creationDate": 1706464688660,
"creationDate": 1706468288660,
"creationDateOffset": "+01:00",
"fileSize": 47059,
"size": {

View File

@ -5,7 +5,7 @@
},
"bitRate": 1794127,
"duration": 290,
"creationDate": 1709052692000,
"creationDate": 1542482851000,
"fileSize": 65073,
"fps": 40000,
"keywords": [

View File

@ -0,0 +1,16 @@
{
"size": {
"width": 640,
"height": 360
},
"bitRate": 1794127,
"duration": 290,
"creationDate": 1542482851000,
"fileSize": 65073,
"fps": 40000,
"keywords": [
"rabbit",
"test"
],
"rating": 4
}

View File

@ -5,7 +5,7 @@
},
"bitRate": 1794127,
"duration": 290,
"creationDate": 1709052692000,
"creationDate": 1542482851000,
"fileSize": 65073,
"fps": 40000,
"keywords": [

View File

@ -102,61 +102,61 @@ describe('MetadataLoader', () => {
});
it('should load sidecar file with file extension for video', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should load sidecar file without file extension for video', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v2.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json'));//sidecar "bunny_1sec_v2.xmp" is identical to "bunny_1sec.mp4.xmp" so we expect the same result
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json'));//sidecar "bunny_1sec_v2.xmp" is identical to "bunny_1sec.mp4.xmp" so we expect the same result
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should retrieve both keywords from sidecar file for video', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should retrieve one keyword from sidecar file for video', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.mp4.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should load sidecar file with file extension for photo', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should load sidecar file without file extension for photo', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.jpg.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should retrieve both keywords from sidecar file for photo', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should retrieve one keyword from sidecar file for photo', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.jpg.json'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.json'));
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'));
const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata.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
const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.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);
});