Home / File/ test.ts — svelte Source File

test.ts — svelte Source File

Architecture documentation for test.ts, a typescript file in the svelte codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  1d0b62ee_f20d_508f_987f_2618ed1176d0["test.ts"]
  e97e8c41_1b06_4e9a_29f3_64dbb37dee3c["helpers.js"]
  1d0b62ee_f20d_508f_987f_2618ed1176d0 --> e97e8c41_1b06_4e9a_29f3_64dbb37dee3c
  e34c4197_0d2d_5f9c_9313_0d10c3cf054c["animation-helpers.js"]
  1d0b62ee_f20d_508f_987f_2618ed1176d0 --> e34c4197_0d2d_5f9c_9313_0d10c3cf054c
  b63ddb92_634c_990b_eb1b_0bad8a4d434e["vitest"]
  1d0b62ee_f20d_508f_987f_2618ed1176d0 --> b63ddb92_634c_990b_eb1b_0bad8a4d434e
  3a5197c5_26d7_61da_55b4_8d8d0647614e["store"]
  1d0b62ee_f20d_508f_987f_2618ed1176d0 --> 3a5197c5_26d7_61da_55b4_8d8d0647614e
  1965e7db_5bb9_486d_54d7_e68764dec3f2["motion"]
  1d0b62ee_f20d_508f_987f_2618ed1176d0 --> 1965e7db_5bb9_486d_54d7_e68764dec3f2
  style 1d0b62ee_f20d_508f_987f_2618ed1176d0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @vitest-environment jsdom
import '../helpers.js'; // for the matchMedia polyfill
import { describe, it, assert } from 'vitest';
import { get } from 'svelte/store';
import { spring, tweened, Tween } from 'svelte/motion';
import { raf } from '../animation-helpers.js';

describe('motion', () => {
	describe('spring', () => {
		it('handles initially undefined values', () => {
			const size = spring();

			size.set(100);
			assert.equal(get(size), 100);
		});
	});

	describe('tweened', () => {
		it('handles initially undefined values', () => {
			const size = tweened();

			size.set(100);
			assert.equal(get(size), 100);
		});

		it('sets immediately when duration is 0', () => {
			const size = tweened(0);

			size.set(100, { duration: 0 });
			assert.equal(get(size), 100);
		});

		it('updates correctly when initialized with a `null`-ish value', () => {
			const size = tweened(undefined as unknown as number, { duration: 0 });

			size.set(10);
			assert.equal(get(size), 10);

			size.update((v) => v + 10);
			assert.equal(get(size), 20);
		});

		it('updates non-numeric values immediately', () => {
			raf.reset();
			const boolean = tweened(false);

			boolean.set(true, { duration: 100 });

			raf.tick(1);
			assert.equal(get(boolean), true);
		});
	});

	describe('Tween', () => {
		it('sets immediately when duration is 0', () => {
			const size = new Tween(0);

			size.set(100, { duration: 0 });
			assert.equal(size.current, 100);
		});

		it('updates non-numeric values immediately', () => {
			raf.reset();
			const boolean = new Tween(false);

			boolean.set(true, { duration: 100 });

			raf.tick(1);
			assert.equal(boolean.current, true);
		});
	});

	it('updates correctly when initialized with a `null`-ish value', () => {
		const size = new Tween(undefined as unknown as number, { duration: 0 });

		size.set(10);
		assert.equal(size.current, 10);
	});
});

Domain

Dependencies

Frequently Asked Questions

What does test.ts do?
test.ts is a source file in the svelte codebase, written in typescript. It belongs to the BuildSystem domain.
What does test.ts depend on?
test.ts imports 5 module(s): animation-helpers.js, helpers.js, motion, store, vitest.
Where is test.ts in the architecture?
test.ts is located at packages/svelte/tests/motion/test.ts (domain: BuildSystem, directory: packages/svelte/tests/motion).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free