@diplodoc/cli-tests 5.24.2 → 5.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/e2e/themer.test.ts
CHANGED
|
@@ -171,4 +171,71 @@ describe('Build themer feature', () => {
|
|
|
171
171
|
),
|
|
172
172
|
).toBe(true);
|
|
173
173
|
});
|
|
174
|
+
|
|
175
|
+
it.each([
|
|
176
|
+
['md2md', true, false],
|
|
177
|
+
['md2html', false, true],
|
|
178
|
+
])('generates theme.css from .yfm (%s)', async (_, md2md, md2html) => {
|
|
179
|
+
const {inputPath, outputPath} = getTestPaths('mocks/themer/test5');
|
|
180
|
+
|
|
181
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
182
|
+
md2md,
|
|
183
|
+
md2html,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const cssPath = join(outputPath, '_assets', 'style', 'theme.css');
|
|
187
|
+
const css = await readFile(cssPath, 'utf8');
|
|
188
|
+
|
|
189
|
+
expect(css).toContain('--g-color-base-brand: var(--g-color-private-base-brand-550-solid);');
|
|
190
|
+
expect(css).toContain('--g-color-private-base-brand-550-solid: rgb(255 0 0);');
|
|
191
|
+
expect(css).toContain('--g-color-private-base-brand-600-solid: rgb(234 4 5);');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it.each([
|
|
195
|
+
['md2md', true, false],
|
|
196
|
+
['md2html', false, true],
|
|
197
|
+
])('flag overrides theme from .yfm (%s)', async (_, md2md, md2html) => {
|
|
198
|
+
const {inputPath, outputPath} = getTestPaths('mocks/themer/test5');
|
|
199
|
+
|
|
200
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
201
|
+
md2md,
|
|
202
|
+
md2html,
|
|
203
|
+
args: '--theme pink',
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const cssPath = join(outputPath, '_assets', 'style', 'theme.css');
|
|
207
|
+
const css = await readFile(cssPath, 'utf8');
|
|
208
|
+
|
|
209
|
+
expect(css).toContain('--g-color-base-brand: var(--g-color-private-base-brand-550-solid);');
|
|
210
|
+
expect(css).toContain('--g-color-private-base-brand-550-solid: rgb(255 192 203);');
|
|
211
|
+
expect(css).toContain('--g-color-private-base-brand-600-solid: rgb(234 177 188);');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('add theme to front matter', async () => {
|
|
215
|
+
const {inputPath, outputPath} = getTestPaths('mocks/themer/test5');
|
|
216
|
+
|
|
217
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
218
|
+
md2md: true,
|
|
219
|
+
md2html: false,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const mdPath = join(outputPath, 'index.md');
|
|
223
|
+
const md = await readFile(mdPath, 'utf8');
|
|
224
|
+
|
|
225
|
+
expect(md).toMatch(/theme:\s*_assets[/\\]style[/\\]theme\.css/);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('does not add theme to front matter when theme.css is not generated', async () => {
|
|
229
|
+
const {inputPath, outputPath} = getTestPaths('mocks/themer/test3');
|
|
230
|
+
|
|
231
|
+
await TestAdapter.testBuildPass(inputPath, outputPath, {
|
|
232
|
+
md2md: true,
|
|
233
|
+
md2html: false,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const mdPath = join(outputPath, 'index.md');
|
|
237
|
+
const md = await readFile(mdPath, 'utf8');
|
|
238
|
+
|
|
239
|
+
expect(md).not.toMatch(/theme:\s*_assets[/\\]style[/\\]theme\.css/);
|
|
240
|
+
});
|
|
174
241
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: red
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Test for themer
|