-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AfO service, tests & bibliography routes and tabs
- Loading branch information
Showing
12 changed files
with
186 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { testDelegation, TestData } from 'test-support/utils' | ||
import AfoRegisterService from 'afo-register/application/AfoRegisterService' | ||
import AfoRegisterRepository from 'afo-register/infrastructure/AfoRegisterRepository' | ||
import { stringify } from 'query-string' | ||
|
||
jest.mock('afo-register/infrastructure/AfoRegisterRepository', () => { | ||
return function () { | ||
return { | ||
search: jest.fn(), | ||
} | ||
} | ||
}) | ||
|
||
const resultStub = { | ||
afoNumber: 'AfO 1', | ||
page: '2', | ||
text: 'some text', | ||
textNumber: '5', | ||
} | ||
const afoRegisterRepository = new (AfoRegisterRepository as jest.Mock)() | ||
const afoRegisterService = new AfoRegisterService(afoRegisterRepository) | ||
|
||
const testData: TestData<AfoRegisterService>[] = [ | ||
new TestData( | ||
'search', | ||
[ | ||
stringify({ | ||
afoNumber: 'AfO 1', | ||
page: '2', | ||
}), | ||
], | ||
afoRegisterRepository.search, | ||
[resultStub] | ||
), | ||
new TestData( | ||
'search', | ||
[ | ||
stringify({ | ||
text: 'some text', | ||
textNumber: '5', | ||
}), | ||
], | ||
afoRegisterRepository.search, | ||
[resultStub] | ||
), | ||
] | ||
describe('afoRegisterService', () => | ||
testDelegation(afoRegisterService, testData)) |
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,19 @@ | ||
import Promise from 'bluebird' | ||
import AfoRegisterRecord from 'afo-register/domain/Record' | ||
import AfoRegisterRepository from 'afo-register/infrastructure/AfoRegisterRepository' | ||
|
||
export interface afoRegisterSearch { | ||
search(query: string): Promise<readonly AfoRegisterRecord[]> | ||
} | ||
|
||
export default class AfoRegisterService implements afoRegisterSearch { | ||
private readonly afoRegisterRepository: AfoRegisterRepository | ||
|
||
constructor(afoRegisterRepository: AfoRegisterRepository) { | ||
this.afoRegisterRepository = afoRegisterRepository | ||
} | ||
|
||
search(query: string): Promise<readonly AfoRegisterRecord[]> { | ||
return this.afoRegisterRepository.search(query) | ||
} | ||
} |
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
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
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
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