Skip to content

Commit

Permalink
Fixes more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
digimezzo committed Dec 7, 2024
1 parent 0e4671c commit a694a9d
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { GuidFactory } from '../../../../../common/guid.factory';
import { ArtistSorter } from '../../../../../common/sorting/artist-sorter';
import { PlaybackService } from '../../../../../services/playback/playback.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

export class CdkVirtualScrollViewportMock {
private _scrollToIndexIndex: number = -1;
private _scrollToIndexBehavior: ScrollBehavior | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { SearchServiceBase } from '../../../../services/search/search.service.ba
import { AppearanceServiceBase } from '../../../../services/appearance/appearance.service.base';
import { IndexingServiceBase } from '../../../../services/indexing/indexing.service.base';
import { CollectionServiceBase } from '../../../../services/collection/collection.service.base';
import { MetadataServiceBase } from '../../../../services/metadata/metadata.service.base';
import { PlaybackService } from '../../../../services/playback/playback.service';
import { FolderServiceBase } from '../../../../services/folder/folder.service.base';
import { NavigationServiceBase } from '../../../../services/navigation/navigation.service.base';
Expand All @@ -31,15 +30,17 @@ import { TrackModels } from '../../../../services/track/track-models';
import { Folder } from '../../../../data/entities/folder';
import { Constants } from '../../../../common/application/constants';
import { DesktopBase } from '../../../../common/io/desktop.base';
import { TrackBrowserComponent } from '../track-browser/track-browser.component';
import { MetadataService } from '../../../../services/metadata/metadata.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('CollectionFoldersComponent', () => {
let settingsStub: any;
let searchServiceMock: IMock<SearchServiceBase>;
let appearanceServiceMock: IMock<AppearanceServiceBase>;
let indexingServiceMock: IMock<IndexingServiceBase>;
let collectionServiceMock: IMock<CollectionServiceBase>;
let metadataServiceMock: IMock<MetadataServiceBase>;
let metadataServiceMock: IMock<MetadataService>;
let playbackServiceMock: IMock<PlaybackService>;
let folderServiceMock: IMock<FolderServiceBase>;
let navigationServiceMock: IMock<NavigationServiceBase>;
Expand Down Expand Up @@ -114,7 +115,7 @@ describe('CollectionFoldersComponent', () => {
appearanceServiceMock = Mock.ofType<AppearanceServiceBase>();
indexingServiceMock = Mock.ofType<IndexingServiceBase>();
collectionServiceMock = Mock.ofType<CollectionServiceBase>();
metadataServiceMock = Mock.ofType<MetadataServiceBase>();
metadataServiceMock = Mock.ofType<MetadataService>();
playbackServiceMock = Mock.ofType<PlaybackService>();
folderServiceMock = Mock.ofType<FolderServiceBase>();
navigationServiceMock = Mock.ofType<NavigationServiceBase>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { Constants } from '../../../../../common/application/constants';
import { GuidFactory } from '../../../../../common/guid.factory';
import { GenreSorter } from '../../../../../common/sorting/genre-sorter';

jest.mock('jimp', () => ({ exec: jest.fn() }));

export class CdkVirtualScrollViewportMock {
private _scrollToIndexIndex: number = -1;
private _scrollToIndexBehavior: ScrollBehavior | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { DateTime } from '../../../../common/date-time';
import { SettingsMock } from '../../../../testing/settings-mock';
import { PlaybackService } from '../../../../services/playback/playback.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('TrackBrowserBase', () => {
let playbackServiceMock: IMock<PlaybackService>;
let dialogServiceMock: IMock<DialogServiceBase>;
Expand Down
8 changes: 5 additions & 3 deletions src/app/ui/components/love/love.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ import { IMock, It, Mock, Times } from 'typemoq';
import { LoveComponent } from './love.component';
import { AppearanceServiceBase } from '../../../services/appearance/appearance.service.base';
import { ScrobblingServiceBase } from '../../../services/scrobbling/scrobbling.service.base';
import { MetadataServiceBase } from '../../../services/metadata/metadata.service.base';
import { DialogServiceBase } from '../../../services/dialog/dialog.service.base';
import { TranslatorServiceBase } from '../../../services/translator/translator.service.base';
import { DateTime } from '../../../common/date-time';
import { Track } from '../../../data/entities/track';
import { TrackModel } from '../../../services/track/track-model';
import { SettingsMock } from '../../../testing/settings-mock';
import { MetadataService } from '../../../services/metadata/metadata.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('LoveComponent', () => {
let appearanceServiceMock: IMock<AppearanceServiceBase>;
let scrobblingServiceMock: IMock<ScrobblingServiceBase>;
let metadataServiceMock: IMock<MetadataServiceBase>;
let metadataServiceMock: IMock<MetadataService>;
let dialogServiceMock: IMock<DialogServiceBase>;
let dateTimeMock: IMock<DateTime>;
let translatorServiceMock: IMock<TranslatorServiceBase>;
Expand All @@ -30,7 +32,7 @@ describe('LoveComponent', () => {
}

beforeEach(() => {
metadataServiceMock = Mock.ofType<MetadataServiceBase>();
metadataServiceMock = Mock.ofType<MetadataService>();
scrobblingServiceMock = Mock.ofType<ScrobblingServiceBase>();
dialogServiceMock = Mock.ofType<DialogServiceBase>();
dateTimeMock = Mock.ofType<DateTime>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { MockCreator } from '../../../../testing/mock-creator';
import { TrackModel } from '../../../../services/track/track-model';
import { ArtistInformation } from '../../../../services/artist-information/artist-information';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('NowPlayingArtistInfoComponent', () => {
let playbackServiceMock: IMock<PlaybackService>;
let artistInformationServiceMock: IMock<ArtistInformationServiceBase>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { PlaybackService } from '../../../../services/playback/playback.service'
import { NowPlayingNothingPlayingComponent } from './now-playing-nothing-playing.component';
import { TrackModels } from '../../../../services/track/track-models';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('NowPlayingNothingPlayingComponent', () => {
let playbackServiceMock: IMock<PlaybackService>;
let trackServiceMock: IMock<TrackServiceBase>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { IMock, Mock, Times } from 'typemoq';
import { NowPlayingComponent } from './now-playing.component';
import { AppearanceServiceBase } from '../../../services/appearance/appearance.service.base';
import { NavigationServiceBase } from '../../../services/navigation/navigation.service.base';
import { MetadataServiceBase } from '../../../services/metadata/metadata.service.base';
import { PlaybackService } from '../../../services/playback/playback.service';
import { SearchServiceBase } from '../../../services/search/search.service.base';
import { NowPlayingNavigationServiceBase } from '../../../services/now-playing-navigation/now-playing-navigation.service.base';
Expand All @@ -14,11 +13,14 @@ import { SchedulerBase } from '../../../common/scheduling/scheduler.base';
import { AudioVisualizer } from '../../../services/playback/audio-visualizer';
import { DocumentProxy } from '../../../common/io/document-proxy';
import { SettingsBase } from '../../../common/settings/settings.base';
import { MetadataService } from '../../../services/metadata/metadata.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('NowPlayingComponent', () => {
let appearanceServiceMock: IMock<AppearanceServiceBase>;
let navigationServiceMock: IMock<NavigationServiceBase>;
let metadataServiceMock: IMock<MetadataServiceBase>;
let metadataServiceMock: IMock<MetadataService>;
let playbackServiceMock: IMock<PlaybackService>;
let searchServiceMock: IMock<SearchServiceBase>;
let nowPlayingNavigationServiceMock: IMock<NowPlayingNavigationServiceBase>;
Expand Down Expand Up @@ -51,7 +53,7 @@ describe('NowPlayingComponent', () => {
beforeEach(() => {
appearanceServiceMock = Mock.ofType<AppearanceServiceBase>();
navigationServiceMock = Mock.ofType<NavigationServiceBase>();
metadataServiceMock = Mock.ofType<MetadataServiceBase>();
metadataServiceMock = Mock.ofType<MetadataService>();
playbackServiceMock = Mock.ofType<PlaybackService>();
nowPlayingNavigationServiceMock = Mock.ofType<NowPlayingNavigationServiceBase>();
schedulerMock = Mock.ofType<SchedulerBase>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Observable, Subject } from 'rxjs';
import { IMock, Mock } from 'typemoq';
import { PlaybackCoverArtComponent } from './playback-cover-art.component';
import { PlaybackInformationServiceBase } from '../../../services/playback-information/playback-information.service.base';
import { Scheduler } from '../../../common/scheduling/scheduler';
import { DateTime } from '../../../common/date-time';
import { TranslatorServiceBase } from '../../../services/translator/translator.service.base';
Expand All @@ -10,10 +9,13 @@ import { Track } from '../../../data/entities/track';
import { PlaybackInformation } from '../../../services/playback-information/playback-information';
import { Constants } from '../../../common/application/constants';
import { SettingsMock } from '../../../testing/settings-mock';
import { PlaybackInformationService } from '../../../services/playback-information/playback-information.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('PlaybackInformationComponent', () => {
let component: PlaybackCoverArtComponent;
let playbackInformationServiceMock: IMock<PlaybackInformationServiceBase>;
let playbackInformationServiceMock: IMock<PlaybackInformationService>;
let schedulerMock: IMock<Scheduler>;
let dateTimeMock: IMock<DateTime>;
let translatorServiceMock: IMock<TranslatorServiceBase>;
Expand All @@ -30,7 +32,7 @@ describe('PlaybackInformationComponent', () => {
let trackModel1: TrackModel;

beforeEach(() => {
playbackInformationServiceMock = Mock.ofType<PlaybackInformationServiceBase>();
playbackInformationServiceMock = Mock.ofType<PlaybackInformationService>();
schedulerMock = Mock.ofType<Scheduler>();

dateTimeMock = Mock.ofType<DateTime>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { Observable, Subject } from 'rxjs';
import { IMock, Mock } from 'typemoq';
import { PlaybackInformationComponent } from './playback-information.component';
import { PlaybackInformationServiceBase } from '../../../services/playback-information/playback-information.service.base';
import { MetadataServiceBase } from '../../../services/metadata/metadata.service.base';
import { Scheduler } from '../../../common/scheduling/scheduler';
import { DateTime } from '../../../common/date-time';
import { TranslatorServiceBase } from '../../../services/translator/translator.service.base';
import { PlaybackInformation } from '../../../services/playback-information/playback-information';
import { TrackModel } from '../../../services/track/track-model';
import { Track } from '../../../data/entities/track';
import { SettingsMock } from '../../../testing/settings-mock';
import { PlaybackInformationService } from '../../../services/playback-information/playback-information.service';
import { MetadataService } from '../../../services/metadata/metadata.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('PlaybackInformationComponent', () => {
let playbackInformationServiceMock: IMock<PlaybackInformationServiceBase>;
let metadataServiceMock: IMock<MetadataServiceBase>;
let playbackInformationServiceMock: IMock<PlaybackInformationService>;
let metadataServiceMock: IMock<MetadataService>;
let schedulerMock: IMock<Scheduler>;
let dateTimeMock: IMock<DateTime>;
let translatorServiceMock: IMock<TranslatorServiceBase>;
Expand Down Expand Up @@ -43,8 +45,8 @@ describe('PlaybackInformationComponent', () => {
}

beforeEach(() => {
playbackInformationServiceMock = Mock.ofType<PlaybackInformationServiceBase>();
metadataServiceMock = Mock.ofType<MetadataServiceBase>();
playbackInformationServiceMock = Mock.ofType<PlaybackInformationService>();
metadataServiceMock = Mock.ofType<MetadataService>();
schedulerMock = Mock.ofType<Scheduler>();
settingsMock = new SettingsMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { NativeElementProxy } from '../../../common/native-element-proxy';
import { Logger } from '../../../common/logger';
import { PlaybackProgress } from '../../../services/playback/playback-progress';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('PlaybackProgressComponent', () => {
let component: PlaybackProgressComponent;
let playbackServiceMock: IMock<PlaybackService>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { IMock, Mock } from 'typemoq';
import { PlaybackTimeComponent } from './playback-time.component';
import { PlaybackService } from '../../../services/playback/playback.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('PlaybackTimeComponent', () => {
let component: PlaybackTimeComponent;
let playbackServiceMock: IMock<PlaybackService>;
Expand Down
8 changes: 5 additions & 3 deletions src/app/ui/components/rating/rating.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { TranslatorServiceBase } from '../../../services/translator/translator.s
import { AppearanceServiceBase } from '../../../services/appearance/appearance.service.base';
import { DateTime } from '../../../common/date-time';
import { DialogServiceBase } from '../../../services/dialog/dialog.service.base';
import { MetadataServiceBase } from '../../../services/metadata/metadata.service.base';
import { TrackModel } from '../../../services/track/track-model';
import { Track } from '../../../data/entities/track';
import { SettingsMock } from '../../../testing/settings-mock';
import { MetadataService } from '../../../services/metadata/metadata.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('RatingComponent', () => {
let metadataServiceMock: IMock<MetadataServiceBase>;
let metadataServiceMock: IMock<MetadataService>;
let dialogServiceMock: IMock<DialogServiceBase>;
let dateTimeMock: IMock<DateTime>;
let translatorServiceMock: IMock<TranslatorServiceBase>;
Expand All @@ -34,7 +36,7 @@ describe('RatingComponent', () => {
}

beforeEach(() => {
metadataServiceMock = Mock.ofType<MetadataServiceBase>();
metadataServiceMock = Mock.ofType<MetadataService>();
dialogServiceMock = Mock.ofType<DialogServiceBase>();
dateTimeMock = Mock.ofType<DateTime>();
translatorServiceMock = Mock.ofType<TranslatorServiceBase>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { DialogServiceBase } from '../../../../services/dialog/dialog.service.ba
import { TranslatorServiceBase } from '../../../../services/translator/translator.service.base';
import { Logger } from '../../../../common/logger';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('BehaviorSettingsComponent', () => {
let component: BehaviorSettingsComponent;
let trayServiceMock: IMock<TrayServiceBase>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Mock, Times } from 'typemoq';
import { VolumeControlComponent } from './volume-control.component';
import { PlaybackService } from '../../../services/playback/playback.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('VolumeControlComponent', () => {
let playbackServiceMock: any;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Mock } from 'typemoq';
import { VolumeIconComponent } from './volume-icon.component';
import {PlaybackService} from "../../../services/playback/playback.service";
import { PlaybackService } from '../../../services/playback/playback.service';

jest.mock('jimp', () => ({ exec: jest.fn() }));

describe('VolumeIconComponent', () => {
let playbackServiceMock: any;
Expand Down

0 comments on commit a694a9d

Please sign in to comment.