Skip to content

Commit bb39565

Browse files
committed
test(ProjectBuilder): Add cases for theme.library.e with seperate less files
1 parent 935d925 commit bb39565

1 file changed

Lines changed: 66 additions & 7 deletions

File tree

packages/project/test/lib/build/ProjectBuilder.integration.js

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,16 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
222222
});
223223

224224
// Change a source file in theme.library.e
225-
const changedFilePath = `${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/library.source.less`;
226-
await fs.appendFile(changedFilePath, `\n.someNewClass {\n\tcolor: red;\n}\n`);
227-
225+
const librarySourceFilePath =
226+
`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/library.source.less`;
227+
await fs.appendFile(librarySourceFilePath, `\n.someNewClass {\n\tcolor: red;\n}\n`);
228228
// #3 build (with cache, with changes)
229229
await fixtureTester.buildProject({
230230
config: {destPath, cleanDest: true},
231231
assertions: {
232232
projects: {"theme.library.e": {}}
233233
}
234234
});
235-
236235
// Check whether the changed file is in the destPath
237236
const builtFileContent = await fs.readFile(
238237
`${destPath}/resources/theme/library/e/themes/my_theme/library.source.less`, {encoding: "utf8"}
@@ -241,7 +240,7 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
241240
builtFileContent.includes(`.someNewClass`),
242241
"Build dest contains changed file content"
243242
);
244-
// Check whether the updated copyright replacement took place
243+
// Check whether the build output contains the new CSS rule
245244
const builtCssContent = await fs.readFile(
246245
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
247246
);
@@ -250,11 +249,71 @@ test.serial("Build theme.library.e project multiple times", async (t) => {
250249
"Build dest contains new rule in library.css"
251250
);
252251

253-
// #4 build (with cache, no changes)
252+
// Add a new less file and import it in library.source.less
253+
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
254+
`.someOtherNewClass {\n\tcolor: blue;\n}\n`
255+
);
256+
await fs.appendFile(librarySourceFilePath, `\n@import "newImportFile.less";\n`);
257+
// #4 build (with cache, with changes)
254258
await fixtureTester.buildProject({
255259
config: {destPath, cleanDest: true},
256260
assertions: {
257-
projects: {}
261+
projects: {"theme.library.e": {}},
262+
}
263+
});
264+
// Check whether the build output contains the import to the new file
265+
const builtCssContent2 = await fs.readFile(
266+
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
267+
);
268+
t.true(
269+
builtCssContent2.includes(`.someOtherNewClass`),
270+
"Build dest contains new rule in library.css"
271+
);
272+
273+
// #5 build (with cache, no changes)
274+
await fixtureTester.buildProject({
275+
config: {destPath, cleanDest: true},
276+
assertions: {
277+
projects: {},
278+
}
279+
});
280+
281+
// Change content of new less file
282+
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
283+
`.someOtherNewClass {\n\tcolor: green;\n}\n`
284+
);
285+
// #6 build (with cache, with changes)
286+
await fixtureTester.buildProject({
287+
config: {destPath, cleanDest: true},
288+
assertions: {
289+
projects: {"theme.library.e": {}},
290+
}
291+
});
292+
// Check whether the build output contains the changed content of the imported file
293+
const builtCssContent3 = await fs.readFile(
294+
`${destPath}/resources/theme/library/e/themes/my_theme/library.css`, {encoding: "utf8"}
295+
);
296+
t.true(
297+
builtCssContent3.includes(`.someOtherNewClass{color:green}`),
298+
"Build dest contains new rule in library.css"
299+
);
300+
301+
// Delete import of library.source.less
302+
const librarySourceFileContent = (await fs.readFile(librarySourceFilePath)).toString();
303+
await fs.writeFile(librarySourceFilePath,
304+
librarySourceFileContent.replace(`\n@import "newImportFile.less";\n`, "")
305+
);
306+
// Change content of new less file again
307+
await fs.writeFile(`${fixtureTester.fixturePath}/src/theme/library/e/themes/my_theme/newImportFile.less`,
308+
`.someOtherNewClass {\n\tcolor: yellow;\n}\n`
309+
);
310+
// #7 build (with cache, with changes)
311+
await fixtureTester.buildProject({
312+
config: {destPath, cleanDest: true},
313+
assertions: {
314+
projects: {"theme.library.e": {
315+
skippedTasks: ["buildThemes"]
316+
}},
258317
}
259318
});
260319
});

0 commit comments

Comments
 (0)