-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the checkbox foundation component. Also moved some helper files for the component testing to a separate file and moved a component test to the components folder. <!--- List and link relevant issues here using the keyword "closes" if this PR will close an issue, eg. closes #411 --> Continues work on #31 <!--- Review the list and put an x in the boxes that apply. --> - [x] I have added tests for my changes. - [x] I have tested my changes. - [x] I have updated the project documentation to reflect my changes. <!--- If there is relevant follow-up work to this PR, please list any existing issues or provide brief descriptions of what you would like to do next. --> - Continue adding foundation components
- Loading branch information
Showing
18 changed files
with
543 additions
and
89 deletions.
There are no files selected for viewing
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
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-cli-d7e4ef82-ac8f-4d95-85b0-4a7e39f6fb85.json
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,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "Add the checkbox component", | ||
"packageName": "@microsoft/fast-cli", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "none" | ||
} |
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 @@ | ||
# Description | ||
|
||
This template is used as a checkbox component template from which a user can modify without having to do the initial scaffolding. |
59 changes: 59 additions & 0 deletions
59
packages/fast-cli/src/components/checkbox/template.pw.spec.ts
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,59 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { execSync } from "child_process"; | ||
import path from "path"; | ||
import fs from "fs-extra"; | ||
import { | ||
expectedGeneratedComponentTemplateFiles, | ||
setup, | ||
teardown, | ||
getTempDir, | ||
getTempComponentDir, | ||
} from "../../test/helpers.js"; | ||
|
||
const uuid: string = "checkbox"; | ||
const tempDir: string = getTempDir(uuid); | ||
const tempComponentDir: string = getTempComponentDir(uuid); | ||
|
||
test.describe(`CLI add-foundation-component ${uuid}`, () => { | ||
test.beforeAll(() => { | ||
setup(tempDir, tempComponentDir); | ||
execSync(`cd ${tempDir} && npm run fast:init`); | ||
setup(tempDir, tempComponentDir); | ||
execSync(`cd ${tempDir} && npm run fast:add-foundation-component:${uuid}`); | ||
}); | ||
test.afterAll(() => { | ||
teardown(tempDir, tempComponentDir); | ||
}); | ||
test("should copy files from the template", () => { | ||
let files: Array<string> = []; | ||
|
||
function testGeneratedFiles(folderName: string) { | ||
const tempDirContents = fs.readdirSync(path.resolve(tempDir, "src/components/test-component", folderName)); | ||
const tempDirContentsWithFileTypes = fs.readdirSync(path.resolve(tempDir, "src/components/test-component", folderName), { | ||
withFileTypes: true | ||
}); | ||
|
||
for (let i = 0, contentLength = tempDirContents.length; i < contentLength; i++) { | ||
if (tempDirContentsWithFileTypes[i].isDirectory()) { | ||
testGeneratedFiles(tempDirContents[i]); | ||
} else { | ||
files.push( | ||
folderName | ||
? `${folderName}/${tempDirContents[i]}` | ||
: tempDirContents[i] | ||
); | ||
} | ||
} | ||
} | ||
|
||
testGeneratedFiles(""); | ||
expect(files).toEqual(expectedGeneratedComponentTemplateFiles); | ||
}); | ||
test("should be able to run the build", () => { | ||
expect( | ||
() => { | ||
execSync(`cd ${tempDir} && npm run build`); | ||
} | ||
).not.toThrow(); | ||
}); | ||
}); |
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,7 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
# ${config.className} | ||
An implementation of a [checkbox](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/checkbox) as a form-connected web-component. | ||
For more information on the building blocks used to create this component, please refer to https://www.fast.design/docs/components/checkbox`; |
Oops, something went wrong.