Home / File/ _config.js — svelte Source File

_config.js — svelte Source File

Architecture documentation for _config.js, a javascript file in the svelte codebase. 1 imports, 0 dependents.

File javascript BuildSystem QualityControl 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  984062df_a5b4_a8e6_3d29_ca89e0c56549["_config.js"]
  654af6d6_2570_6860_f8dd_6b6131e1eec4["test.ts"]
  984062df_a5b4_a8e6_3d29_ca89e0c56549 --> 654af6d6_2570_6860_f8dd_6b6131e1eec4
  style 984062df_a5b4_a8e6_3d29_ca89e0c56549 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { test } from '../../test';

export default test({
	async test({ assert, component, target, window }) {
		const [input1, input2] = target.querySelectorAll('input');

		// we are not able emulate user interaction in jsdom,
		// therefore, jsdom could not validate minlength / maxlength

		// we simulate user input with
		// setting input.value + dispatchEvent

		// and we determine if svelte does not set the `input.value` again by
		// spying on the setter of `input.value`

		const spy1 = spyOnValueSetter(input1, input1.value);
		const spy2 = spyOnValueSetter(input2, input2.value);

		const event = new window.Event('input');

		input1.value = '12345';
		spy1.reset();
		await input1.dispatchEvent(event);

		// In Svelte 5, the value will always fire as the effects for setting
		// the value and spreading happen in different parts.

		// assert.ok(!spy1.isSetCalled());

		input2.value = '12345';
		spy2.reset();
		await input2.dispatchEvent(event);

		// Same as above.
		// assert.ok(!spy2.isSetCalled());

		spy1.reset();
		component.val1 = '56789';
		assert.ok(spy1.isSetCalled());

		spy2.reset();
		component.val2 = '56789';
		// Same as above.
		// assert.ok(spy2.isSetCalled());
	}
});

/**
 * @param {HTMLInputElement} input
 * @param {string} initialValue
 */
function spyOnValueSetter(input, initialValue) {
	let value = initialValue;
	let isSet = false;
	Object.defineProperty(input, 'value', {
		get() {
			return value;
		},
		set(_value) {
			value = _value;
			isSet = true;
		}
	});

	return {
		isSetCalled() {
			return isSet;
		},
		reset() {
			isSet = false;
		}
	};
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does _config.js do?
_config.js is a source file in the svelte codebase, written in javascript. It belongs to the BuildSystem domain, QualityControl subdomain.
What functions are defined in _config.js?
_config.js defines 2 function(s): default.test, spyOnValueSetter.
What does _config.js depend on?
_config.js imports 1 module(s): test.ts.
Where is _config.js in the architecture?
_config.js is located at packages/svelte/tests/runtime-legacy/samples/spread-element-input-value/_config.js (domain: BuildSystem, subdomain: QualityControl, directory: packages/svelte/tests/runtime-legacy/samples/spread-element-input-value).

Analyze Your Own Codebase

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

Try Supermodel Free