Home / File/ _config.js — svelte Source File

_config.js — svelte Source File

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

File javascript BuildSystem QualityControl 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  f12ba047_94da_b808_a152_6597a63a08ae["_config.js"]
  d952c6b0_fdc4_6752_d5aa_0b4adfa256ee["test.ts"]
  f12ba047_94da_b808_a152_6597a63a08ae --> d952c6b0_fdc4_6752_d5aa_0b4adfa256ee
  4ead6623_c53e_ab40_5690_64903d5addf1["svelte"]
  f12ba047_94da_b808_a152_6597a63a08ae --> 4ead6623_c53e_ab40_5690_64903d5addf1
  style f12ba047_94da_b808_a152_6597a63a08ae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

/**
 * Polyfill for Promise.withResolver()
 * @returns { {promise: Promise<string>, resolve: (value: any)=>void, reject: (reason?: any) => void} }
 */
function promiseWithResolver() {
	let resolve, reject;
	const promise = new Promise((res, rej) => {
		resolve = res;
		reject = rej;
	});
	// @ts-ignore
	return { promise, resolve, reject };
}

export default test({
	async test({ component, assert, logs }) {
		{
			// Set a promise on the component
			const { promise, resolve } = promiseWithResolver();
			component.promise = promise;
			// wait for rendering
			await Promise.resolve();
			// resolve promise
			resolve('ok');
			// And wait the end of the promise
			await promise;
			// {#await} and {:then} block must be rendered
			assert.deepEqual(logs, ['await', 'then:ok']);
		}

		// clear logs
		logs.length = 0;

		{
			// Set a promise on the component
			const { promise, reject } = promiseWithResolver();
			component.promise = promise;
			// wait for rendering
			await Promise.resolve();
			// reject promise
			reject('error');
			// And wait the end of the promise
			await promise.catch((ignore) => {});
			// {#await} and {:catch} block must be rendered
			assert.deepEqual(logs, ['await', 'catch:error']);
		}

		// clear logs
		logs.length = 0;

		{
			// Set a promise on the component
			const { promise, resolve } = promiseWithResolver();
			component.promise = promise;
			// wait for rendering
			await Promise.resolve();

			// remove the promise
			component.promise = null;
			await Promise.resolve();

			// resolve promise
			resolve('ok');
			// And wait the end of the promise
			await promise;
			// Only {#await} block must be rendered
			assert.deepEqual(logs, ['await']);
		}

		// clear logs
		logs.length = 0;

		{
			// Set a promise on the component
			const { promise, reject } = promiseWithResolver();
			component.promise = promise;
			// wait for rendering
			await tick();

			// remove the promise
			component.promise = null;
			await Promise.resolve();

			// reject promise
			reject('error');
			// And wait the end of the promise
			await promise.catch((ignore) => {});
			// Only {#await} block must be rendered
			assert.deepEqual(logs, ['await']);
		}
	}
});

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, promiseWithResolver.
What does _config.js depend on?
_config.js imports 2 module(s): svelte, test.ts.
Where is _config.js in the architecture?
_config.js is located at packages/svelte/tests/runtime-runes/samples/await-pending-destroy/_config.js (domain: BuildSystem, subdomain: QualityControl, directory: packages/svelte/tests/runtime-runes/samples/await-pending-destroy).

Analyze Your Own Codebase

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

Try Supermodel Free