-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rewrite-select
- Loading branch information
Showing
8 changed files
with
149 additions
and
21 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
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,42 @@ | ||
import { fireEvent } from "@testing-library/react"; | ||
import { ButtonGroup, ButtonGroupProps } from "./ButtonGroup"; | ||
import { renderCUI } from "@/utils/test-utils"; | ||
|
||
describe("ButtonGroup", () => { | ||
const renderButtonGroup = (props: ButtonGroupProps) => | ||
renderCUI(<ButtonGroup {...props} />); | ||
const labels = ["Option 1", "Option 2", "Option 3"]; | ||
|
||
it("renders buttons with labels correctly", () => { | ||
const { getByText } = renderButtonGroup({ labels: labels }); | ||
|
||
labels.forEach(label => { | ||
expect(getByText(label).textContent).toBe(label); | ||
}); | ||
}); | ||
|
||
it("calls onClick handler when a button is clicked", () => { | ||
let counter = 0; | ||
const handleClick = () => (counter = 1); | ||
|
||
const { getByText } = renderButtonGroup({ | ||
labels: labels, | ||
onClick: handleClick, | ||
}); | ||
|
||
fireEvent.click(getByText("Option 2")); | ||
|
||
expect(counter).toEqual(1); | ||
}); | ||
|
||
it("adds 'active' class to the active button", () => { | ||
const { getByText } = renderButtonGroup({ | ||
labels: labels, | ||
activeIndex: 1, | ||
}); | ||
|
||
const activeButton = getByText("Option 2"); | ||
|
||
expect(activeButton).active == true; | ||
}); | ||
}); |
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
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 |
---|---|---|
|
@@ -1897,6 +1897,9 @@ | |
"default": string | ||
} | ||
}, | ||
"size": { | ||
"width": string | ||
}, | ||
"color": { | ||
"title": { | ||
"default": string | ||
|
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,60 @@ | ||
// vite.config.ts | ||
import { defineConfig } from "file:///Users/garethjones/Sites/click-ui/node_modules/vite/dist/node/index.js"; | ||
import react from "file:///Users/garethjones/Sites/click-ui/node_modules/@vitejs/plugin-react/dist/index.mjs"; | ||
import path, { resolve } from "path"; | ||
import dts from "file:///Users/garethjones/Sites/click-ui/node_modules/vite-plugin-dts/dist/index.mjs"; | ||
var __vite_injected_original_dirname = "/Users/garethjones/Sites/click-ui"; | ||
var vite_config_default = defineConfig({ | ||
plugins: [ | ||
react({ | ||
babel: { | ||
plugins: [["babel-plugin-styled-components", { displayName: false }]], | ||
env: { | ||
development: { | ||
plugins: [["babel-plugin-styled-components", { displayName: true }]] | ||
} | ||
} | ||
} | ||
}), | ||
dts({ | ||
include: ["src/"], | ||
exclude: ["**/*.stories.ts", "**/*.stories.tsx", "**/*.test.ts", "**/*.test.tsx"] | ||
}) | ||
], | ||
resolve: { | ||
alias: { | ||
"@": path.resolve(__vite_injected_original_dirname, "./src") | ||
} | ||
}, | ||
build: { | ||
lib: { | ||
entry: resolve(__vite_injected_original_dirname, "src/index.ts"), | ||
name: "click-ui", | ||
formats: ["es", "umd"], | ||
fileName: (format) => `click-ui.${format}.js` | ||
}, | ||
rollupOptions: { | ||
// Add _all_ external dependencies here | ||
external: [ | ||
"react", | ||
"react-dom", | ||
"styled-components", | ||
"**/*.stories.ts", | ||
"**/*.stories.tsx", | ||
"**/*.test.ts", | ||
"**/*.test.tsx" | ||
], | ||
output: { | ||
globals: { | ||
react: "React", | ||
"styled-components": "styled", | ||
"react-dom": "ReactDOM" | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
export { | ||
vite_config_default as default | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvZ2FyZXRoam9uZXMvU2l0ZXMvY2xpY2stdWlcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9nYXJldGhqb25lcy9TaXRlcy9jbGljay11aS92aXRlLmNvbmZpZy50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvZ2FyZXRoam9uZXMvU2l0ZXMvY2xpY2stdWkvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tIFwidml0ZVwiO1xuaW1wb3J0IHJlYWN0IGZyb20gXCJAdml0ZWpzL3BsdWdpbi1yZWFjdFwiO1xuaW1wb3J0IHBhdGgsIHsgcmVzb2x2ZSB9IGZyb20gXCJwYXRoXCI7XG5pbXBvcnQgZHRzIGZyb20gXCJ2aXRlLXBsdWdpbi1kdHNcIjtcblxuLy8gaHR0cHM6Ly92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