-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
10,356 additions
and
6,457 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const { testKendoComponent } = require("./utility"); | ||
|
||
testKendoComponent("appbar", "k-appbar", []); |
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,3 @@ | ||
// const { testKendoComponent } = require("./utility"); | ||
|
||
// testKendoComponent("button", "k-button", []); |
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,20 @@ | ||
// const { compileKendoTheme } = require("./utility"); | ||
// const { describe, it, expect } = require('@jest/globals'); | ||
|
||
// const customizedVariables = { | ||
// "$kendo-colors": `( | ||
// app-surface: red, | ||
// primary: red, | ||
// secondary: red, | ||
// )`, | ||
// }; | ||
|
||
// describe("Color System Module", () => { | ||
// it("should return css variables with correct values", () => { | ||
// const result = compileKendoTheme(customizedVariables); | ||
|
||
// expect(result).toContain(`--kendo-color-app-surface: red;`); | ||
// expect(result).toContain(`--kendo-color-primary: red;`); | ||
// expect(result).toContain(`--kendo-color-secondary: red;`); | ||
// }); | ||
// }); |
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,3 @@ | ||
// const { testKendoComponent } = require("./utility"); | ||
|
||
// testKendoComponent("grid", "k-grid", ["k-button"]); |
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,18 @@ | ||
// const { compileKendoTheme } = require("./utility"); | ||
// const { describe, it, expect } = require('@jest/globals'); | ||
|
||
// const customizedVariables = { | ||
// "$kendo-spacing": `( | ||
// 2: 8px, | ||
// 6: 12px | ||
// )`, | ||
// }; | ||
|
||
// describe("Spacing Module", () => { | ||
// it("should return css variables with correct values", () => { | ||
// const result = compileKendoTheme(customizedVariables); | ||
|
||
// expect(result).toContain(`--kendo-spacing-2: 8px;`); | ||
// expect(result).toContain(`--kendo-spacing-6: 12px;`); | ||
// }); | ||
// }); |
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,86 @@ | ||
const sass = require("sass"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { describe, it, expect } = require("@jest/globals"); | ||
|
||
const theme = "default"; | ||
const themeDir = path.resolve("packages", theme, "scss"); | ||
const nodeModules = path.resolve("node_modules"); | ||
const themeMetadata = path.resolve("packages", theme, "dist", "meta", "sassdoc-raw-data.json"); | ||
const jsonData = fs.readFileSync(themeMetadata); | ||
const data = JSON.parse(jsonData); | ||
|
||
function fetchComponentVariables(component) { | ||
return data.filter((item) => item.group[0] === component).map((item) => item.context.name); | ||
} | ||
|
||
function compileSassString(sassString) { | ||
return sass.compileString(sassString, { | ||
loadPaths: [themeDir, nodeModules], | ||
}).css; | ||
} | ||
|
||
function compileKendoComponent(component, uniqueVariables = {}) { | ||
const sassString = ` | ||
@use 'index.scss' as * with (${uniqueVariables}); | ||
@include kendo-${component}--styles(); | ||
`; | ||
|
||
return compileSassString(sassString); | ||
} | ||
|
||
// function compileKendoTheme(customizedVariables = {}) { | ||
// const sassString = ` | ||
// @use 'index.scss' as * with (${formatVariableString(customizedVariables)}); | ||
// @include kendo-theme--styles(); | ||
// `; | ||
|
||
// return compileSassString(sassString); | ||
// } | ||
|
||
function testKendoModule(module) { | ||
Check failure on line 41 in unit-tests/utility.js GitHub Actions / Lint scripts / run
|
||
//TODO | ||
//Here use the compileKendoTheme function to compile the module | ||
} | ||
|
||
function testKendoComponent(component, className, dependenciesClassNames = []) { | ||
describe(component, () => { | ||
const variables = fetchComponentVariables(component); | ||
const uniqueValues = []; | ||
const uniqueVariables = variables | ||
.map((property, index) => { | ||
const uniqueValue = `unique-value-${index}`; // TODO: modify the pattern for unique values | ||
uniqueValues.push(uniqueValue); | ||
return `$${property}: ${uniqueValue},`; | ||
}) | ||
.join("\n"); | ||
|
||
const result = compileKendoComponent(component, uniqueVariables); | ||
|
||
// it("should compile", () => { | ||
// const result = compileKendoComponent("appbar", customizedVariables); | ||
// }); | ||
className && | ||
it("Should have component selector styles", () => { | ||
expect(result).toContain(`.${className} {`); | ||
}); | ||
|
||
it("It's variable customizations should work", () => { | ||
uniqueValues.forEach((value) => { | ||
expect(result).toContain(`${value};`); | ||
}); | ||
}); | ||
|
||
dependenciesClassNames && | ||
it("Should have dependency selector styles", () => { | ||
dependenciesClassNames.forEach((className) => { | ||
expect(result).toContain(`.${className} {`); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
testKendoComponent, | ||
compileKendoComponent | ||
}; |