1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 10:54:44 +00:00

feat(configs/oxlint): add linter

This commit is contained in:
2026-02-14 22:49:47 +07:00
parent 2a5412c3b8
commit 49b9f2aa79
98 changed files with 1236 additions and 201 deletions

View File

@@ -2,56 +2,56 @@ import { it, expect, describe } from 'vitest';
import { ref } from 'vue';
import { useToggle } from '.';
describe('useToggle', () => {
describe(useToggle, () => {
it('initialize with false by default', () => {
const { value } = useToggle();
expect(value.value).toBe(false);
expect(value.value).toBeFalsy();
});
it('initialize with the provided initial value', () => {
const { value } = useToggle(true);
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
});
it('initialize with the provided initial value from a ref', () => {
const { value } = useToggle(ref(true));
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
});
it('toggle from false to true', () => {
const { value, toggle } = useToggle(false);
toggle();
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
});
it('toggle from true to false', () => {
const { value, toggle } = useToggle(true);
toggle();
expect(value.value).toBe(false);
expect(value.value).toBeFalsy();
});
it('toggle multiple times', () => {
const { value, toggle } = useToggle(false);
toggle();
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
toggle();
expect(value.value).toBe(false);
expect(value.value).toBeFalsy();
toggle();
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
});
it('toggle returns the new value', () => {
const { toggle } = useToggle(false);
expect(toggle()).toBe(true);
expect(toggle()).toBe(false);
expect(toggle()).toBeTruthy();
expect(toggle()).toBeFalsy();
});
it('set a specific value via toggle', () => {
const { value, toggle } = useToggle(false);
toggle(true);
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
toggle(true);
expect(value.value).toBe(true);
expect(value.value).toBeTruthy();
});
it('use custom truthy and falsy values', () => {

View File

@@ -1,4 +1,5 @@
import { ref, toValue, type MaybeRefOrGetter, type MaybeRef, type Ref } from 'vue';
import { ref, toValue } from 'vue';
import type { MaybeRefOrGetter, MaybeRef, Ref } from 'vue';
export interface UseToggleOptions<Truthy, Falsy> {
truthyValue?: MaybeRefOrGetter<Truthy>,