31 lines
758 B
TypeScript
31 lines
758 B
TypeScript
import { usePulseActivatedTool } from 'src/composables/pulseActivatedTool';
|
|
import { expect, test } from 'vitest';
|
|
import { nextTick, ref } from 'vue';
|
|
|
|
test('starts in the off state', () => {
|
|
const pulse = ref(false);
|
|
|
|
const { isActive } = usePulseActivatedTool(pulse, 10);
|
|
expect(isActive.value).toBe(false);
|
|
});
|
|
|
|
test('is resoping to the input pulse', async () => {
|
|
const pulse = ref(false);
|
|
|
|
const { isActive } = usePulseActivatedTool(pulse, 10);
|
|
expect(isActive.value).toBe(false);
|
|
|
|
pulse.value = true;
|
|
await nextTick();
|
|
|
|
expect(isActive.value).toBe(true);
|
|
|
|
pulse.value = false;
|
|
await nextTick();
|
|
|
|
expect(isActive.value).toBe(true);
|
|
|
|
await await new Promise((p) => setTimeout(p, 15));
|
|
expect(isActive.value).toBe(false);
|
|
});
|