-
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.
Added the number-field component (#48)
<!--- Provide some background and a description of your work. --> Adds the number-field foundation component. Also applied a small cleanup to some of the component testing. <!--- 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
19 changed files
with
665 additions
and
83 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-419f8bdd-3aae-4648-b038-c50fa295319d.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": "Added the number-field 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,3 @@ | ||
# Description | ||
|
||
This template is used as a number-field component template from which a user can modify without having to do the initial scaffolding. |
7 changes: 7 additions & 0 deletions
7
packages/fast-cli/src/components/number-field/template/README.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,7 @@ | ||
import type { ComponentTemplateConfig } from "../../../utilities/template"; | ||
|
||
export default (config: ComponentTemplateConfig): string => ` | ||
# ${config.className} | ||
An implementation of a [text field](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/text) 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/number-field`; |
Oops, something went wrong.