Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added loading the scan types via the message system [#643]
- Loading branch information
Showing
15 changed files
with
556 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...-api/src/main/java/org/comixedproject/messaging/ComiXedWebSocketAuthenticationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { createAction, props } from '@ngrx/store'; | ||
import { ScanType } from '@app/library'; | ||
|
||
export const loadScanTypes = createAction('[Scan Type] Load all scan types'); | ||
|
||
export const addScanType = createAction( | ||
'[Scan Type] A scan type was received', | ||
props<{ scanType: ScanType }>() | ||
); |
52 changes: 52 additions & 0 deletions
52
comixed-web/src/app/library/effects/scan-type.effects.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
import { provideMockActions } from '@ngrx/effects/testing'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { ScanTypeEffects } from './scan-type.effects'; | ||
import { ScanTypeService } from '@app/library/services/scan-type.service'; | ||
|
||
describe('ScanTypeEffects', () => { | ||
const actions$: Observable<any> = null; | ||
let effects: ScanTypeEffects; | ||
let scanTypeService: jasmine.SpyObj<ScanTypeService>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ | ||
ScanTypeEffects, | ||
provideMockActions(() => actions$), | ||
{ | ||
provide: ScanTypeService, | ||
useValue: {} | ||
} | ||
] | ||
}); | ||
|
||
effects = TestBed.inject(ScanTypeEffects); | ||
scanTypeService = TestBed.inject( | ||
ScanTypeService | ||
) as jasmine.SpyObj<ScanTypeService>; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(effects).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { Actions } from '@ngrx/effects'; | ||
import { ScanTypeService } from '@app/library/services/scan-type.service'; | ||
|
||
@Injectable() | ||
export class ScanTypeEffects { | ||
constructor( | ||
private actions$: Actions, | ||
private scanTypeService: ScanTypeService | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
comixed-web/src/app/library/reducers/scan-type.reducer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { initialState, reducer, ScanTypeState } from './scan-type.reducer'; | ||
import { SCAN_TYPE_1 } from '@app/library/library.fixtures'; | ||
import { | ||
addScanType, | ||
loadScanTypes | ||
} from '@app/library/actions/scan-type.actions'; | ||
|
||
describe('ScanType Reducer', () => { | ||
const SCAN_TYPE = SCAN_TYPE_1; | ||
|
||
let state: ScanTypeState; | ||
|
||
beforeEach(() => { | ||
state = { ...initialState }; | ||
}); | ||
|
||
describe('the initial state', () => { | ||
beforeEach(() => { | ||
state = reducer({ ...state }, {} as any); | ||
}); | ||
|
||
it('has no scan types', () => { | ||
expect(state.types).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('loading the scan types', () => { | ||
beforeEach(() => { | ||
state = reducer({ ...state, initialized: true }, loadScanTypes()); | ||
}); | ||
|
||
it('clears the initialized flag', () => { | ||
expect(state.initialized).toBeFalse(); | ||
}); | ||
}); | ||
|
||
describe('receiving a scan type', () => { | ||
beforeEach(() => { | ||
state = reducer( | ||
{ ...state, initialized: false, types: [] }, | ||
addScanType({ scanType: SCAN_TYPE }) | ||
); | ||
}); | ||
|
||
it('sets the initialized flag', () => { | ||
expect(state.initialized).toBeTrue(); | ||
}); | ||
|
||
it('adds the scan type', () => { | ||
expect(state.types).toContain(SCAN_TYPE); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.