diff --git a/library/core/components/option-node.ts b/library/core/components/option-node.ts index c913a0f..4090b9e 100644 --- a/library/core/components/option-node.ts +++ b/library/core/components/option-node.ts @@ -5,7 +5,7 @@ import type { OptionProps } from "./option" export class OptionNode extends Node { get options(): MessageSelectOptionOptions { return { - label: this.props.children || this.props.label || this.props.value || "", + label: this.props.children || this.props.label || this.props.value, value: this.props.value, description: this.props.description, emoji: this.props.emoji, diff --git a/library/internal/text-node.ts b/library/internal/text-node.ts index a4baeeb..973b253 100644 --- a/library/internal/text-node.ts +++ b/library/internal/text-node.ts @@ -3,6 +3,6 @@ import { Node } from "./node.js" export class TextNode extends Node { override modifyMessageOptions(options: MessageOptions) { - options.content = (options.content ?? "") + this.props + options.content = options.content + this.props } } diff --git a/package.json b/package.json index 83938e7..6abe27d 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "devDependencies": { "@itsmapleleaf/configs": "^1.1.2", + "@jest/globals": "^27.4.4", "@types/jest": "^27.0.3", "@types/lodash-es": "^4.17.5", "@typescript-eslint/eslint-plugin": "^5.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b731a62..adbec05 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,7 @@ importers: .: specifiers: '@itsmapleleaf/configs': ^1.1.2 + '@jest/globals': ^27.4.4 '@types/jest': ^27.0.3 '@types/lodash-es': ^4.17.5 '@types/node': '*' @@ -50,6 +51,7 @@ importers: rxjs: 7.4.0 devDependencies: '@itsmapleleaf/configs': 1.1.2 + '@jest/globals': 27.4.4 '@types/jest': 27.0.3 '@types/lodash-es': 4.17.5 '@typescript-eslint/eslint-plugin': 5.8.0_836011a006f4f5d67178564baf2b6d34 diff --git a/test/select.test.tsx b/test/select.test.tsx index 58fa1a0..c8f0a0d 100644 --- a/test/select.test.tsx +++ b/test/select.test.tsx @@ -1,10 +1,13 @@ +import { jest } from "@jest/globals" import React, { useState } from "react" import { Button, Option, Select } from "../library/main" import { setupReacordTesting } from "./setup-testing" -const { adapter, reply, assertMessages } = setupReacordTesting() +const { adapter, reply, assertRender, assertMessages } = setupReacordTesting() test("single select", async () => { + const onSelect = jest.fn() + function TestSelect() { const [value, setValue] = useState() const [disabled, setDisabled] = useState(false) @@ -13,11 +16,12 @@ test("single select", async () => {