Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: Prerelease 7.5.0-alpha.6 #24419

Merged
merged 66 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2191679
fix(Select.tsx): added value prop to select and multiselect
oxcened May 1, 2023
41dd534
fix(basics.stories.ts): fixed select and multiselect controls, added …
oxcened May 1, 2023
afd96e7
test(addon-controls.spec.ts): check that options which value contain …
oxcened May 1, 2023
1490497
Merge branch 'next' into fix-select-double-spaces
JReinhold Aug 29, 2023
8978776
Add url for themes icon
Aug 29, 2023
9869282
Update chromatic-github-action.js.mdx
natehouk Sep 2, 2023
68465b0
Merge branch 'next' into fix-select-double-spaces
ndelangen Sep 19, 2023
dd0d1be
Merge branch 'storybookjs:next' into next
natehouk Sep 20, 2023
1bfdfb1
Update chromatic-github-action.js.mdx
natehouk Sep 20, 2023
b3674b8
Update chromatic-github-action.js.mdx
natehouk Sep 20, 2023
8dc11d5
Merge branch 'next' into fix-select-double-spaces
yannbf Oct 3, 2023
e1af53a
Remove file URL examples from storyshots-puppetteer docs
irangarcia Oct 3, 2023
39a7b27
Merge branch 'next' into docs/remove-deprecated-file-url
irangarcia Oct 4, 2023
15370fd
Add instructions for installing yarn
IanVS Oct 5, 2023
806ea52
Add step to cd into storybook directory
IanVS Oct 5, 2023
bcef966
Merge branch 'next' into docs/remove-deprecated-file-url
irangarcia Oct 7, 2023
c74abef
fix: pass when callee.name equals local.name
yoshi2no Oct 8, 2023
83c5b00
fix: use imported.name as a functionName
yoshi2no Oct 8, 2023
c304067
feat: update test of TransformFontImports
yoshi2no Oct 8, 2023
cbcea15
fix bad non-patch renaming
JReinhold Oct 9, 2023
89af803
Merge pull request #24361 from irangarcia/docs/remove-deprecated-file…
ndelangen Oct 9, 2023
64e1ac9
Merge pull request #24409 from storybookjs/fix-publishing
JReinhold Oct 9, 2023
05eb71f
Merge branch 'next' into fix-select-double-spaces
ndelangen Oct 9, 2023
77d2da2
Merge pull request #22334 from oxcened/fix-select-double-spaces
ndelangen Oct 9, 2023
6018ef7
Update packages
cdedreuille Oct 9, 2023
4581321
Remove old styles
cdedreuille Oct 9, 2023
3332ca2
Update ScrollArea
cdedreuille Oct 9, 2023
1820326
Fix Sidebar
cdedreuille Oct 9, 2023
cbbdeaa
Change to lowercase
cdedreuille Oct 9, 2023
ccffdc3
Merge pull request #24406 from yoshi2no/fix/rename-font-import/yoshi2no
valentinpalkovic Oct 9, 2023
4dd6782
Fix emotion issues
cdedreuille Oct 9, 2023
488a243
Merge branch 'next' into yarn-instructions
jonniebigodes Oct 9, 2023
e03993c
Fix capitalization
jonniebigodes Oct 9, 2023
4d3ff76
Merge branch 'next-release' into next
storybook-bot Oct 9, 2023
0a06536
Merge branch 'next' into yarn-instructions
jonniebigodes Oct 9, 2023
d42aae3
Merge pull request #24386 from storybookjs/yarn-instructions
jonniebigodes Oct 9, 2023
72ab5b3
Update chromatic-github-action.js.mdx
natehouk Oct 10, 2023
beeab50
Merge pull request #24413 from storybookjs/move-scrollarea-to-radix
cdedreuille Oct 10, 2023
1fc5ed4
upgrade to node18 in a backwards compatible way
ndelangen Oct 10, 2023
e9313b7
Update CI to Node.js v18
valentinpalkovic Oct 9, 2023
483eb52
Update @types/node to v18
valentinpalkovic Oct 10, 2023
b078e37
Apply suggestions from code review
ndelangen Oct 10, 2023
b23680c
Merge branch 'valentin/update-to-node-18' into norbert/node18
ndelangen Oct 10, 2023
edd0f61
Replace setting node version to nvmrc
valentinpalkovic Oct 10, 2023
dc9a774
Increase node version in scripts/.babelrc
valentinpalkovic Oct 10, 2023
f67071f
Merge pull request #24426 from storybookjs/norbert/node18
ndelangen Oct 10, 2023
9e1ec61
Update chromatic-github-action.js.mdx
natehouk Oct 10, 2023
7efefba
Merge branch 'next' into shaun/add-theming-icon
jonniebigodes Oct 10, 2023
37f33ab
Merge pull request #24414 from storybookjs/valentin/update-to-node-18
valentinpalkovic Oct 11, 2023
3146415
Add argsToTemplate helper function
valentinpalkovic Oct 11, 2023
c769e4b
Rewrite Angular Stories to CSF 3
valentinpalkovic Oct 11, 2023
a42f7b9
Support event bindings in argsToTemplate
valentinpalkovic Oct 11, 2023
79c2381
Update docs to mention argsToTemplate
valentinpalkovic Oct 11, 2023
7bec7b3
Replace 'storyName' with 'name' in Angular stories
valentinpalkovic Oct 11, 2023
a1fdb68
Add Stories to cover argsToTemplate functionality
valentinpalkovic Oct 11, 2023
55d6b8d
Web-components: Add Lit3 support
shilman Oct 11, 2023
7f337b1
Merge pull request #24437 from storybookjs/shilman/lit3
shilman Oct 11, 2023
f1494f6
Merge branch 'next' into shaun/add-theming-icon
Oct 11, 2023
1cdee6a
Update README.md gif
Oct 11, 2023
a9d1dfc
Merge pull request #24434 from storybookjs/valentin/angular-args-to-t…
yannbf Oct 11, 2023
f24058b
Merge branch 'next' into next
jonniebigodes Oct 11, 2023
1a455e5
Merge branch 'next' into shaun/add-theming-icon
Oct 11, 2023
1a16894
Addon: Add catalog icon for addon-themes #23995
Oct 11, 2023
a74ba7c
Merge branch 'next' into next
jonniebigodes Oct 11, 2023
0b5697f
Merge pull request #24054 from natehouk/next
jonniebigodes Oct 11, 2023
87ad0ab
Write changelog for 7.5.0-alpha.6 [skip ci]
storybook-bot Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ executors:
default: 'small'
working_directory: /tmp/storybook
docker:
- image: cimg/node:16.20.0
- image: cimg/node:18.18.0
environment:
NODE_OPTIONS: --max_old_space_size=6144
resource_class: <<parameters.class>>
Expand All @@ -30,7 +30,7 @@ executors:
default: 'small'
working_directory: /tmp/storybook
docker:
- image: cimg/node:16.20.0-browsers
- image: cimg/node:18.18.0-browsers
environment:
NODE_OPTIONS: --max_old_space_size=6144
resource_class: <<parameters.class>>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-sandboxes-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: '.nvmrc'
- uses: actions/checkout@v3
with:
ref: main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-sandboxes-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: '.nvmrc'
- uses: actions/checkout@v3
with:
ref: next
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ on:

jobs:
build:
name: Core Unit Tests node-${{ matrix.node_version }}, ${{ matrix.os }}
name: Core Unit Tests, ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
node_version: [16]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set node version to ${{ matrix.node_version }}
- name: Set node version
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
node-version-file: '.nvmrc'
- name: install and compile
run: yarn task --task compile --start-from=auto --no-link
- name: test
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20
18.18
8 changes: 8 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 7.5.0-alpha.6

- Angular: Introduce argsToTemplate for property and event Bindings - [#24434](https://github.com/storybookjs/storybook/pull/24434), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- Controls: Fix select / multiselect when value contains multiple spaces - [#22334](https://github.com/storybookjs/storybook/pull/22334), thanks [@oxcened](https://github.com/oxcened)!
- Next.js: Support rename font import - [#24406](https://github.com/storybookjs/storybook/pull/24406), thanks [@yoshi2no](https://github.com/yoshi2no)!
- UI: Update ScrollArea with radix - [#24413](https://github.com/storybookjs/storybook/pull/24413), thanks [@cdedreuille](https://github.com/cdedreuille)!
- Web-components: Add Lit3 support - [#24437](https://github.com/storybookjs/storybook/pull/24437), thanks [@shilman](https://github.com/shilman)!

## 7.5.0-alpha.5

- Angular: Add CLI options (debugWebpack, webpackStatsJson, and more) - [#24388](https://github.com/storybookjs/storybook/pull/24388), thanks [@yannbf](https://github.com/yannbf)!
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ A few key points to note in this flow:

Patch releases are created by [cherry-picking](https://www.atlassian.com/git/tutorials/cherry-pick) any merged, unreleased pull requests that have the "**patch:yes**" label applied to the `next` branch. The merge commit of said pull requests are cherry-picked.

Sometimes it is desired to pick pull requests back to `main` even if they are not considered "releasable". Unlike non-patch-release preparation, patch releases will not be canceled if the content is not releasable. It might not make sense to create a new patch release if the changes are only for documentation and/or internal build systems. However, getting the changes back to `main` is the only way to deploy the documentation to the production docs site. You may also want to cherry-pick changes to internal CI to fix issues. These are valid scenarios where you want to cherry-pick the changes without being blocked on "releasable" content. In these cases, where all cherry picks are non-releasable, the preparation workflow creates a "merging" pull request instead of a "releasing" pull request. This pull request does not bump versions or update changelogs; it just cherry-picks the changes and allows you to merge them into `latest-release` -> `main`.
Sometimes it is desired to pick pull requests back to `main` even if they are not considered "releasable". Unlike non-patch release preparation, patch releases will not be canceled if the content is not releasable. It might not make sense to create a new patch release if the changes are only for documentation and/or internal build systems. However, getting the changes back to `main` is the only way to deploy the documentation to the production docs site. You may also want to cherry-pick changes to internal CI to fix issues. These are valid scenarios where you want to cherry-pick the changes without being blocked on "releasable" content. In these cases, where all cherry picks are non-releasable, the preparation workflow creates a "merging" pull request instead of a "releasing" pull request. This pull request does not bump versions or update changelogs; it just cherry-picks the changes and allows you to merge them into `latest-release` -> `main`.

The preparation workflow sequentially cherry-picks each patch pull request to its branch. If this cherry-picking fails due to conflicts or other reasons, it is ignored and the next pull request is processed. All failing cherry-picks are listed in the release pull request's description, for the Releaser to manually cherry-pick during the release process. This problem occurs more often when `main` and `next` diverge, i.e. the longer it has been since a stable major/minor release.

Similar to the non-patch-release flow, the preparation workflow for patches will create a new branch from `main` called `version-patch-from-<CURRENT-STABLE-VERSION>`, and open a pull request that targets `latest-release`. When the pull request is merged by the Releaser, the [publish workflow](#publishing) will eventually merge `latest-release` into `main`.
Similar to the non-patch release flow, the preparation workflow for patches will create a new branch from `main` called `version-patch-from-<CURRENT-STABLE-VERSION>`, and open a pull request that targets `latest-release`. When the pull request is merged by the Releaser, the [publish workflow](#publishing) will eventually merge `latest-release` into `main`.

Here is an example of a workflow where a feature and two bug fixes have been merged to `next`. Only the bug fixes have the "**patch:yes**" label, so only those two go into the new `7.0.19` release. Note that it is the merge commits to `next` that are cherry-picked, not the commits on the bugfix branches.

Expand Down Expand Up @@ -173,7 +173,7 @@ gitGraph
> **Note**
> Workflow: [`prepare-non-patch-release.yml`](../.github/workflows/prepare-non-patch-release.yml)

Non-patch-releases are prepared with all content from the `next` branch. The changelog is generated by examining the git history, and looking up all the commits and pull requests between the current prerelease (on `next-release`) and `HEAD` of `next`.
Non-patch releases are prepared with all content from the `next` branch. The changelog is generated by examining the git history, and looking up all the commits and pull requests between the current prerelease (on `next-release`) and `HEAD` of `next`.

The default versioning strategy is to increase the current prerelease number, as described in [Prereleases - `7.1.0-alpha.12` -> `7.1.0-alpha.13`](#prereleases---710-alpha12---710-alpha13). If there is no prerelease number (i.e., we just released a new stable minor/major version), it will add one to a patch bump, so it would go from `7.2.0` to `7.2.1-0` by default.

Expand Down Expand Up @@ -215,7 +215,7 @@ gitGraph
> **Note**
> Workflow: [`publish.yml`](../.github/workflows/publish.yml)

When either a non-patch-release or a patch release branch is merged into `latest-release` or `next-release`, the publishing workflow is triggered. This workflow performs the following tasks:
When either a non-patch release or a patch release branch is merged into `latest-release` or `next-release`, the publishing workflow is triggered. This workflow performs the following tasks:

1. Bump versions of all packages according to the plan from the prepared PRs
2. Install dependencies and build all packages.
Expand Down Expand Up @@ -306,7 +306,7 @@ The workflows can be triggered here:

Crucially for prereleases, this is also where you change the versioning strategy if you need something else than the default as described in [Preparing - Non-patch Releases](#non-patch-releases). When triggering the non-patch workflow manually, you can optionally add inputs:

![Screenshot of triggering the non-patch-release workflow in GitHub Actions, with a form that shows a release type selector and a prerelease identifier text field](prerelease-workflow-inputs.png)
![Screenshot of triggering the non-patch release workflow in GitHub Actions, with a form that shows a release type selector and a prerelease identifier text field](prerelease-workflow-inputs.png)

See [Versioning Scenarios](#versioning-scenarios) for a description of each version bump scenario, how to activate it and what it does, and [Which combination of inputs creates the version bump I need?](#which-combination-of-inputs-creates-the-version-bump-i-need) for a detailed description of the workflow inputs.

Expand Down Expand Up @@ -376,7 +376,7 @@ Before you start you should make sure that your working tree is clean and the re
4. `git add ./CHANGELOG.md`
5. `git commit -m "Update CHANGELOG.md for v<NEXT_VERSION>"`
6. `git push origin`
19. (If non-patch-release) Sync `versions/next.json` from `next` to `main`
19. (If non-patch release) Sync `versions/next.json` from `next` to `main`
1. `git checkout main`
2. `git pull`
3. `git checkout origin/next ./docs/versions/next.json`
Expand Down
4 changes: 2 additions & 2 deletions code/addons/controls/template/stories/basics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default {
control: { type: 'radio', options: ['a', 'b', 'c'], labels: ['alpha', 'beta', 'gamma'] },
},
inlineRadio: { control: { type: 'inline-radio', options: ['a', 'b', 'c'] } },
select: { control: { type: 'select', options: ['a', 'b', 'c'] } },
multiSelect: { control: { type: 'multi-select', options: ['a', 'b', 'c'] } },
select: { control: 'select', options: ['a', 'b', 'c', 'double space'] },
multiSelect: { control: { type: 'multi-select' }, options: ['a', 'b', 'c', 'double space'] },
range: { control: 'range' },
rangeCustom: { control: { type: 'range', min: 0, max: 1000, step: 100 } },
text: { control: 'text' },
Expand Down
2 changes: 1 addition & 1 deletion code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"@devtools-ds/object-inspector": "^1.1.2",
"@storybook/jest": "next",
"@storybook/testing-library": "next",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"formik": "^2.2.9",
"typescript": "~4.9.3"
},
Expand Down
17 changes: 1 addition & 16 deletions code/addons/storyshots-puppeteer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ When running Puppeteer tests for your stories, you have two options:
- Have a storybook running (ie. accessible via http(s), for instance using `npm run storybook`)
- Have a static build of the storybook (for instance, using `npm run build-storybook`)

Then you will need to reference the storybook URL (`file://...` if local, `http(s)://...` if served)
Then you will need to reference the storybook URL (`http(s)://...`)

## _puppeteerTest_

Expand Down Expand Up @@ -72,21 +72,6 @@ initStoryshots({

The above config will use _<https://my-specific-domain.com:9010>_ for tests. You can also use query parameters in your URL (e.g. for setting a different background for your storyshots, if you use `@storybook/addon-backgrounds`).

You may also use a local static build of storybook if you do not want to run the webpack dev-server:

```js
import initStoryshots from '@storybook/addon-storyshots';
import { puppeteerTest } from '@storybook/addon-storyshots-puppeteer';

initStoryshots({
suite: 'Puppeteer storyshots',
test: puppeteerTest({
storybookUrl: 'file:///path/to/my/storybook-static',
// storybookUrl: 'file://${path.resolve(__dirname, '../storybook-static')}'
}),
});
```

### Specifying options to _goto()_ (Puppeteer API)

You might use `getGotoOptions` to specify options when the storybook is navigating to a story (using the `goto` method). Will be passed to [Puppeteer .goto() fn](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options)
Expand Down
2 changes: 1 addition & 1 deletion code/addons/themes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Storybook Addon Themes can be used which between multiple themes for components inside the preview in [Storybook](https://storybook.js.org).

![React Storybook Screenshot](https://user-images.githubusercontent.com/42671/98158421-dada2300-1ea8-11eb-8619-af1e7018e1ec.png)
![React Storybook Screenshot](https://user-images.githubusercontent.com/18172605/274302488-77a39112-cdbe-4d16-9966-0d8e9e7e3399.gif)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion code/addons/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@
"unsupportedFrameworks": [
"react-native"
],
"icon": ""
"icon": "https://user-images.githubusercontent.com/18172605/264114587-e4b32190-a9b7-4afa-b739-c873fc0498a6.png"
}
}
2 changes: 1 addition & 1 deletion code/builders/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"glob": "^10.0.0",
"rollup": "^3.20.1",
"slash": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@storybook/preview": "workspace:*",
"@storybook/preview-api": "workspace:*",
"@swc/core": "^1.3.82",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/semver": "^7.3.4",
"babel-loader": "^9.0.0",
"babel-plugin-named-exports-order": "^0.0.2",
Expand Down
27 changes: 27 additions & 0 deletions code/e2e-tests/addon-controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,31 @@ test.describe('addon-controls', () => {
const label = await sbPage.panelContent().locator('textarea[name=label]').inputValue();
await expect(label).toEqual('Hello world');
});

test('should set select option when value contains double spaces', async ({ page }) => {
await page.goto(`${storybookUrl}?path=/story/addons-controls-basics--undefined`);

const sbPage = new SbPage(page);
await sbPage.waitUntilLoaded();
await sbPage.viewAddonPanel('Controls');
await sbPage.panelContent().locator('#control-select').selectOption('double space');

await expect(sbPage.panelContent().locator('#control-select')).toHaveValue('double space');
await expect(page).toHaveURL(/.*select:double\+\+space.*/);
});

test('should set multiselect option when value contains double spaces', async ({ page }) => {
await page.goto(`${storybookUrl}?path=/story/addons-controls-basics--undefined`);

const sbPage = new SbPage(page);
await sbPage.waitUntilLoaded();
await sbPage.viewAddonPanel('Controls');
await sbPage.panelContent().locator('#control-multiSelect').selectOption('double space');

await expect(sbPage.panelContent().locator('#control-multiSelect')).toHaveValue(
'double space'
);

await expect(page).toHaveURL(/.*multiSelect\[0]:double\+\+space.*/);
});
});
2 changes: 1 addition & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@storybook/preview-api": "workspace:*",
"@storybook/telemetry": "workspace:*",
"@storybook/types": "workspace:*",
"@types/node": "^16.0.0",
"@types/node": "^18.0.0",
"@types/react": "^16.14.34",
"@types/react-dom": "^16.9.14",
"@types/semver": "^7.3.4",
Expand Down
102 changes: 102 additions & 0 deletions code/frameworks/angular/src/client/argsToTemplate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { argsToTemplate, ArgsToTemplateOptions } from './argsToTemplate'; // adjust path

describe('argsToTemplate', () => {
it('should correctly convert args to template string and exclude undefined values', () => {
const args: Record<string, any> = {
prop1: 'value1',
prop2: undefined,
prop3: 'value3',
};
const options: ArgsToTemplateOptions<keyof typeof args> = {};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
});

it('should include properties from include option', () => {
const args = {
prop1: 'value1',
prop2: 'value2',
prop3: 'value3',
};
const options: ArgsToTemplateOptions<keyof typeof args> = {
include: ['prop1', 'prop3'],
};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
});

it('should include non-undefined properties from include option', () => {
const args: Record<string, any> = {
prop1: 'value1',
prop2: 'value2',
prop3: undefined,
};
const options: ArgsToTemplateOptions<keyof typeof args> = {
include: ['prop1', 'prop3'],
};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1"');
});

it('should exclude properties from exclude option', () => {
const args = {
prop1: 'value1',
prop2: 'value2',
prop3: 'value3',
};
const options: ArgsToTemplateOptions<keyof typeof args> = {
exclude: ['prop2'],
};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
});

it('should exclude properties from exclude option and undefined properties', () => {
const args: Record<string, any> = {
prop1: 'value1',
prop2: 'value2',
prop3: undefined,
};
const options: ArgsToTemplateOptions<keyof typeof args> = {
exclude: ['prop2'],
};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1"');
});

it('should prioritize include over exclude when both options are given', () => {
const args = {
prop1: 'value1',
prop2: 'value2',
prop3: 'value3',
};
const options: ArgsToTemplateOptions<keyof typeof args> = {
include: ['prop1', 'prop2'],
exclude: ['prop2', 'prop3'],
};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1" [prop2]="prop2"');
});

it('should work when neither include nor exclude options are given', () => {
const args = {
prop1: 'value1',
prop2: 'value2',
};
const options: ArgsToTemplateOptions<keyof typeof args> = {};
const result = argsToTemplate(args, options);
expect(result).toBe('[prop1]="prop1" [prop2]="prop2"');
});

it('should bind events correctly when value is a function', () => {
const args = { event1: () => {}, event2: () => {} };
const result = argsToTemplate(args, {});
expect(result).toEqual('(event1)="event1($event)" (event2)="event2($event)"');
});

it('should mix properties and events correctly', () => {
const args = { input: 'Value1', event1: () => {} };
const result = argsToTemplate(args, {});
expect(result).toEqual('[input]="input" (event1)="event1($event)"');
});
});
Loading
Loading