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
  62b4bf6a_2e40_3d9a_a8a2_264903195239["default.test()"]
  1cdb4286_4a7d_eade_9c2d_ee1ce78c04e9["_config.js"]
  62b4bf6a_2e40_3d9a_a8a2_264903195239 -->|defined in| 1cdb4286_4a7d_eade_9c2d_ee1ce78c04e9
  style 62b4bf6a_2e40_3d9a_a8a2_264903195239 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/runtime-legacy/samples/binding-this-with-context/_config.js lines 9–76

	test({ assert, component, target }) {
		let divs = target.querySelectorAll('div');
		assert.equal(component.divs.length, 3, 'three divs are registered (unkeyed array)');
		// @ts-ignore
		component.divs.forEach((e, i) => {
			assert.equal(e, divs[i], `div ${i} is correct (unkeyed array)`);
		});

		let spans = target.querySelectorAll('span');
		assert.equal(
			Object.keys(component.spans).length,
			3,
			'three spans are registered (unkeyed object)'
		);
		// @ts-ignore
		component.items.forEach((e, i) => {
			assert.equal(
				component.spans[`-${e}${i}`],
				spans[i],
				`span -${e}${i} is correct (unkeyed object)`
			);
		});

		let ps = target.querySelectorAll('p');
		assert.equal(component.ps.length, 3, 'three ps are registered (keyed array)');
		// @ts-ignore
		component.ps.forEach((e, i) => {
			assert.equal(e, ps[i], `p ${i} is correct (keyed array)`);
		});

		let hrs = target.querySelectorAll('hr');
		assert.equal(Object.keys(component.hrs).length, 3, 'three hrs are registered (keyed object)');
		// @ts-ignore
		component.items.forEach((e, i) => {
			assert.equal(component.hrs[e], hrs[i], `hr ${e} is correct (keyed object)`);
		});

		component.items = ['foo', 'baz'];
		assert.equal(component.divs.length, 3, 'the divs array is still 3 long');
		assert.equal(component.divs[2], null, 'the last div is unregistered');
		assert.equal(component.ps[2], null, 'the last p is unregistered');
		assert.equal(component.spans['-bar1'], null, 'the bar span is unregistered');
		assert.equal(component.hrs.bar, null, 'the bar hr is unregistered');

		divs = target.querySelectorAll('div');
		// @ts-ignore
		component.divs.forEach((e, i) => {
			assert.equal(e, divs[i], `div ${i} is still correct`);
		});

		spans = target.querySelectorAll('span');
		// @ts-ignore
		component.items.forEach((e, i) => {
			assert.equal(component.spans[`-${e}${i}`], spans[i], `span -${e}${i} is still correct`);
		});

		ps = target.querySelectorAll('p');
		// @ts-ignore
		component.ps.forEach((e, i) => {
			assert.equal(e, ps[i], `p ${i} is still correct`);
		});

		hrs = target.querySelectorAll('hr');
		// @ts-ignore
		component.items.forEach((e, i) => {
			assert.equal(component.hrs[e], hrs[i], `hr ${e} is still correct`);
		});
	}

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-this-with-context/_config.js.
Where is default.test() defined?
default.test() is defined in packages/svelte/tests/runtime-legacy/samples/binding-this-with-context/_config.js at line 9.

Analyze Your Own Codebase

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

Try Supermodel Free