Home / Function/ default.test() — svelte Function Reference

default.test() — svelte Function Reference

Architecture documentation for the default.test() function in _config.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  8071cad7_9321_bd77_7cdf_ef0078c81468["default.test()"]
  ea8bb942_f97c_5c4f_5843_134ff04da6f1["_config.js"]
  8071cad7_9321_bd77_7cdf_ef0078c81468 -->|defined in| ea8bb942_f97c_5c4f_5843_134ff04da6f1
  style 8071cad7_9321_bd77_7cdf_ef0078c81468 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/runtime-legacy/samples/binding-indirect/_config.js lines 39–133

	async test({ assert, component, target, window, variant }) {
		assert.htmlEqual(
			target.innerHTML,
			`
			<select>
				<option ${variant === 'hydrate' ? 'selected ' : ''}value='[object Object]'>put your left leg in</option>
				<option value='[object Object]'>your left leg out</option>
				<option value='[object Object]'>in, out, in, out</option>
				<option value='[object Object]'>shake it all about</option>
			</select>

			<label>
				<input type='checkbox'> put your left leg in
			</label>

			<h2>Pending tasks</h2>
			<p>put your left leg in</p>
			<p>your left leg out</p>
			<p>in, out, in, out</p>
			<p>shake it all about</p>
		`
		);
		const input = target.querySelector('input');
		const select = target.querySelector('select');
		const options = target.querySelectorAll('option');
		ok(input);
		ok(select);

		const change = new window.Event('change');

		input.checked = true;

		flushSync(() => {
			input.dispatchEvent(change);
		});

		assert.ok(component.tasks[0].done);

		assert.htmlEqual(
			target.innerHTML,
			`
			<select>
				<option ${variant === 'hydrate' ? 'selected ' : ''}value='[object Object]'>put your left leg in</option>
				<option value='[object Object]'>your left leg out</option>
				<option value='[object Object]'>in, out, in, out</option>
				<option value='[object Object]'>shake it all about</option>
			</select>

			<label>
				<input type='checkbox'> put your left leg in
			</label>

			<h2>Pending tasks</h2>
			<p>your left leg out</p>
			<p>in, out, in, out</p>
			<p>shake it all about</p>
		`
		);

		options[1].selected = true;

		flushSync(() => {
			select.dispatchEvent(change);
		});

		assert.deepEqual(component.selected, tasks[1]); // TODO this should be assert.equal, but that crashes the entire test suite in mysterious ways... something to do with proxies not being reused?
		assert.ok(!input.checked);

		input.checked = true;

		flushSync(() => {
			input.dispatchEvent(change);
		});

		assert.ok(component.tasks[1].done);
		assert.htmlEqual(
			target.innerHTML,
			`
			<select>
				<option ${variant === 'hydrate' ? 'selected ' : ''}value='[object Object]'>put your left leg in</option>
				<option value='[object Object]'>your left leg out</option>

Domain

Subdomains

Frequently Asked Questions

What does default.test() do?
default.test() is a function in the svelte codebase, defined in packages/svelte/tests/runtime-legacy/samples/binding-indirect/_config.js.
Where is default.test() defined?
default.test() is defined in packages/svelte/tests/runtime-legacy/samples/binding-indirect/_config.js at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free