-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise 'About' Section #426
Changes from 16 commits
4612dc0
c2e9e49
9b5a38a
6760055
852f271
feec724
6675ed5
c3eb13d
e2a5cb2
c9d2900
7e93b40
15c599f
ccbbb63
f711162
d3ce18d
0c8e576
73b6d01
ad430f7
0523a29
1c2a110
41c90e1
76d1694
4f48b17
89b6840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import { ChapterDisplay } from 'corpus/domain/chapter' | |
import textLineFixture, { textLineDto } from 'test-support/lines/text-line' | ||
import { chapterDisplayDtoFactory } from 'test-support/chapter-fixtures' | ||
import { | ||
bibliographyEntryFactory, | ||
cslDataFactory, | ||
referenceDtoFactory, | ||
referenceFactory, | ||
|
@@ -582,8 +583,28 @@ test('inject ChapterDisplay', async () => { | |
} | ||
} | ||
|
||
const translationReference = referenceFactory.build() | ||
const intertextReference = referenceFactory.build() | ||
const translationReference = referenceFactory.build( | ||
{}, | ||
{ | ||
associations: { | ||
document: bibliographyEntryFactory.build( | ||
{}, | ||
{ associations: { id: 'XY1' } } | ||
), | ||
}, | ||
} | ||
) | ||
const intertextReference = referenceFactory.build( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 2 locations. Consider refactoring. |
||
{}, | ||
{ | ||
associations: { | ||
document: bibliographyEntryFactory.build( | ||
{}, | ||
{ associations: { id: 'XY2' } } | ||
), | ||
}, | ||
} | ||
) | ||
const chapterWithReferences = produce(chapterDisplay, (draft) => { | ||
draft.lines[0].translation[0].parts = [ | ||
createInjectedPart(translationReference), | ||
|
@@ -607,11 +628,11 @@ test('inject ChapterDisplay', async () => { | |
] | ||
}) | ||
apiClient.fetchJson.mockReturnValue(Bluebird.resolve(chapterWithReferences)) | ||
bibliographyServiceMock.find.mockReturnValueOnce( | ||
Bluebird.resolve(translationReference.document) | ||
bibliographyServiceMock.findMany.mockReturnValueOnce( | ||
Bluebird.resolve([translationReference.document]) | ||
) | ||
bibliographyServiceMock.find.mockReturnValueOnce( | ||
Bluebird.resolve(intertextReference.document) | ||
bibliographyServiceMock.findMany.mockReturnValueOnce( | ||
Bluebird.resolve([intertextReference.document]) | ||
) | ||
await expect(testService.findChapterDisplay(chapterId)).resolves.toEqual( | ||
injectedChapter | ||
|
@@ -620,12 +641,12 @@ test('inject ChapterDisplay', async () => { | |
`${chapterUrl}/display`, | ||
false | ||
) | ||
expect(bibliographyServiceMock.find).toHaveBeenCalledWith( | ||
translationReference.id | ||
) | ||
expect(bibliographyServiceMock.find).toHaveBeenCalledWith( | ||
intertextReference.id | ||
) | ||
expect(bibliographyServiceMock.findMany).toHaveBeenCalledWith([ | ||
translationReference.id, | ||
]) | ||
expect(bibliographyServiceMock.findMany).toHaveBeenCalledWith([ | ||
intertextReference.id, | ||
]) | ||
}) | ||
|
||
test('listAllTexts', async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ import { MarkupPart } from 'transliteration/domain/markup' | |
import { stringify } from 'query-string' | ||
|
||
export default class MarkupService { | ||
private readonly referenceInjector: ReferenceInjector | ||
protected readonly referenceInjector: ReferenceInjector | ||
constructor( | ||
private readonly apiClient: ApiClient, | ||
protected readonly apiClient: ApiClient, | ||
bibliographyService: BibliographyService | ||
) { | ||
this.referenceInjector = new ReferenceInjector(bibliographyService) | ||
|
@@ -42,3 +42,20 @@ export default class MarkupService { | |
return this.referenceInjector.injectReferencesToMarkup(parts) | ||
} | ||
} | ||
|
||
export class CachedMarkupService extends MarkupService { | ||
fromString(text: string): Bluebird<readonly MarkupPart[]> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 2 locations. Consider refactoring. |
||
return this.apiClient | ||
.fetchJson( | ||
`/cached-markup?${stringify({ | ||
text: text, | ||
})}`, | ||
false | ||
) | ||
.then((parts) => { | ||
return Bluebird.all( | ||
parts && Bluebird.all(this.injectReferencesToMarkup(parts)) | ||
) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.