mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
refactor(packages/vue): clean test names for UseLastChanged, add new imports
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
export * from './tryOnBeforeMount';
|
||||
export * from './tryOnMounted';
|
||||
export * from './tryOnScopeDispose';
|
||||
export * from './useAppSharedState';
|
||||
export * from './useCached';
|
||||
export * from './useClamp';
|
||||
export * from './useContextFactory';
|
||||
export * from './useCounter';
|
||||
export * from './useLastChanged';
|
||||
export * from './useMounted';
|
||||
export * from './useOffsetPagination';
|
||||
export * from './useRenderCount';
|
||||
export * from './useRenderInfo';
|
||||
export * from './useSupported';
|
||||
export * from './useSyncRefs';
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { useLastChanged } from '.';
|
||||
import { timestamp } from '@robonen/stdlib';
|
||||
|
||||
describe('useLastChanged', () => {
|
||||
it('should initialize with null if no initialValue is provided', () => {
|
||||
it('initialize with null if no initialValue is provided', () => {
|
||||
const source = ref(0);
|
||||
const lastChanged = useLastChanged(source);
|
||||
|
||||
expect(lastChanged.value).toBeNull();
|
||||
});
|
||||
|
||||
it('should initialize with the provided initialValue', () => {
|
||||
it('initialize with the provided initialValue', () => {
|
||||
const source = ref(0);
|
||||
const initialValue = 123456789;
|
||||
const lastChanged = useLastChanged(source, { initialValue });
|
||||
@@ -19,7 +19,7 @@ describe('useLastChanged', () => {
|
||||
expect(lastChanged.value).toBe(initialValue);
|
||||
});
|
||||
|
||||
it('should update the timestamp when the source changes', async () => {
|
||||
it('update the timestamp when the source changes', async () => {
|
||||
const source = ref(0);
|
||||
const lastChanged = useLastChanged(source);
|
||||
|
||||
@@ -31,14 +31,14 @@ describe('useLastChanged', () => {
|
||||
expect(lastChanged.value).toBeLessThanOrEqual(timestamp());
|
||||
});
|
||||
|
||||
it('should update the timestamp immediately if immediate option is true', async () => {
|
||||
it('update the timestamp immediately if immediate option is true', async () => {
|
||||
const source = ref(0);
|
||||
const lastChanged = useLastChanged(source, { immediate: true });
|
||||
|
||||
expect(lastChanged.value).toBeLessThanOrEqual(timestamp());
|
||||
});
|
||||
|
||||
it('should not update the timestamp if the source does not change', async () => {
|
||||
it('not update the timestamp if the source does not change', async () => {
|
||||
const source = ref(0);
|
||||
const lastChanged = useLastChanged(source);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { isRef, ref, toValue, type MaybeRefOrGetter, type MaybeRef, type Ref } from 'vue';
|
||||
|
||||
// TODO: wip
|
||||
|
||||
export interface UseToggleOptions<Enabled, Disabled> {
|
||||
enabledValue?: MaybeRefOrGetter<Enabled>,
|
||||
disabledValue?: MaybeRefOrGetter<Disabled>,
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './composables';
|
||||
export * from './utils';
|
||||
export * from './utils';
|
||||
export * from './types';
|
||||
2
packages/vue/src/types/index.ts
Normal file
2
packages/vue/src/types/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './resumable';
|
||||
export * from './window';
|
||||
Reference in New Issue
Block a user