import { beforeEach, describe, expect, it } from 'vitest';
import { mount, shallowMount } from '@vue/test-utils';
import { createPinia, setActivePinia } from 'pinia';
import _ from 'lodash';
import CInputText from './c-input-text.vue';
import { useValidation } from '@/composable/validation';
describe('CInputText', () => {
beforeEach(() => {
setActivePinia(createPinia());
});
it('Renders a label', () => {
const wrapper = shallowMount(CInputText, {
props: {
label: 'Label',
},
});
expect(wrapper.get('.label').text()).to.equal('Label');
});
it('Renders a placeholder', () => {
const wrapper = shallowMount(CInputText, {
props: {
placeholder: 'Placeholder',
},
});
expect(wrapper.get('.input').attributes('placeholder')).to.equal('Placeholder');
});
it('Renders a value', () => {
const wrapper = shallowMount(CInputText, {
props: {
value: 'Value',
},
});
expect(wrapper.vm.value).to.equal('Value');
});
it('Renders a provided id', () => {
const wrapper = shallowMount(CInputText, {
props: {
id: 'id',
},
});
expect(wrapper.get('.input').attributes('id')).to.equal('id');
});
it('updates value on input', async () => {
const wrapper = shallowMount(CInputText);
await wrapper.get('input').setValue('Hello');
expect(_.get(wrapper.emitted(), 'update:value.0.0')).to.equal('Hello');
});
it('cannot be edited when disabled', async () => {
const wrapper = shallowMount(CInputText, {
props: {
disabled: true,
},
});
await wrapper.get('input').setValue('Hello');
expect(_.get(wrapper.emitted(), 'update:value')).toBeUndefined();
});
it('renders a feedback message for invalid rules', async () => {
const wrapper = shallowMount(CInputText, {
props: { validationRules: [{ validator: () => false, message: 'Message' }] },
});
const feedback = wrapper.find('.feedback');
expect(feedback.exists()).to.equal(true);
expect(feedback.text()).to.equal('Message');
});
it('if the value become valid according to rules, the feedback disappear', async () => {
const wrapper = shallowMount(CInputText, {
props: {
validationRules: [{ validator: (value: string) => value === 'Hello', message: 'Value should be Hello' }],
},
});
const feedback = wrapper.find('.feedback');
expect(feedback.exists()).to.equal(true);
expect(feedback.text()).to.equal('Value should be Hello');
await wrapper.setProps({ value: 'Hello' });
expect(wrapper.find('.feedback').exists()).to.equal(false);
});
it('feedback does not render for valid rules', async () => {
const wrapper = shallowMount(CInputText, {
props: { rules: [{ validator: () => true, message: 'Message' }] },
});
expect(wrapper.find('.feedback').exists()).to.equal(false);
});
it('renders a feedback message for invalid custom validation wrapper', async () => {
const wrapper = shallowMount(CInputText, {
props: {
validation: useValidation({ source: ref(), rules: [{ validator: () => false, message: 'Message' }] }),
},
});
const feedback = wrapper.find('.feedback');
expect(feedback.exists()).to.equal(true);
expect(feedback.text()).to.equal('Message');
});
it('feedback does not render for valid custom validation wrapper', async () => {
const wrapper = shallowMount(CInputText, {
props: {
validation: useValidation({ source: ref(), rules: [{ validator: () => true, message: 'Message' }] }),
},
});
expect(wrapper.find('.feedback').exists()).to.equal(false);
});
it('if the value become valid according to the custom validation wrapper, the feedback disappear', async () => {
const source = ref('');
const wrapper = shallowMount(CInputText, {
props: {
validation: useValidation({
source,
rules: [{ validator: (value: string) => value === 'Hello', message: 'Value should be Hello' }],
}),
},
});
const feedback = wrapper.find('.feedback');
expect(feedback.exists()).to.equal(true);
expect(feedback.text()).to.equal('Value should be Hello');
source.value = 'Hello';
await wrapper.vm.$nextTick();
expect(wrapper.find('.feedback').exists()).to.equal(false);
});
it('[prop:testId] renders a test id on the input', async () => {
const wrapper = mount(CInputText, {
props: {
testId: 'TEST',
},
});
expect(wrapper.get('input').attributes('data-test-id')).to.equal('TEST');
});
});
e='dylan/set-exit-code'>dylan/set-exit-code
dylan/source-map-names-property
eventstream
feat/ecosystem
feat/npm
fix
fix-prepare-stack-trace
fix-websocket-upgrade
fs-watch-file
got
guides-3
improve-docker
insensitive-pkg-names
integration-tests
jarred/5859
jarred/actions
jarred/add-git
jarred/analytics
jarred/arenas
jarred/ast
jarred/ast-again
jarred/async_bio
jarred/bench
jarred/brotli
jarred/bump-uws
jarred/bundle-workspace-packages
jarred/bunfig
jarred/callable
jarred/canvas
jarred/ci-check
jarred/cjs2
jarred/cleanup-error
jarred/clipboard-objc
jarred/direct
jarred/dump
jarred/edgecase
jarred/esbuild-plugin-api
jarred/escapeHTML
jarred/esm-conditions
jarred/experiment-bsp
jarred/export-star-flat
jarred/exports-map
jarred/faster-error-capturestacktrace
jarred/faster-ordered-properties
jarred/fastmalloc
jarred/fetch-experiment
jarred/fetchheaders
jarred/fix-blob-slice-test
jarred/fix-bunbun-on-wsl
jarred/fix-crash
jarred/fix-http-compression
jarred/fix-issue-with-tsconfig-run
jarred/fix-proxy-regression
jarred/fixes-3129
jarred/gen
jarred/htmlrewriter
jarred/improve-testing
jarred/inquirer
jarred/isolation
jarred/jsc
jarred/land
jarred/landing
jarred/linux
jarred/live-bindings
jarred/make-strings-better
jarred/mdx-thrwawy
jarred/move
jarred/napi
jarred/new-bund
jarred/new-bund-ressurected-branch
jarred/new-http
jarred/no-more-npm
jarred/package-mapper
jarred/pg
jarred/port
jarred/possibly-2732
jarred/postgresql
jarred/precompile-linux-dependencies
jarred/prepare-for-libuv
jarred/profiled-call
jarred/read-tsconfig-jsx
jarred/redo-evaluation-order
jarred/redo-zigstring-for-utf16
jarred/relay
jarred/rename
jarred/repl
jarred/request-finalizer
jarred/rewrite-router
jarred/run
jarred/simdjson
jarred/simplify
jarred/some-fixes-for-eventsource
jarred/standalone-repro1
jarred/start
jarred/strong
jarred/subprocess
jarred/support-tee
jarred/tcc
jarred/throw-if
jarred/update-install-stuff
jarred/update-zig1
jarred/upgrade-zig-2
jarred/uws
jarred/webkit-upgrade-may-17
jarred/wip-more-reliable
jarred/workers
jarred/zlib
jarred/zls
lithdew/picohttp-mimalloc
main
move-templates
nestjs-guide
next-cleanup
origin/main
plugin/plugindata
plugin/resolvedir
postinstall_3
repl
request-body-stream
reserve-commands
revert-5167-dylan/decode-regex-if-needed
rfc/bun-bundler-api
rfc/bunfig-overhaul
save-in-update
sdl
test/action
types/mock
types/readable-stream-default
types/tty
u/vjpr/zig-0.10
xHyroM/types/expose-Bun-Env
Unnamed repository; edit this file 'description' to name the repository.
Age Commit message (Collapse ) Author Files Lines
* Give dlopen & linkSymbols typings for exported functions
* Fix lookup table
* Fully change over to Pointer + fix examples
* add back header for typings
* Fix tsc errors
* Run formatter on ffi.d.ts
* Revert args/return type change
* Add type tests for ffi
---------
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Fix Bun.sleep/sleepSync to actually use milliseconds
`Bun.sleepSync` was accidentally treating its argument as seconds rather than milliseconds as the docs stated. This is a breaking change in that the function now behaves as documented. Fixed relevant tests.
* sleepSync: add more argument checking, tests
* Add page descriptions
* Update bun install
* Description tweaks
* Tweaks
* removed redundant tests, fixed server segfault
* fix onRejectStream, safer unassign signal
* fix abort Bun.serve signal.addEventListener on async
* move ctx.signal null check up
* keep original behavior of streams onAborted
* fix(node:http/https): fix passing `URL` objs to `http.request`(#2253)
* fix(node:http): hoist debug env var
* fix(node:http): make body `undefined` when falsy
This reverts commit 7b9a17f9d7106ffd8e553a5192aba60d14ea5e9c.
This reverts commit ec20fae57f96a835562b154730957ecc4015ba31.
* avoids segfault after aborted on reject
* silence err on handleRejectStream after aborted
cc @FireTheFox
abort event behavior (#2252)
* fix deinit behavior when connection is aborted using ResponseStream
* fix abort handling on stream, and get better tests
* avoid segfault by trying to deinit 2x when aborted
* make tests more reliable
* more reliable onResolveStream after aborted
* add test case for not firing the abort signal
* fix Bun.file.arrayBuffer() segmentation fault on empty file #2248
* cleanner this.iotask check
The c-ares build expects lib/libcares.a to exist after cmake, but on my system it was being generated in lib64. This simply sets the cmake variable so that the target ends up where we expect.
Example usage:
BUN_JSC_logGC=1 bun file.js
* remove vendored clap
* Update to latest zig-clap
Major changes:
* Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule
* `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`)
* A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream
Minor change:
* `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome.
* add --development and --optional to bun install
* Add support for `-D`, `--dev` in bun install, fix `--save`