diff --git a/test/backend/unit/model/sql/GalleryManager.ts b/test/backend/unit/model/sql/GalleryManager.ts index a59bc452..050bbea5 100644 --- a/test/backend/unit/model/sql/GalleryManager.ts +++ b/test/backend/unit/model/sql/GalleryManager.ts @@ -103,7 +103,7 @@ describe('GalleryManager', () => { removeIds(selected); subDir.isPartial = true; delete subDir.directories; - expect(selected).to.deep.equal(parent); + expect(Utils.clone(selected)).to.deep.equal(Utils.clone(parent)); }); @@ -137,7 +137,7 @@ describe('GalleryManager', () => { delete subDir.parent; removeIds(selected); // selected.directories[0].parent = selected; - expect(selected).to.deep.equal(subDir); + expect(Utils.clone(selected)).to.deep.equal(Utils.clone(subDir)); }); diff --git a/test/backend/unit/model/sql/SearchManager.ts b/test/backend/unit/model/sql/SearchManager.ts index 69a39e90..4be5efbe 100644 --- a/test/backend/unit/model/sql/SearchManager.ts +++ b/test/backend/unit/model/sql/SearchManager.ts @@ -19,7 +19,7 @@ import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/Me import {OrientationTypes} from 'ts-exif-parser'; import {Utils} from '../../../../../common/Utils'; import {TestHelper} from './TestHelper'; -import {afterEach, beforeEach, describe, it} from '@angular/core/testing/src/testing_internal'; +import {VideoEntity} from '../../../../../backend/model/sql/enitites/VideoEntity'; describe('SearchManager', () => { @@ -30,6 +30,7 @@ describe('SearchManager', () => { const dir = TestHelper.getDirectoryEntry(); const p = TestHelper.getPhotoEntry1(dir); const p2 = TestHelper.getPhotoEntry2(dir); + const v = TestHelper.getVideoEntry1(dir); const setUpSqlDB = async () => { if (fs.existsSync(dbPath)) { @@ -49,6 +50,7 @@ describe('SearchManager', () => { await conn.getRepository(DirectoryEntity).save(p.directory); await pr.save(p); await pr.save(p2); + await conn.getRepository(VideoEntity).save(v); await SQLConnection.close(); }; @@ -99,8 +101,10 @@ describe('SearchManager', () => { new AutoCompleteItem('wars dir', SearchTypes.directory), new AutoCompleteItem('Research City', SearchTypes.position)].sort(cmp)); - expect((await sm.autocomplete('sw')).sort(cmp)).to.deep.equal([new AutoCompleteItem('sw1', SearchTypes.image), - new AutoCompleteItem('sw2', SearchTypes.image)].sort(cmp)); + expect((await sm.autocomplete('sw')).sort(cmp)).to.deep.equal([new AutoCompleteItem('sw1', SearchTypes.photo), + new AutoCompleteItem('sw2', SearchTypes.photo), new AutoCompleteItem(v.name, SearchTypes.video)].sort(cmp)); + + expect((await sm.autocomplete(v.name)).sort(cmp)).to.deep.equal([new AutoCompleteItem(v.name, SearchTypes.video)]); }); @@ -112,7 +116,7 @@ describe('SearchManager', () => { searchText: 'sw', searchType: null, directories: [], - media: [p, p2], + media: [p, p2,v], resultOverflow: false })); @@ -156,7 +160,7 @@ describe('SearchManager', () => { expect(Utils.clone(await sm.instantSearch('sw'))).to.deep.equal(Utils.clone({ searchText: 'sw', directories: [], - media: [p, p2], + media: [p, p2,v], resultOverflow: false })); diff --git a/test/backend/unit/model/sql/TestHelper.ts b/test/backend/unit/model/sql/TestHelper.ts index 86cce854..8258934b 100644 --- a/test/backend/unit/model/sql/TestHelper.ts +++ b/test/backend/unit/model/sql/TestHelper.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import {OrientationTypes} from 'ts-exif-parser'; import {DirectoryEntity} from '../../../../../backend/model/sql/enitites/DirectoryEntity'; import {Utils} from '../../../../../common/Utils'; +import {VideoEntity, VideoMetadataEntity} from '../../../../../backend/model/sql/enitites/VideoEntity'; export class TestHelper { @@ -65,6 +66,28 @@ export class TestHelper { return d; } + public static getVideoEntry(dir: DirectoryEntity) { + const sd = new MediaDimensionEntity(); + sd.height = 200; + sd.width = 200; + + const m = new VideoMetadataEntity(); + m.keywords = null; + m.size = sd; + m.creationDate = Date.now(); + m.fileSize = 123456789; + + m.duration = 10000; + m.bitRate = 4000; + + + const d = new VideoEntity(); + d.name = 'test video.jpg'; + d.directory = dir; + d.metadata = m; + return d; + } + public static getPhotoEntry1(dir: DirectoryEntity) { const p = TestHelper.getPhotoEntry(dir); @@ -75,6 +98,12 @@ export class TestHelper { return p; } + public static getVideoEntry1(dir: DirectoryEntity) { + const p = TestHelper.getVideoEntry(dir); + p.name = 'swVideo'; + return p; + } + public static getPhotoEntry2(dir: DirectoryEntity) { const p = TestHelper.getPhotoEntry(dir);