-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
improvement: settings refactor
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { HighlightRenderOption, formatHighlightQuote } from '../util' | ||
import { DEFAULT_SETTINGS, HighlightManagerId } from '../settings' | ||
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 16.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 18.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 14.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 19.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 19.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 18.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 16.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 14.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 14.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 18.x)
Check failure on line 2 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 19.x)
|
||
|
||
type testCase = { | ||
quote: string | ||
template: string | ||
highlightRenderOption: HighlightRenderOption | null | ||
expected: string | ||
} | ||
|
||
const quote = 'some quote' | ||
const color = 'red' | ||
const templateWithoutBlockQuote = `{{#highlights}} | ||
{{{text}}} | ||
{{/highlights}}` | ||
const templateWithBlockQuote = `{{#highlights}} | ||
> {{{text}}} | ||
{{/highlights}}` | ||
|
||
const blockQuoteNoHighlightRenderOption = { | ||
quote: quote, | ||
template: templateWithBlockQuote, | ||
highlightRenderOption: null, | ||
expected: quote, | ||
} | ||
|
||
const noBlockQuoteNoHighlightRenderOption = { | ||
quote: quote, | ||
template: templateWithoutBlockQuote, | ||
highlightRenderOption: null, | ||
expected: quote, | ||
} | ||
|
||
const blockQuoteOmnivoreRenderOption = { | ||
quote: quote, | ||
template: templateWithBlockQuote, | ||
highlightRenderOption: { | ||
highlightManagerId: HighlightManagerId.OMNIVORE, | ||
highlightColor: color, | ||
}, | ||
expected: `<mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}">${quote}</mark>`, | ||
} | ||
|
||
const blockQuoteMultiLineOmnivoreRenderOption = { | ||
quote: `${quote} | ||
${quote}`, | ||
template: templateWithBlockQuote, | ||
highlightRenderOption: { | ||
highlightManagerId: HighlightManagerId.OMNIVORE, | ||
highlightColor: color, | ||
}, | ||
expected: `<mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}">${quote}</mark> | ||
><mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}"> ${quote}</mark>`, | ||
} | ||
|
||
|
||
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 16.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 18.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 14.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 19.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 19.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 18.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 16.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 14.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 14.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 18.x)
Check failure on line 56 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 19.x)
|
||
const blockQuoteHighlightrRenderOption = { | ||
quote: quote, | ||
template: templateWithBlockQuote, | ||
highlightRenderOption: { | ||
highlightManagerId: HighlightManagerId.HIGHLIGHTR, | ||
highlightColor: color, | ||
}, | ||
expected: `<mark class="${HighlightManagerId.HIGHLIGHTR}-${color}">${quote}</mark>`, | ||
} | ||
|
||
const noBlockQuoteMultiLineOmnivoreRenderOption = { | ||
quote: `${quote} | ||
${quote}`, | ||
template: templateWithoutBlockQuote, | ||
highlightRenderOption: { | ||
highlightManagerId: HighlightManagerId.OMNIVORE, | ||
highlightColor: color, | ||
}, | ||
expected: `<mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}">${quote}</mark> | ||
<mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}">${quote}</mark>`, | ||
} | ||
|
||
const blockQuoteEmptyLineOmnivoreRenderOption = { | ||
quote: `${quote} | ||
`, | ||
template: templateWithBlockQuote, | ||
highlightRenderOption: { | ||
highlightManagerId: HighlightManagerId.OMNIVORE, | ||
highlightColor: color, | ||
}, | ||
expected: `<mark class="${HighlightManagerId.OMNIVORE} ${HighlightManagerId.OMNIVORE}-${color}">${quote}</mark> | ||
>`, | ||
} | ||
|
||
|
||
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 16.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 18.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 14.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 19.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 19.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 18.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 16.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 14.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 14.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 18.x)
Check failure on line 91 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 19.x)
|
||
const testCases: testCase[] = [ | ||
blockQuoteNoHighlightRenderOption, | ||
noBlockQuoteNoHighlightRenderOption, | ||
blockQuoteOmnivoreRenderOption, | ||
blockQuoteMultiLineOmnivoreRenderOption, | ||
blockQuoteHighlightrRenderOption, | ||
noBlockQuoteMultiLineOmnivoreRenderOption, | ||
blockQuoteEmptyLineOmnivoreRenderOption | ||
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 16.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 18.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 14.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 19.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 19.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 18.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 16.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 14.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 14.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 18.x)
Check failure on line 99 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 19.x)
|
||
] | ||
|
||
describe('formatHighlightQuote', () => { | ||
test.each(testCases)('should correctly for format %s', (testCase) => { | ||
const result = formatHighlightQuote(testCase.quote, testCase.template, testCase.highlightRenderOption) | ||
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 16.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 18.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 14.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (ubuntu-latest, 19.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 19.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 18.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 16.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 14.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (macos-latest, 14.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 18.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 19.x)
Check failure on line 104 in src/__tests__/renderHighlightColorQuote.spec.ts GitHub Actions / build (windows-latest, 16.x)
|
||
expect(result).toBe(testCase.expected) | ||
}) | ||
}) |