chore: eslint rule for naming convention (#9208)

pull/9211/head
Yeom suyun 1 year ago committed by GitHub
parent 8667f0fd7e
commit b62fc8c8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,7 +83,7 @@
"posttest": "agadoo src/internal/index.js", "posttest": "agadoo src/internal/index.js",
"prepublishOnly": "pnpm build", "prepublishOnly": "pnpm build",
"types": "node ./scripts/generate-dts.js", "types": "node ./scripts/generate-dts.js",
"lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{src,test}/**/*.{ts,js}\" --cache" "lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{scripts,src,test}/**/*.js\" --cache --fix"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -129,6 +129,7 @@
"agadoo": "^3.0.0", "agadoo": "^3.0.0",
"dts-buddy": "^0.1.7", "dts-buddy": "^0.1.7",
"esbuild": "^0.18.11", "esbuild": "^0.18.11",
"eslint-plugin-lube": "^0.1.7",
"happy-dom": "^9.20.3", "happy-dom": "^9.20.3",
"jsdom": "^21.1.2", "jsdom": "^21.1.2",
"kleur": "^4.1.5", "kleur": "^4.1.5",

@ -0,0 +1,6 @@
{
"plugins": ["lube"],
"rules": {
"lube/svelte-naming-convention": ["error", { "fixSameNames": true }]
}
}

@ -1,8 +1,8 @@
// Compile all Svelte files in a directory to JS and CSS files // Compile all Svelte files in a directory to JS and CSS files
// Usage: node scripts/compile-test.js <directory> // Usage: node scripts/compile-test.js <directory>
import { mkdirSync, readFileSync, writeFileSync } from 'fs'; import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import path from 'path'; import path from 'node:path';
import glob from 'tiny-glob/sync.js'; import glob from 'tiny-glob/sync.js';
import { compile } from '../src/compiler/index.js'; import { compile } from '../src/compiler/index.js';

@ -1,18 +1,18 @@
import * as fs from 'fs'; import * as fs from 'node:fs';
import { createBundle } from 'dts-buddy'; import { createBundle } from 'dts-buddy';
// It may look weird, but the imports MUST be ending with index.js to be properly resolved in all TS modes // It may look weird, but the imports MUST be ending with index.js to be properly resolved in all TS modes
for (const name of ['action', 'animate', 'easing', 'motion', 'store', 'transition']) { for (const name of ['action', 'animate', 'easing', 'motion', 'store', 'transition']) {
fs.writeFileSync(`${name}.d.ts`, `import './types/index.js';`); fs.writeFileSync(`${name}.d.ts`, "import './types/index.js';");
} }
fs.writeFileSync('index.d.ts', `import './types/index.js';`); fs.writeFileSync('index.d.ts', "import './types/index.js';");
fs.writeFileSync('compiler.d.ts', `import './types/index.js';`); fs.writeFileSync('compiler.d.ts', "import './types/index.js';");
// TODO: some way to mark these as deprecated // TODO: some way to mark these as deprecated
fs.mkdirSync('./types/compiler', { recursive: true }); fs.mkdirSync('./types/compiler', { recursive: true });
fs.writeFileSync('./types/compiler/preprocess.d.ts', `import '../index.js';`); fs.writeFileSync('./types/compiler/preprocess.d.ts', "import '../index.js';");
fs.writeFileSync('./types/compiler/interfaces.d.ts', `import '../index.js';`); fs.writeFileSync('./types/compiler/interfaces.d.ts', "import '../index.js';");
await createBundle({ await createBundle({
output: 'types/index.d.ts', output: 'types/index.d.ts',

@ -6,8 +6,8 @@ Please run `node scripts/globals-extractor.js` at the project root.
see: https://github.com/microsoft/TypeScript/tree/main/lib see: https://github.com/microsoft/TypeScript/tree/main/lib
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
import http from 'https'; import http from 'node:https';
import fs from 'fs'; import fs from 'node:fs';
const GLOBAL_TS_PATH = './src/compiler/utils/globals.js'; const GLOBAL_TS_PATH = './src/compiler/utils/globals.js';

@ -0,0 +1,6 @@
{
"plugins": ["lube"],
"rules": {
"lube/svelte-naming-convention": ["error", { "fixSameNames": true }]
}
}

@ -1555,8 +1555,8 @@ export default class Component {
}, []) }, [])
); );
if (cycle && cycle.length) { if (cycle && cycle.length) {
const declarationList = lookup.get(cycle[0]); const declaration_list = lookup.get(cycle[0]);
const declaration = declarationList[0]; const declaration = declaration_list[0];
return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle)); return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle));
} }

@ -4,7 +4,7 @@ import { b } from 'code-red';
* @param {any} program * @param {any} program
* @param {import('estree').Identifier} name * @param {import('estree').Identifier} name
* @param {string} banner * @param {string} banner
* @param {any} sveltePath * @param {any} svelte_path
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers * @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals * @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
* @param {import('estree').ImportDeclaration[]} imports * @param {import('estree').ImportDeclaration[]} imports
@ -15,21 +15,21 @@ export default function create_module(
program, program,
name, name,
banner, banner,
sveltePath = 'svelte', svelte_path = 'svelte',
helpers, helpers,
globals, globals,
imports, imports,
module_exports, module_exports,
exports_from exports_from
) { ) {
const internal_path = `${sveltePath}/internal`; const internal_path = `${svelte_path}/internal`;
helpers.sort((a, b) => (a.name < b.name ? -1 : 1)); helpers.sort((a, b) => (a.name < b.name ? -1 : 1));
globals.sort((a, b) => (a.name < b.name ? -1 : 1)); globals.sort((a, b) => (a.name < b.name ? -1 : 1));
return esm( return esm(
program, program,
name, name,
banner, banner,
sveltePath, svelte_path,
internal_path, internal_path,
helpers, helpers,
globals, globals,
@ -41,11 +41,11 @@ export default function create_module(
/** /**
* @param {any} source * @param {any} source
* @param {any} sveltePath * @param {any} svelte_path
*/ */
function edit_source(source, sveltePath) { function edit_source(source, svelte_path) {
return source === 'svelte' || source.startsWith('svelte/') return source === 'svelte' || source.startsWith('svelte/')
? source.replace('svelte', sveltePath) ? source.replace('svelte', svelte_path)
: source; : source;
} }
@ -84,7 +84,7 @@ function get_internal_globals(globals, helpers) {
* @param {any} program * @param {any} program
* @param {import('estree').Identifier} name * @param {import('estree').Identifier} name
* @param {string} banner * @param {string} banner
* @param {string} sveltePath * @param {string} svelte_path
* @param {string} internal_path * @param {string} internal_path
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers * @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals * @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
@ -96,7 +96,7 @@ function esm(
program, program,
name, name,
banner, banner,
sveltePath, svelte_path,
internal_path, internal_path,
helpers, helpers,
globals, globals,
@ -118,7 +118,7 @@ function esm(
/** @param {any} node */ /** @param {any} node */
function rewrite_import(node) { function rewrite_import(node) {
const value = edit_source(node.source.value, sveltePath); const value = edit_source(node.source.value, svelte_path);
if (node.source.value !== value) { if (node.source.value !== value) {
node.source.value = value; node.source.value = value;
node.source.raw = null; node.source.raw = null;

@ -98,7 +98,7 @@ export default class Binding extends Node {
this.is_readonly = this.is_readonly =
regex_dimensions.test(this.name) || regex_dimensions.test(this.name) ||
regex_box_size.test(this.name) || regex_box_size.test(this.name) ||
(isElement(parent) && (is_element(parent) &&
((parent.is_media_node() && read_only_media_attributes.has(this.name)) || ((parent.is_media_node() && read_only_media_attributes.has(this.name)) ||
(parent.name === 'input' && type === 'file'))) /* TODO others? */; (parent.name === 'input' && type === 'file'))) /* TODO others? */;
} }
@ -127,6 +127,6 @@ export default class Binding extends Node {
* @param {import('./shared/Node.js').default} node * @param {import('./shared/Node.js').default} node
* @returns {node is import('./Element.js').default} * @returns {node is import('./Element.js').default}
*/ */
function isElement(node) { function is_element(node) {
return !!(/** @type {any} */ (node).is_media_node); return !!(/** @type {any} */ (node).is_media_node);
} }

@ -84,7 +84,9 @@ export default class EachBlock extends AbstractBlock {
this.has_animation = false; this.has_animation = false;
[this.const_tags, this.children] = get_const_tags(info.children, component, this, this); [this.const_tags, this.children] = get_const_tags(info.children, component, this, this);
if (this.has_animation) { if (this.has_animation) {
this.children = this.children.filter((child) => !isEmptyNode(child) && !isCommentNode(child)); this.children = this.children.filter(
(child) => !is_empty_node(child) && !is_comment_node(child)
);
if (this.children.length !== 1) { if (this.children.length !== 1) {
const child = this.children.find( const child = this.children.find(
(child) => !!(/** @type {import('./Element.js').default} */ (child).animation) (child) => !!(/** @type {import('./Element.js').default} */ (child).animation)
@ -102,11 +104,11 @@ export default class EachBlock extends AbstractBlock {
} }
/** @param {import('./interfaces.js').INode} node */ /** @param {import('./interfaces.js').INode} node */
function isEmptyNode(node) { function is_empty_node(node) {
return node.type === 'Text' && node.data.trim() === ''; return node.type === 'Text' && node.data.trim() === '';
} }
/** @param {import('./interfaces.js').INode} node */ /** @param {import('./interfaces.js').INode} node */
function isCommentNode(node) { function is_comment_node(node) {
return node.type === 'Comment'; return node.type === 'Comment';
} }

@ -875,7 +875,7 @@ export default class Element extends Node {
) { ) {
const interactive_handlers = handlers const interactive_handlers = handlers
.map((handler) => handler.name) .map((handler) => handler.name)
.filter((handlerName) => a11y_interactive_handlers.has(handlerName)); .filter((handler_name) => a11y_interactive_handlers.has(handler_name));
if (interactive_handlers.length > 0) { if (interactive_handlers.length > 0) {
component.warn( component.warn(
this, this,

@ -73,8 +73,8 @@ function sort_consts_nodes(consts_nodes, component) {
}, []) }, [])
); );
if (cycle && cycle.length) { if (cycle && cycle.length) {
const nodeList = lookup.get(cycle[0]); const node_list = lookup.get(cycle[0]);
const node = nodeList[0]; const node = node_list[0];
component.error(node.node, compiler_errors.cyclical_const_tags(cycle)); component.error(node.node, compiler_errors.cyclical_const_tags(cycle));
} }

@ -94,14 +94,14 @@ export default class WindowWrapper extends Wrapper {
bindings.scrollX && bindings.scrollY bindings.scrollX && bindings.scrollY
? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state` ? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state`
: x`"${bindings.scrollX || bindings.scrollY}" in this._state`; : x`"${bindings.scrollX || bindings.scrollY}" in this._state`;
const scrollX = bindings.scrollX && x`this._state.${bindings.scrollX}`; const scroll_x = bindings.scrollX && x`this._state.${bindings.scrollX}`;
const scrollY = bindings.scrollY && x`this._state.${bindings.scrollY}`; const scroll_y = bindings.scrollY && x`this._state.${bindings.scrollY}`;
renderer.meta_bindings.push(b` renderer.meta_bindings.push(b`
if (${condition}) { if (${condition}) {
@_scrollTo(${scrollX || '@_window.pageXOffset'}, ${scrollY || '@_window.pageYOffset'}); @_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'});
} }
${scrollX && `${scrollX} = @_window.pageXOffset;`} ${scroll_x && `${scroll_x} = @_window.pageXOffset;`}
${scrollY && `${scrollY} = @_window.pageYOffset;`} ${scroll_y && `${scroll_y} = @_window.pageYOffset;`}
`); `);
block.event_listeners.push(x` block.event_listeners.push(x`
@listen(@_window, "${event}", () => { @listen(@_window, "${event}", () => {
@ -132,17 +132,17 @@ export default class WindowWrapper extends Wrapper {
// special case... might need to abstract this out if we add more special cases // special case... might need to abstract this out if we add more special cases
if (bindings.scrollX || bindings.scrollY) { if (bindings.scrollX || bindings.scrollY) {
const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean)); const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean));
const scrollX = bindings.scrollX const scroll_x = bindings.scrollX
? renderer.reference(bindings.scrollX) ? renderer.reference(bindings.scrollX)
: x`@_window.pageXOffset`; : x`@_window.pageXOffset`;
const scrollY = bindings.scrollY const scroll_y = bindings.scrollY
? renderer.reference(bindings.scrollY) ? renderer.reference(bindings.scrollY)
: x`@_window.pageYOffset`; : x`@_window.pageYOffset`;
block.chunks.update.push(b` block.chunks.update.push(b`
if (${condition} && !${scrolling}) { if (${condition} && !${scrolling}) {
${scrolling} = true; ${scrolling} = true;
@_clearTimeout(${scrolling_timeout}); @_clearTimeout(${scrolling_timeout});
@_scrollTo(${scrollX}, ${scrollY}); @_scrollTo(${scroll_x}, ${scroll_y});
${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100); ${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100);
} }
`); `);

@ -8,7 +8,7 @@ import * as node from './node/index.js';
* *
* The new nodes are located in `./node`. * The new nodes are located in `./node`.
*/ */
const cqSyntax = fork({ const cq_syntax = fork({
atrule: { atrule: {
// extend or override at-rule dictionary // extend or override at-rule dictionary
container: { container: {
@ -16,8 +16,8 @@ const cqSyntax = fork({
prelude() { prelude() {
return this.createSingleNodeList(this.ContainerQuery()); return this.createSingleNodeList(this.ContainerQuery());
}, },
block(isStyleBlock = false) { block(is_style_block = false) {
return this.Block(isStyleBlock); return this.Block(is_style_block);
} }
} }
} }
@ -25,4 +25,4 @@ const cqSyntax = fork({
node node
}); });
export const parse = cqSyntax.parse; export const parse = cq_syntax.parse;

@ -16,7 +16,7 @@ export const structure = {
value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null] value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null]
}; };
function lookup_non_WS_type_and_value(offset, type, referenceStr) { function lookup_non_ws_type_and_value(offset, type, reference_str) {
let current_type; let current_type;
do { do {
@ -26,7 +26,7 @@ function lookup_non_WS_type_and_value(offset, type, referenceStr) {
} }
} while (current_type !== 0); // NULL -> 0 } while (current_type !== 0); // NULL -> 0
return current_type === type ? this.lookupValue(offset - 1, referenceStr) : false; return current_type === type ? this.lookupValue(offset - 1, reference_str) : false;
} }
export function parse() { export function parse() {
@ -40,7 +40,7 @@ export function parse() {
while (!this.eof && this.tokenType !== RightParenthesis) { while (!this.eof && this.tokenType !== RightParenthesis) {
switch (this.tokenType) { switch (this.tokenType) {
case Number: case Number:
if (lookup_non_WS_type_and_value.call(this, 1, Delim, '/')) { if (lookup_non_ws_type_and_value.call(this, 1, Delim, '/')) {
child = this.Ratio(); child = this.Ratio();
} else { } else {
child = this.Number(); child = this.Number();

@ -1,5 +1,7 @@
import { ResizeObserverSingleton } from './ResizeObserverSingleton.js';
import { contenteditable_truthy_values, has_prop } from './utils.js'; import { contenteditable_truthy_values, has_prop } from './utils.js';
import { ResizeObserverSingleton } from './ResizeObserverSingleton.js';
// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM // Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM
// at the end of hydration without touching the remaining nodes. // at the end of hydration without touching the remaining nodes.
let is_hydrating = false; let is_hydrating = false;
@ -50,14 +52,14 @@ function init_hydrate(target) {
let children = /** @type {ArrayLike<NodeEx2>} */ (target.childNodes); let children = /** @type {ArrayLike<NodeEx2>} */ (target.childNodes);
// If target is <head>, there may be children without claim_order // If target is <head>, there may be children without claim_order
if (target.nodeName === 'HEAD') { if (target.nodeName === 'HEAD') {
const myChildren = []; const my_children = [];
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
const node = children[i]; const node = children[i];
if (node.claim_order !== undefined) { if (node.claim_order !== undefined) {
myChildren.push(node); my_children.push(node);
} }
} }
children = myChildren; children = my_children;
} }
/* /*
* Reorder claimed children optimally. * Reorder claimed children optimally.
@ -87,15 +89,15 @@ function init_hydrate(target) {
// Find the largest subsequence length such that it ends in a value less than our current value // Find the largest subsequence length such that it ends in a value less than our current value
// upper_bound returns first greater value, so we subtract one // upper_bound returns first greater value, so we subtract one
// with fast path for when we are on the current longest subsequence // with fast path for when we are on the current longest subsequence
const seqLen = const seq_len =
(longest > 0 && children[m[longest]].claim_order <= current (longest > 0 && children[m[longest]].claim_order <= current
? longest + 1 ? longest + 1
: upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1; : upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1;
p[i] = m[seqLen] + 1; p[i] = m[seq_len] + 1;
const newLen = seqLen + 1; const new_len = seq_len + 1;
// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence. // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.
m[newLen] = i; m[new_len] = i;
longest = Math.max(newLen, longest); longest = Math.max(new_len, longest);
} }
// The longest increasing subsequence of nodes (initially reversed) // The longest increasing subsequence of nodes (initially reversed)
@ -108,28 +110,28 @@ function init_hydrate(target) {
/** /**
* @type {NodeEx2[]} * @type {NodeEx2[]}
*/ */
const toMove = []; const to_move = [];
let last = children.length - 1; let last = children.length - 1;
for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) { for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {
lis.push(children[cur - 1]); lis.push(children[cur - 1]);
for (; last >= cur; last--) { for (; last >= cur; last--) {
toMove.push(children[last]); to_move.push(children[last]);
} }
last--; last--;
} }
for (; last >= 0; last--) { for (; last >= 0; last--) {
toMove.push(children[last]); to_move.push(children[last]);
} }
lis.reverse(); lis.reverse();
// We sort the nodes being moved to guarantee that their insertion order matches the claim order // We sort the nodes being moved to guarantee that their insertion order matches the claim order
toMove.sort((a, b) => a.claim_order - b.claim_order); to_move.sort((a, b) => a.claim_order - b.claim_order);
// Finally, we move the nodes // Finally, we move the nodes
for (let i = 0, j = 0; i < toMove.length; i++) { for (let i = 0, j = 0; i < to_move.length; i++) {
while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) { while (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) {
j++; j++;
} }
const anchor = j < lis.length ? lis[j] : null; const anchor = j < lis.length ? lis[j] : null;
target.insertBefore(toMove[i], anchor); target.insertBefore(to_move[i], anchor);
} }
} }
@ -624,26 +626,26 @@ function init_claim_info(nodes) {
* @template {ChildNodeEx} R * @template {ChildNodeEx} R
* @param {ChildNodeArray} nodes * @param {ChildNodeArray} nodes
* @param {(node: ChildNodeEx) => node is R} predicate * @param {(node: ChildNodeEx) => node is R} predicate
* @param {(node: ChildNodeEx) => ChildNodeEx | undefined} processNode * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node
* @param {() => R} createNode * @param {() => R} create_node
* @param {boolean} dontUpdateLastIndex * @param {boolean} dont_update_last_index
* @returns {R} * @returns {R}
*/ */
function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) { function claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {
// Try to find nodes in an order such that we lengthen the longest increasing subsequence // Try to find nodes in an order such that we lengthen the longest increasing subsequence
init_claim_info(nodes); init_claim_info(nodes);
const resultNode = (() => { const result_node = (() => {
// We first try to find an element after the previous one // We first try to find an element after the previous one
for (let i = nodes.claim_info.last_index; i < nodes.length; i++) { for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {
const node = nodes[i]; const node = nodes[i];
if (predicate(node)) { if (predicate(node)) {
const replacement = processNode(node); const replacement = process_node(node);
if (replacement === undefined) { if (replacement === undefined) {
nodes.splice(i, 1); nodes.splice(i, 1);
} else { } else {
nodes[i] = replacement; nodes[i] = replacement;
} }
if (!dontUpdateLastIndex) { if (!dont_update_last_index) {
nodes.claim_info.last_index = i; nodes.claim_info.last_index = i;
} }
return node; return node;
@ -654,13 +656,13 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd
for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) { for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {
const node = nodes[i]; const node = nodes[i];
if (predicate(node)) { if (predicate(node)) {
const replacement = processNode(node); const replacement = process_node(node);
if (replacement === undefined) { if (replacement === undefined) {
nodes.splice(i, 1); nodes.splice(i, 1);
} else { } else {
nodes[i] = replacement; nodes[i] = replacement;
} }
if (!dontUpdateLastIndex) { if (!dont_update_last_index) {
nodes.claim_info.last_index = i; nodes.claim_info.last_index = i;
} else if (replacement === undefined) { } else if (replacement === undefined) {
// Since we spliced before the last_index, we decrease it // Since we spliced before the last_index, we decrease it
@ -670,11 +672,11 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd
} }
} }
// If we can't find any matching node, we create a new one // If we can't find any matching node, we create a new one
return createNode(); return create_node();
})(); })();
resultNode.claim_order = nodes.claim_info.total_claimed; result_node.claim_order = nodes.claim_info.total_claimed;
nodes.claim_info.total_claimed += 1; nodes.claim_info.total_claimed += 1;
return resultNode; return result_node;
} }
/** /**
@ -736,13 +738,13 @@ export function claim_text(nodes, data) {
(node) => node.nodeType === 3, (node) => node.nodeType === 3,
/** @param {Text} node */ /** @param {Text} node */
(node) => { (node) => {
const dataStr = '' + data; const data_str = '' + data;
if (node.data.startsWith(dataStr)) { if (node.data.startsWith(data_str)) {
if (node.data.length !== dataStr.length) { if (node.data.length !== data_str.length) {
return node.splitText(dataStr.length); return node.splitText(data_str.length);
} }
} else { } else {
node.data = dataStr; node.data = data_str;
} }
}, },
() => text(data), () => text(data),

@ -1,6 +1,8 @@
{ {
"plugins": ["lube"],
"rules": { "rules": {
"no-console": "off", "no-console": "off",
"@typescript-eslint/no-var-requires": "off" "@typescript-eslint/no-var-requires": "off",
"lube/svelte-naming-convention": ["error", { "fixSameNames": true }]
} }
} }

@ -20,14 +20,14 @@ describe('compiler-errors', () => {
it_fn(dir, () => { it_fn(dir, () => {
const cwd = path.resolve(`${__dirname}/samples/${dir}`); const cwd = path.resolve(`${__dirname}/samples/${dir}`);
const compileOptions = Object.assign({}, config.compileOptions || {}, { const compile_options = Object.assign({}, config.compileOptions || {}, {
immutable: config.immutable, immutable: config.immutable,
accessors: 'accessors' in config ? config.accessors : true, accessors: 'accessors' in config ? config.accessors : true,
generate: 'dom' generate: 'dom'
}); });
try { try {
compile(fs.readFileSync(`${cwd}/main.svelte`, 'utf-8'), compileOptions); compile(fs.readFileSync(`${cwd}/main.svelte`, 'utf-8'), compile_options);
} catch (error) { } catch (error) {
if (typeof config.error === 'function') { if (typeof config.error === 'function') {
config.error(assert, error); config.error(assert, error);

@ -2,11 +2,11 @@ export default {
compileOptions: { compileOptions: {
filename: 'src/components/FooSwitcher.svelte', filename: 'src/components/FooSwitcher.svelte',
cssHash({ hash, css, name, filename }) { cssHash({ hash, css, name, filename }) {
const minFilename = filename const min_filename = filename
.split('/') .split('/')
.map((i) => i.charAt(0).toLowerCase()) .map((i) => i.charAt(0).toLowerCase())
.join(''); .join('');
return `sv-${name}-${minFilename}-${hash(css)}`; return `sv-${name}-${min_filename}-${hash(css)}`;
} }
} }
}; };

@ -1,10 +1,11 @@
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import glob from 'tiny-glob/sync';
import colors from 'kleur';
import { assert } from 'vitest'; import { assert } from 'vitest';
import colors from 'kleur';
import { compile } from 'svelte/compiler'; import { compile } from 'svelte/compiler';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import glob from 'tiny-glob/sync';
export function try_load_json(file) { export function try_load_json(file) {
try { try {
@ -158,8 +159,8 @@ export function create_loader(compileOptions, cwd) {
) )
.replace( .replace(
/^import (\w+, )?{([^}]+)} from ['"](.+)['"];?/gm, /^import (\w+, )?{([^}]+)} from ['"](.+)['"];?/gm,
(_, default_, names, source) => { (_, _default, names, source) => {
const d = default_ ? `default: ${default_}` : ''; const d = _default ? `default: ${_default}` : '';
return `const { ${d} ${names.replaceAll( return `const { ${d} ${names.replaceAll(
' as ', ' as ',
': ' ': '

@ -18,12 +18,12 @@ describe('hydration', async () => {
it_fn(dir, async () => { it_fn(dir, async () => {
const cwd = path.resolve(`${__dirname}/samples/${dir}`); const cwd = path.resolve(`${__dirname}/samples/${dir}`);
const compileOptions = Object.assign({}, config.compileOptions, { const compile_options = Object.assign({}, config.compileOptions, {
accessors: 'accessors' in config ? config.accessors : true, accessors: 'accessors' in config ? config.accessors : true,
hydratable: true hydratable: true
}); });
const { default: SvelteComponent } = await create_loader(compileOptions, cwd)('main.svelte'); const { default: SvelteComponent } = await create_loader(compile_options, cwd)('main.svelte');
const target = window.document.body; const target = window.document.body;
const head = window.document.head; const head = window.document.head;

@ -2,12 +2,12 @@ export default {
props: {}, props: {},
snapshot(target) { snapshot(target) {
const nullText = target.querySelectorAll('p')[0].textContent; const null_text = target.querySelectorAll('p')[0].textContent;
const undefinedText = target.querySelectorAll('p')[1].textContent; const undefined_text = target.querySelectorAll('p')[1].textContent;
return { return {
nullText, nullText: null_text,
undefinedText undefinedText: undefined_text
}; };
} }
}; };

@ -26,8 +26,8 @@ describe('parse', () => {
.trimEnd() .trimEnd()
.replace(/\r/g, ''); .replace(/\r/g, '');
const expectedOutput = try_load_json(`${__dirname}/samples/${dir}/output.json`); const expected_output = try_load_json(`${__dirname}/samples/${dir}/output.json`);
const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`);
try { try {
const { ast } = svelte.compile( const { ast } = svelte.compile(
@ -42,16 +42,16 @@ describe('parse', () => {
JSON.stringify(ast, null, '\t') JSON.stringify(ast, null, '\t')
); );
assert.deepEqual(ast.html, expectedOutput.html); assert.deepEqual(ast.html, expected_output.html);
assert.deepEqual(ast.css, expectedOutput.css); assert.deepEqual(ast.css, expected_output.css);
assert.deepEqual(ast.instance, expectedOutput.instance); assert.deepEqual(ast.instance, expected_output.instance);
assert.deepEqual(ast.module, expectedOutput.module); assert.deepEqual(ast.module, expected_output.module);
} catch (err) { } catch (err) {
if (err.name !== 'ParseError') throw err; if (err.name !== 'ParseError') throw err;
if (!expectedError) throw err; if (!expected_error) throw err;
const { code, message, pos, start } = err; const { code, message, pos, start } = err;
assert.deepEqual({ code, message, pos, start }, expectedError); assert.deepEqual({ code, message, pos, start }, expected_error);
} }
}); });
}); });

@ -33,10 +33,10 @@ export function ok(condition, message) {
} }
export function htmlEqual(actual, expected, message) { export function htmlEqual(actual, expected, message) {
return deepEqual(normalizeHtml(window, actual), normalizeHtml(window, expected), message); return deepEqual(normalize_html(window, actual), normalize_html(window, expected), message);
} }
function normalizeHtml(window, html) { function normalize_html(window, html) {
try { try {
const node = window.document.createElement('div'); const node = window.document.createElement('div');
node.innerHTML = html node.innerHTML = html
@ -44,7 +44,7 @@ function normalizeHtml(window, html) {
.replace(/>[\s\r\n]+</g, '><') .replace(/>[\s\r\n]+</g, '><')
.trim(); .trim();
normalizeStyles(node); normalize_styles(node);
return node.innerHTML.replace(/<\/?noscript\/?>/g, ''); return node.innerHTML.replace(/<\/?noscript\/?>/g, '');
} catch (err) { } catch (err) {
@ -52,14 +52,14 @@ function normalizeHtml(window, html) {
} }
} }
function normalizeStyles(node) { function normalize_styles(node) {
if (node.nodeType === 1) { if (node.nodeType === 1) {
if (node.hasAttribute('style')) { if (node.hasAttribute('style')) {
node.style = node.style.cssText; node.style = node.style.cssText;
} }
for (const child of node.childNodes) { for (const child of node.childNodes) {
normalizeStyles(child); normalize_styles(child);
} }
} }
} }

@ -93,7 +93,7 @@ async function run_browser_test(dir) {
globalName: 'test' globalName: 'test'
}); });
function assertWarnings() { function assert_warnings() {
if (config.warnings) { if (config.warnings) {
assert.deepStrictEqual( assert.deepStrictEqual(
warnings.map((w) => ({ warnings.map((w) => ({
@ -112,7 +112,7 @@ async function run_browser_test(dir) {
} }
} }
assertWarnings(); assert_warnings();
try { try {
const page = await browser.newPage(); const page = await browser.newPage();
@ -191,7 +191,7 @@ async function run_custom_elements_test(dir) {
globalName: 'test' globalName: 'test'
}); });
function assertWarnings() { function assert_warnings() {
if (expected_warnings) { if (expected_warnings) {
assert.deepStrictEqual( assert.deepStrictEqual(
warnings.map((w) => ({ warnings.map((w) => ({
@ -205,7 +205,7 @@ async function run_custom_elements_test(dir) {
); );
} }
} }
assertWarnings(); assert_warnings();
const page = await browser.newPage(); const page = await browser.newPage();
page.on('console', (type) => { page.on('console', (type) => {

@ -6,25 +6,25 @@ export default async function (target) {
target.innerHTML = '<custom-element red white></custom-element>'; target.innerHTML = '<custom-element red white></custom-element>';
await tick(); await tick();
await tick(); await tick();
const ceRoot = target.querySelector('custom-element').shadowRoot; const ce_root = target.querySelector('custom-element').shadowRoot;
const div = ceRoot.querySelector('div'); const div = ce_root.querySelector('div');
const p = ceRoot.querySelector('p'); const p = ce_root.querySelector('p');
const button = ceRoot.querySelector('button'); const button = ce_root.querySelector('button');
assert.equal(getComputedStyle(div).color, 'rgb(255, 0, 0)'); assert.equal(getComputedStyle(div).color, 'rgb(255, 0, 0)');
assert.equal(getComputedStyle(p).color, 'rgb(255, 255, 255)'); assert.equal(getComputedStyle(p).color, 'rgb(255, 255, 255)');
const innerRoot = ceRoot.querySelector('my-widget').shadowRoot; const inner_root = ce_root.querySelector('my-widget').shadowRoot;
const innerDiv = innerRoot.querySelector('div'); const inner_div = inner_root.querySelector('div');
const innerP = innerRoot.querySelector('p'); const inner_p = inner_root.querySelector('p');
assert.equal(getComputedStyle(innerDiv).color, 'rgb(255, 0, 0)'); assert.equal(getComputedStyle(inner_div).color, 'rgb(255, 0, 0)');
assert.equal(getComputedStyle(innerP).color, 'rgb(255, 255, 255)'); assert.equal(getComputedStyle(inner_p).color, 'rgb(255, 255, 255)');
button.click(); button.click();
await tick(); await tick();
await tick(); await tick();
assert.equal(getComputedStyle(div).color, 'rgb(0, 0, 0)'); assert.equal(getComputedStyle(div).color, 'rgb(0, 0, 0)');
assert.equal(getComputedStyle(innerDiv).color, 'rgb(0, 0, 0)'); assert.equal(getComputedStyle(inner_div).color, 'rgb(0, 0, 0)');
} }

@ -30,7 +30,7 @@ export default async function (target) {
const component = new SvelteComponent(options); const component = new SvelteComponent(options);
const waitUntil = async (fn, ms = 500) => { const wait_until = async (fn, ms = 500) => {
const start = new Date().getTime(); const start = new Date().getTime();
do { do {
if (fn()) return; if (fn()) return;
@ -48,7 +48,7 @@ export default async function (target) {
component, component,
target, target,
window, window,
waitUntil waitUntil: wait_until
}); });
component.$destroy(); component.$destroy();

@ -45,14 +45,14 @@ export default {
` `
); );
const circleColor1 = target.querySelector('#svg-1 circle'); const circle_color1 = target.querySelector('#svg-1 circle');
const rectColor1 = target.querySelector('#svg-1 rect'); const rect_color1 = target.querySelector('#svg-1 rect');
const circleColor2 = target.querySelector('#svg-2 circle'); const circle_color2 = target.querySelector('#svg-2 circle');
const rectColor2 = target.querySelector('#svg-2 rect'); const rect_color2 = target.querySelector('#svg-2 rect');
assert.htmlEqual(window.getComputedStyle(circleColor1).fill, 'rgb(255, 0, 0)'); assert.htmlEqual(window.getComputedStyle(circle_color1).fill, 'rgb(255, 0, 0)');
assert.htmlEqual(window.getComputedStyle(rectColor1).fill, 'rgb(255, 255, 0)'); assert.htmlEqual(window.getComputedStyle(rect_color1).fill, 'rgb(255, 255, 0)');
assert.htmlEqual(window.getComputedStyle(circleColor2).fill, 'rgb(0, 255, 255)'); assert.htmlEqual(window.getComputedStyle(circle_color2).fill, 'rgb(0, 255, 255)');
assert.htmlEqual(window.getComputedStyle(rectColor2).fill, 'rgb(0, 0, 0)'); assert.htmlEqual(window.getComputedStyle(rect_color2).fill, 'rgb(0, 0, 0)');
} }
}; };

@ -14,14 +14,14 @@ export default {
</div> </div>
`, `,
test({ target, window, assert }) { test({ target, window, assert }) {
const railColor1 = target.querySelector('#slider-1 p'); const rail_color1 = target.querySelector('#slider-1 p');
const trackColor1 = target.querySelector('#slider-1 span'); const track_color1 = target.querySelector('#slider-1 span');
const railColor2 = target.querySelector('#slider-2 p'); const rail_color2 = target.querySelector('#slider-2 p');
const trackColor2 = target.querySelector('#slider-2 span'); const track_color2 = target.querySelector('#slider-2 span');
assert.htmlEqual(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.htmlEqual(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.htmlEqual(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.htmlEqual(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.htmlEqual(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.htmlEqual(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.htmlEqual(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.htmlEqual(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
} }
}; };

@ -18,31 +18,31 @@ export default {
`, `,
test({ target, window, assert, component }) { test({ target, window, assert, component }) {
function assert_slider_1() { function assert_slider_1() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(railColor1.textContent, 'Slider1'); assert.equal(rail_color1.textContent, 'Slider1');
assert.equal(railColor2.textContent, 'Slider1'); assert.equal(rail_color2.textContent, 'Slider1');
} }
function assert_slider_2() { function assert_slider_2() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(railColor1.textContent, 'Slider2'); assert.equal(rail_color1.textContent, 'Slider2');
assert.equal(railColor2.textContent, 'Slider2'); assert.equal(rail_color2.textContent, 'Slider2');
} }
assert_slider_1(); assert_slider_1();

@ -20,31 +20,31 @@ export default {
`, `,
test({ target, window, assert, component }) { test({ target, window, assert, component }) {
function assert_slider_1() { function assert_slider_1() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(railColor1.textContent, 'Slider1'); assert.equal(rail_color1.textContent, 'Slider1');
assert.equal(railColor2.textContent, 'Slider1'); assert.equal(rail_color2.textContent, 'Slider1');
} }
function assert_slider_2() { function assert_slider_2() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(railColor1.textContent, 'Slider2'); assert.equal(rail_color1.textContent, 'Slider2');
assert.equal(railColor2.textContent, 'Slider2'); assert.equal(rail_color2.textContent, 'Slider2');
} }
assert_slider_1(); assert_slider_1();

@ -22,26 +22,26 @@ export default {
</div> </div>
`, `,
test({ target, window, assert }) { test({ target, window, assert }) {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
const nestRailColor1 = target.querySelector('#nest-component1 p'); const nest_rail_color1 = target.querySelector('#nest-component1 p');
const nestTrackColor1 = target.querySelector('#nest-component1 span'); const nest_track_color1 = target.querySelector('#nest-component1 span');
const nestRailColor2 = target.querySelector('#nest-component2 p'); const nest_rail_color2 = target.querySelector('#nest-component2 p');
const nestTrackColor2 = target.querySelector('#nest-component2 span'); const nest_track_color2 = target.querySelector('#nest-component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(255, 255, 0)');
assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 0, 255)');
assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(0, 255, 255)');
assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 255, 255)');
assert.equal(railColor1.textContent, 'Slider1'); assert.equal(rail_color1.textContent, 'Slider1');
assert.equal(railColor2.textContent, 'Slider2'); assert.equal(rail_color2.textContent, 'Slider2');
assert.equal(nestRailColor1.textContent, 'Slider1'); assert.equal(nest_rail_color1.textContent, 'Slider1');
assert.equal(nestRailColor2.textContent, 'Slider2'); assert.equal(nest_rail_color2.textContent, 'Slider2');
} }
}; };

@ -25,51 +25,51 @@ export default {
`, `,
test({ target, window, assert, component }) { test({ target, window, assert, component }) {
function assert_slider_1() { function assert_slider_1() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
const nestRailColor1 = target.querySelector('#nest-component1 p'); const nest_rail_color1 = target.querySelector('#nest-component1 p');
const nestTrackColor1 = target.querySelector('#nest-component1 span'); const nest_track_color1 = target.querySelector('#nest-component1 span');
const nestRailColor2 = target.querySelector('#nest-component2 p'); const nest_rail_color2 = target.querySelector('#nest-component2 p');
const nestTrackColor2 = target.querySelector('#nest-component2 span'); const nest_track_color2 = target.querySelector('#nest-component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(255, 255, 0)'); assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(255, 255, 0)');
assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 0, 255)'); assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 0, 255)');
assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(255, 255, 0)'); assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(255, 255, 0)');
assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 0, 255)'); assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 0, 255)');
assert.equal(railColor1.textContent, 'Slider1'); assert.equal(rail_color1.textContent, 'Slider1');
assert.equal(railColor2.textContent, 'Slider1'); assert.equal(rail_color2.textContent, 'Slider1');
assert.equal(nestRailColor1.textContent, 'Slider1'); assert.equal(nest_rail_color1.textContent, 'Slider1');
assert.equal(nestRailColor2.textContent, 'Slider1'); assert.equal(nest_rail_color2.textContent, 'Slider1');
} }
function assert_slider_2() { function assert_slider_2() {
const railColor1 = target.querySelector('#component1 p'); const rail_color1 = target.querySelector('#component1 p');
const trackColor1 = target.querySelector('#component1 span'); const track_color1 = target.querySelector('#component1 span');
const railColor2 = target.querySelector('#component2 p'); const rail_color2 = target.querySelector('#component2 p');
const trackColor2 = target.querySelector('#component2 span'); const track_color2 = target.querySelector('#component2 span');
const nestRailColor1 = target.querySelector('#nest-component1 p'); const nest_rail_color1 = target.querySelector('#nest-component1 p');
const nestTrackColor1 = target.querySelector('#nest-component1 span'); const nest_track_color1 = target.querySelector('#nest-component1 span');
const nestRailColor2 = target.querySelector('#nest-component2 p'); const nest_rail_color2 = target.querySelector('#nest-component2 p');
const nestTrackColor2 = target.querySelector('#nest-component2 span'); const nest_track_color2 = target.querySelector('#nest-component2 span');
assert.equal(window.getComputedStyle(railColor1).color, 'rgb(0, 0, 0)'); assert.equal(window.getComputedStyle(rail_color1).color, 'rgb(0, 0, 0)');
assert.equal(window.getComputedStyle(trackColor1).color, 'rgb(255, 0, 0)'); assert.equal(window.getComputedStyle(track_color1).color, 'rgb(255, 0, 0)');
assert.equal(window.getComputedStyle(railColor2).color, 'rgb(0, 255, 0)'); assert.equal(window.getComputedStyle(rail_color2).color, 'rgb(0, 255, 0)');
assert.equal(window.getComputedStyle(trackColor2).color, 'rgb(0, 0, 255)'); assert.equal(window.getComputedStyle(track_color2).color, 'rgb(0, 0, 255)');
assert.equal(window.getComputedStyle(nestRailColor1).color, 'rgb(0, 255, 255)'); assert.equal(window.getComputedStyle(nest_rail_color1).color, 'rgb(0, 255, 255)');
assert.equal(window.getComputedStyle(nestTrackColor1).color, 'rgb(255, 255, 255)'); assert.equal(window.getComputedStyle(nest_track_color1).color, 'rgb(255, 255, 255)');
assert.equal(window.getComputedStyle(nestRailColor2).color, 'rgb(0, 255, 255)'); assert.equal(window.getComputedStyle(nest_rail_color2).color, 'rgb(0, 255, 255)');
assert.equal(window.getComputedStyle(nestTrackColor2).color, 'rgb(255, 255, 255)'); assert.equal(window.getComputedStyle(nest_track_color2).color, 'rgb(255, 255, 255)');
assert.equal(railColor1.textContent, 'Slider2'); assert.equal(rail_color1.textContent, 'Slider2');
assert.equal(railColor2.textContent, 'Slider2'); assert.equal(rail_color2.textContent, 'Slider2');
assert.equal(nestRailColor1.textContent, 'Slider2'); assert.equal(nest_rail_color1.textContent, 'Slider2');
assert.equal(nestRailColor2.textContent, 'Slider2'); assert.equal(nest_rail_color2.textContent, 'Slider2');
} }
assert_slider_1(); assert_slider_1();

@ -55,18 +55,18 @@ async function run_test(dir) {
const cwd = path.resolve(`${__dirname}/samples/${dir}`); const cwd = path.resolve(`${__dirname}/samples/${dir}`);
const compileOptions = Object.assign({}, config.compileOptions || {}, { const compile_options = Object.assign({}, config.compileOptions || {}, {
hydratable: hydrate, hydratable: hydrate,
immutable: config.immutable, immutable: config.immutable,
accessors: 'accessors' in config ? config.accessors : true accessors: 'accessors' in config ? config.accessors : true
}); });
const load = create_loader(compileOptions, cwd); const load = create_loader(compile_options, cwd);
let mod; let mod;
let SvelteComponent; let SvelteComponent;
let unintendedError = null; let unintended_error = null;
if (config.expect_unhandled_rejections) { if (config.expect_unhandled_rejections) {
listeners.forEach((listener) => { listeners.forEach((listener) => {
@ -111,7 +111,7 @@ async function run_test(dir) {
let snapshot = undefined; let snapshot = undefined;
if (hydrate && from_ssr_html) { if (hydrate && from_ssr_html) {
const load_ssr = create_loader({ ...compileOptions, generate: 'ssr' }, cwd); const load_ssr = create_loader({ ...compile_options, generate: 'ssr' }, cwd);
// ssr into target // ssr into target
if (config.before_test) config.before_test(); if (config.before_test) config.before_test();
@ -152,14 +152,14 @@ async function run_test(dir) {
console.warn = warn; console.warn = warn;
if (config.error) { if (config.error) {
unintendedError = true; unintended_error = true;
assert.fail('Expected a runtime error'); assert.fail('Expected a runtime error');
} }
if (config.warnings) { if (config.warnings) {
assert.deepEqual(warnings, config.warnings); assert.deepEqual(warnings, config.warnings);
} else if (warnings.length) { } else if (warnings.length) {
unintendedError = true; unintended_error = true;
assert.fail('Received unexpected warnings'); assert.fail('Received unexpected warnings');
} }
@ -183,7 +183,7 @@ async function run_test(dir) {
snapshot, snapshot,
window, window,
raf, raf,
compileOptions, compileOptions: compile_options,
load load
}); });
} }
@ -201,7 +201,7 @@ async function run_test(dir) {
await test() await test()
.catch((err) => { .catch((err) => {
if (config.error && !unintendedError) { if (config.error && !unintended_error) {
if (typeof config.error === 'function') { if (typeof config.error === 'function') {
config.error(assert, err); config.error(assert, err);
} else { } else {
@ -217,7 +217,7 @@ async function run_test(dir) {
mkdirp(path.dirname(out)); // file could be in subdirectory, therefore don't use dir mkdirp(path.dirname(out)); // file could be in subdirectory, therefore don't use dir
const { js } = compile(fs.readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, ''), { const { js } = compile(fs.readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, ''), {
...compileOptions, ...compile_options,
filename: file filename: file
}); });
fs.writeFileSync(out, js.code); fs.writeFileSync(out, js.code);

@ -10,9 +10,9 @@ export default {
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn1.dispatchEvent(clickEvent); await btn1.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -24,7 +24,7 @@ export default {
` `
); );
await btn2.dispatchEvent(clickEvent); await btn2.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -36,7 +36,7 @@ export default {
` `
); );
await btn3.dispatchEvent(clickEvent); await btn3.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -48,7 +48,7 @@ export default {
` `
); );
await btn4.dispatchEvent(clickEvent); await btn4.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -12,9 +12,9 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn1.dispatchEvent(clickEvent); await btn1.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -27,7 +27,7 @@ export default {
` `
); );
await btn2.dispatchEvent(clickEvent); await btn2.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -40,7 +40,7 @@ export default {
` `
); );
await btn3.dispatchEvent(clickEvent); await btn3.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -53,7 +53,7 @@ export default {
` `
); );
await btn4.dispatchEvent(clickEvent); await btn4.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -5,10 +5,10 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const button = target.querySelector('button'); const button = target.querySelector('button');
const eventEnter = new window.MouseEvent('mouseenter'); const event_enter = new window.MouseEvent('mouseenter');
const eventLeave = new window.MouseEvent('mouseleave'); const event_leave = new window.MouseEvent('mouseleave');
await button.dispatchEvent(eventEnter); await button.dispatchEvent(event_enter);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -17,7 +17,7 @@ export default {
` `
); );
await button.dispatchEvent(eventLeave); await button.dispatchEvent(event_leave);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -7,7 +7,7 @@ export default {
const button = target.querySelector('button'); const button = target.querySelector('button');
const enter = new window.MouseEvent('mouseenter'); const enter = new window.MouseEvent('mouseenter');
const leave = new window.MouseEvent('mouseleave'); const leave = new window.MouseEvent('mouseleave');
const ctrlPress = new window.KeyboardEvent('keydown', { ctrlKey: true }); const ctrl_press = new window.KeyboardEvent('keydown', { ctrlKey: true });
await button.dispatchEvent(enter); await button.dispatchEvent(enter);
assert.htmlEqual( assert.htmlEqual(
@ -18,7 +18,7 @@ export default {
` `
); );
await window.dispatchEvent(ctrlPress); await window.dispatchEvent(ctrl_press);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -5,10 +5,10 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const button = target.querySelector('button'); const button = target.querySelector('button');
const eventEnter = new window.MouseEvent('mouseenter'); const event_enter = new window.MouseEvent('mouseenter');
const eventLeave = new window.MouseEvent('mouseleave'); const event_leave = new window.MouseEvent('mouseleave');
await button.dispatchEvent(eventEnter); await button.dispatchEvent(event_enter);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -17,7 +17,7 @@ export default {
` `
); );
await button.dispatchEvent(eventLeave); await button.dispatchEvent(event_leave);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -1,8 +1,8 @@
const realPromise = Promise.resolve(42); const real_promise = Promise.resolve(42);
const promise = () => {}; const promise = () => {};
promise.then = realPromise.then.bind(realPromise); promise.then = real_promise.then.bind(real_promise);
promise.catch = realPromise.catch.bind(realPromise); promise.catch = real_promise.catch.bind(real_promise);
export default { export default {
get props() { get props() {

@ -1,13 +1,13 @@
let fulfil; let fulfil;
const thePromise = new Promise((f) => { const the_promise = new Promise((f) => {
fulfil = f; fulfil = f;
}); });
const items = [ const items = [
{ {
title: 'a title', title: 'a title',
data: thePromise data: the_promise
} }
]; ];
@ -23,7 +23,7 @@ export default {
test({ assert, target }) { test({ assert, target }) {
fulfil(42); fulfil(42);
return thePromise.then(() => { return the_promise.then(() => {
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -28,10 +28,10 @@ export default {
assert.equal(component.clicked, 42); assert.equal(component.clicked, 42);
const thePromise = Promise.resolve(43); const the_promise = Promise.resolve(43);
component.thePromise = thePromise; component.thePromise = the_promise;
return thePromise; return the_promise;
}) })
.then(() => { .then(() => {
const { button } = component; const { button } = component;

@ -1,12 +1,12 @@
let fulfil; let fulfil;
const thePromise = new Promise((f) => { const the_promise = new Promise((f) => {
fulfil = f; fulfil = f;
}); });
export default { export default {
get props() { get props() {
return { show: true, thePromise }; return { show: true, thePromise: the_promise };
}, },
html: ` html: `
@ -16,7 +16,7 @@ export default {
test({ assert, component, target }) { test({ assert, component, target }) {
fulfil(42); fulfil(42);
return thePromise.then(() => { return the_promise.then(() => {
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -35,7 +35,7 @@ export default {
component.show = true; component.show = true;
return thePromise.then(() => { return the_promise.then(() => {
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -1,12 +1,12 @@
let fulfil; let fulfil;
const thePromise = new Promise((f) => { const the_promise = new Promise((f) => {
fulfil = f; fulfil = f;
}); });
export default { export default {
get props() { get props() {
return { thePromise }; return { thePromise: the_promise };
}, },
html: ` html: `
@ -16,7 +16,7 @@ export default {
test({ assert, target }) { test({ assert, target }) {
fulfil(42); fulfil(42);
return thePromise.then(() => { return the_promise.then(() => {
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -1,12 +1,12 @@
let fulfil; let fulfil;
const thePromise = new Promise((f) => { const the_promise = new Promise((f) => {
fulfil = f; fulfil = f;
}); });
export default { export default {
get props() { get props() {
return { thePromise }; return { thePromise: the_promise };
}, },
html: ` html: `
@ -16,7 +16,7 @@ export default {
async test({ assert, target }) { async test({ assert, target }) {
fulfil([]); fulfil([]);
await thePromise; await the_promise;
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -15,12 +15,12 @@ export default {
test({ assert, component, target, window }) { test({ assert, component, target, window }) {
const { cats } = component; const { cats } = component;
const newCats = cats.slice(); const new_cats = cats.slice();
newCats.push({ new_cats.push({
name: 'cat ' + cats.length, name: 'cat ' + cats.length,
checked: false checked: false
}); });
component.cats = newCats; component.cats = new_cats;
let inputs = target.querySelectorAll('input'); let inputs = target.querySelectorAll('input');
assert.equal(inputs.length, 3); assert.equal(inputs.length, 3);

@ -23,7 +23,7 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const inputs = target.querySelectorAll('input'); const inputs = target.querySelectorAll('input');
const checked = new Set(); const checked = new Set();
const checkInbox = async (i) => { const check_inbox = async (i) => {
checked.add(i); checked.add(i);
inputs[i].checked = true; inputs[i].checked = true;
await inputs[i].dispatchEvent(event); await inputs[i].dispatchEvent(event);
@ -35,17 +35,17 @@ export default {
const event = new window.Event('change'); const event = new window.Event('change');
await checkInbox(2); await check_inbox(2);
for (let i = 0; i < 18; i++) { for (let i = 0; i < 18; i++) {
assert.equal(inputs[i].checked, checked.has(i)); assert.equal(inputs[i].checked, checked.has(i));
} }
await checkInbox(12); await check_inbox(12);
for (let i = 0; i < 18; i++) { for (let i = 0; i < 18; i++) {
assert.equal(inputs[i].checked, checked.has(i)); assert.equal(inputs[i].checked, checked.has(i));
} }
await checkInbox(8); await check_inbox(8);
for (let i = 0; i < 18; i++) { for (let i = 0; i < 18; i++) {
assert.equal(inputs[i].checked, checked.has(i)); assert.equal(inputs[i].checked, checked.has(i));
} }

@ -1,8 +1,8 @@
export default { export default {
async test({ assert, target, component, window }) { async test({ assert, target, component, window }) {
const button = target.querySelector('button'); const button = target.querySelector('button');
const clickEvent = new window.Event('click'); const click_event = new window.Event('click');
const changeEvent = new window.Event('change'); const change_event = new window.Event('change');
const [input1, input2] = target.querySelectorAll('input[type="checkbox"]'); const [input1, input2] = target.querySelectorAll('input[type="checkbox"]');
function validate_inputs(v1, v2) { function validate_inputs(v1, v2) {
@ -17,24 +17,24 @@ export default {
validate_inputs(true, true); validate_inputs(true, true);
input1.checked = false; input1.checked = false;
await input1.dispatchEvent(changeEvent); await input1.dispatchEvent(change_event);
assert.deepEqual(component.test, ['b']); assert.deepEqual(component.test, ['b']);
input2.checked = false; input2.checked = false;
await input2.dispatchEvent(changeEvent); await input2.dispatchEvent(change_event);
assert.deepEqual(component.test, []); assert.deepEqual(component.test, []);
input1.checked = true; input1.checked = true;
input2.checked = true; input2.checked = true;
await input1.dispatchEvent(changeEvent); await input1.dispatchEvent(change_event);
await input2.dispatchEvent(changeEvent); await input2.dispatchEvent(change_event);
assert.deepEqual(component.test, ['b', 'a']); assert.deepEqual(component.test, ['b', 'a']);
await button.dispatchEvent(clickEvent); await button.dispatchEvent(click_event);
assert.deepEqual(component.test, ['b', 'a']); // should it be ['a'] only? valid arguments for both outcomes assert.deepEqual(component.test, ['b', 'a']); // should it be ['a'] only? valid arguments for both outcomes
input1.checked = false; input1.checked = false;
await input1.dispatchEvent(changeEvent); await input1.dispatchEvent(change_event);
assert.deepEqual(component.test, []); assert.deepEqual(component.test, []);
} }
}; };

@ -1,8 +1,8 @@
export default { export default {
async test({ assert, target, component, window }) { async test({ assert, target, component, window }) {
const button = target.querySelector('button'); const button = target.querySelector('button');
const clickEvent = new window.Event('click'); const click_event = new window.Event('click');
const changeEvent = new window.Event('change'); const change_event = new window.Event('change');
const [input1, input2] = target.querySelectorAll('input[type="radio"]'); const [input1, input2] = target.querySelectorAll('input[type="radio"]');
function validate_inputs(v1, v2) { function validate_inputs(v1, v2) {
@ -17,18 +17,18 @@ export default {
validate_inputs(false, true); validate_inputs(false, true);
input1.checked = true; input1.checked = true;
await input1.dispatchEvent(changeEvent); await input1.dispatchEvent(change_event);
assert.deepEqual(component.test, 'a'); assert.deepEqual(component.test, 'a');
input2.checked = true; input2.checked = true;
await input2.dispatchEvent(changeEvent); await input2.dispatchEvent(change_event);
assert.deepEqual(component.test, 'b'); assert.deepEqual(component.test, 'b');
await button.dispatchEvent(clickEvent); await button.dispatchEvent(click_event);
assert.deepEqual(component.test, 'b'); // should it be undefined? valid arguments for both outcomes assert.deepEqual(component.test, 'b'); // should it be undefined? valid arguments for both outcomes
input1.checked = true; input1.checked = true;
await input1.dispatchEvent(changeEvent); await input1.dispatchEvent(change_event);
assert.deepEqual(component.test, 'a'); assert.deepEqual(component.test, 'a');
} }
}; };

@ -1,25 +1,25 @@
export default { export default {
test({ assert, target, window, component }) { test({ assert, target, window, component }) {
const input = target.querySelector('input'); const input = target.querySelector('input');
const inputEvent = new window.InputEvent('input'); const input_event = new window.InputEvent('input');
assert.equal(component.value, 5); assert.equal(component.value, 5);
assert.equal(input.value, '5'); assert.equal(input.value, '5');
input.value = '5.'; input.value = '5.';
input.dispatchEvent(inputEvent); input.dispatchEvent(input_event);
// input type number has value === "" if ends with dot/comma // input type number has value === "" if ends with dot/comma
assert.equal(component.value, undefined); assert.equal(component.value, undefined);
assert.equal(input.value, ''); assert.equal(input.value, '');
input.value = '5.5'; input.value = '5.5';
input.dispatchEvent(inputEvent); input.dispatchEvent(input_event);
assert.equal(component.value, 5.5); assert.equal(component.value, 5.5);
assert.equal(input.value, '5.5'); assert.equal(input.value, '5.5');
input.value = '5.50'; input.value = '5.50';
input.dispatchEvent(inputEvent); input.dispatchEvent(input_event);
assert.equal(component.value, 5.5); assert.equal(component.value, 5.5);
assert.equal(input.value, '5.50'); assert.equal(input.value, '5.50');

@ -9,13 +9,13 @@ const components = [
} }
]; ];
const selectedComponent = components[0]; const selected_component = components[0];
export default { export default {
skip: true, // doesn't reflect real-world bug, maybe a JSDOM quirk skip: true, // doesn't reflect real-world bug, maybe a JSDOM quirk
get props() { get props() {
return { components, selectedComponent }; return { components, selectedComponent: selected_component };
}, },
html: ` html: `

@ -5,13 +5,13 @@ export default {
`, `,
async test({ assert, component, target, window }) { async test({ assert, component, target, window }) {
const [updateButton, button] = target.querySelectorAll('button'); const [update_button, button] = target.querySelectorAll('button');
const event = new window.MouseEvent('click'); const event = new window.MouseEvent('click');
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.equal(component.count, 1); assert.equal(component.count, 1);
await updateButton.dispatchEvent(event); await update_button.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.equal(component.count, 11); assert.equal(component.count, 11);
} }

@ -5,10 +5,10 @@ export default {
`, `,
async test({ assert, component, target, window }) { async test({ assert, component, target, window }) {
const [updateButton, button] = target.querySelectorAll('button'); const [update_button, button] = target.querySelectorAll('button');
const event = new window.MouseEvent('click'); const event = new window.MouseEvent('click');
await updateButton.dispatchEvent(event); await update_button.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.equal(component.count, 10); assert.equal(component.count, 10);

@ -3,7 +3,7 @@ export default {
ssrHtml: '<input value="Blub"> <input value="Blub"> <input value="Blub">', ssrHtml: '<input value="Blub"> <input value="Blub"> <input value="Blub">',
async test({ assert, target, component, window }) { async test({ assert, target, component, window }) {
const [input1, input2, inputFallback] = target.querySelectorAll('input'); const [input1, input2, input_fallback] = target.querySelectorAll('input');
assert.equal(component.getSubscriberCount(), 3); assert.equal(component.getSubscriberCount(), 3);
@ -13,7 +13,7 @@ export default {
await input1.dispatchEvent(new window.Event('input')); await input1.dispatchEvent(new window.Event('input'));
assert.equal(input1.value, 'ab'); assert.equal(input1.value, 'ab');
assert.equal(input2.value, 'ab'); assert.equal(input2.value, 'ab');
assert.equal(inputFallback.value, 'ab'); assert.equal(input_fallback.value, 'ab');
component.props = 'hello'; component.props = 'hello';

@ -6,9 +6,9 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -18,7 +18,7 @@ export default {
` `
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -1,6 +1,6 @@
let originalDivGetBoundingClientRect; let original_div_get_bounding_client_rect;
let originalSpanGetBoundingClientRect; let original_span_get_bounding_client_rect;
let originalParagraphGetBoundingClientRect; let original_paragraph_get_bounding_client_rect;
export default { export default {
skip_if_ssr: true, skip_if_ssr: true,
@ -26,16 +26,16 @@ export default {
`, `,
before_test() { before_test() {
originalDivGetBoundingClientRect = window.HTMLDivElement.prototype.getBoundingClientRect; original_div_get_bounding_client_rect = window.HTMLDivElement.prototype.getBoundingClientRect;
originalSpanGetBoundingClientRect = window.HTMLSpanElement.prototype.getBoundingClientRect; original_span_get_bounding_client_rect = window.HTMLSpanElement.prototype.getBoundingClientRect;
originalParagraphGetBoundingClientRect = original_paragraph_get_bounding_client_rect =
window.HTMLParagraphElement.prototype.getBoundingClientRect; window.HTMLParagraphElement.prototype.getBoundingClientRect;
window.HTMLDivElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; window.HTMLDivElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect;
window.HTMLSpanElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; window.HTMLSpanElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect;
window.HTMLParagraphElement.prototype.getBoundingClientRect = fakeGetBoundingClientRect; window.HTMLParagraphElement.prototype.getBoundingClientRect = fake_get_bounding_client_rect;
function fakeGetBoundingClientRect() { function fake_get_bounding_client_rect() {
const index = [...this.parentNode.children].indexOf(this); const index = [...this.parentNode.children].indexOf(this);
const top = index * 30; const top = index * 30;
@ -48,10 +48,10 @@ export default {
} }
}, },
after_test() { after_test() {
window.HTMLDivElement.prototype.getBoundingClientRect = originalDivGetBoundingClientRect; window.HTMLDivElement.prototype.getBoundingClientRect = original_div_get_bounding_client_rect;
window.HTMLSpanElement.prototype.getBoundingClientRect = originalSpanGetBoundingClientRect; window.HTMLSpanElement.prototype.getBoundingClientRect = original_span_get_bounding_client_rect;
window.HTMLParagraphElement.prototype.getBoundingClientRect = window.HTMLParagraphElement.prototype.getBoundingClientRect =
originalParagraphGetBoundingClientRect; original_paragraph_get_bounding_client_rect;
}, },
async test({ assert, component, raf }) { async test({ assert, component, raf }) {

@ -13,10 +13,10 @@ export default {
assert.equal(input1.value, ''); assert.equal(input1.value, '');
assert.equal(input2.value, 'hello'); assert.equal(input2.value, 'hello');
const inputEvent = new window.InputEvent('input'); const input_event = new window.InputEvent('input');
input2.value = 'world'; input2.value = 'world';
input2.dispatchEvent(inputEvent); input2.dispatchEvent(input_event);
assert.equal(input2.value, 'world'); assert.equal(input2.value, 'world');
assert.equal(component.array[1].value, 'world'); assert.equal(component.array[1].value, 'world');
} }

@ -1,6 +1,6 @@
const VALUES = Array.from('abcdefghijklmnopqrstuvwxyz'); const VALUES = Array.from('abcdefghijklmnopqrstuvwxyz');
function toObjects(array) { function to_objects(array) {
return array.split('').map((x) => ({ id: x })); return array.split('').map((x) => ({ id: x }));
} }
@ -17,7 +17,7 @@ function permute() {
export default { export default {
get props() { get props() {
return { values: toObjects('abc') }; return { values: to_objects('abc') };
}, },
html: '(a)(b)(c)', html: '(a)(b)(c)',
@ -29,7 +29,7 @@ export default {
.split('') .split('')
.map((x) => `(${x})`) .map((x) => `(${x})`)
.join(''); .join('');
component.values = toObjects(sequence); component.values = to_objects(sequence);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
expected, expected,

@ -6,8 +6,8 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const button = target.querySelector('button'); const button = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await button.dispatchEvent(clickEvent); await button.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -9,10 +9,10 @@ export default {
<button>Test</button> <button>Test</button>
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
let [incrementBtn, ...buttons] = target.querySelectorAll('button'); let [increment_btn, ...buttons] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await buttons[0].dispatchEvent(clickEvent); await buttons[0].dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -27,7 +27,7 @@ export default {
` `
); );
await buttons[0].dispatchEvent(clickEvent); await buttons[0].dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -42,8 +42,8 @@ export default {
` `
); );
await buttons[2].dispatchEvent(clickEvent); await buttons[2].dispatchEvent(click_event);
await buttons[2].dispatchEvent(clickEvent); await buttons[2].dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -58,7 +58,7 @@ export default {
` `
); );
await incrementBtn.dispatchEvent(clickEvent); await increment_btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -75,9 +75,9 @@ export default {
` `
); );
[incrementBtn, ...buttons] = target.querySelectorAll('button'); [increment_btn, ...buttons] = target.querySelectorAll('button');
await buttons[3].dispatchEvent(clickEvent); await buttons[3].dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -9,7 +9,7 @@ export default {
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [updateButton1, updateButton2, button] = target.querySelectorAll('button'); const [update_button1, update_button2, button] = target.querySelectorAll('button');
const event = new window.MouseEvent('click'); const event = new window.MouseEvent('click');
let err = ''; let err = '';
@ -32,7 +32,7 @@ export default {
` `
); );
await updateButton1.dispatchEvent(event); await update_button1.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -46,7 +46,7 @@ export default {
` `
); );
await updateButton2.dispatchEvent(event); await update_button2.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -4,7 +4,7 @@ export default {
<button>invalid</button>`, <button>invalid</button>`,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [buttonUndef, buttonNull, buttonInvalid] = target.querySelectorAll('button'); const [button_undef, button_null, button_invalid] = target.querySelectorAll('button');
const event = new window.MouseEvent('click'); const event = new window.MouseEvent('click');
let err = ''; let err = '';
@ -14,13 +14,13 @@ export default {
}); });
// All three should not throw if proper checking is done in runtime code // All three should not throw if proper checking is done in runtime code
await buttonUndef.dispatchEvent(event); await button_undef.dispatchEvent(event);
assert.equal(err, '', err); assert.equal(err, '', err);
await buttonNull.dispatchEvent(event); await button_null.dispatchEvent(event);
assert.equal(err, '', err); assert.equal(err, '', err);
await buttonInvalid.dispatchEvent(event); await button_invalid.dispatchEvent(event);
assert.equal(err, '', err); assert.equal(err, '', err);
} }
}; };

@ -9,7 +9,7 @@ export default {
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [updateButton1, updateButton2, button] = target.querySelectorAll('button'); const [update_button1, update_button2, button] = target.querySelectorAll('button');
const event = new window.MouseEvent('click'); const event = new window.MouseEvent('click');
let err = ''; let err = '';
@ -32,7 +32,7 @@ export default {
` `
); );
await updateButton1.dispatchEvent(event); await update_button1.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -46,7 +46,7 @@ export default {
` `
); );
await updateButton2.dispatchEvent(event); await update_button2.dispatchEvent(event);
await button.dispatchEvent(event); await button.dispatchEvent(event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -10,21 +10,21 @@ export default {
assert.equal(component.updated, 4); assert.equal(component.updated, 4);
const [item1, item2] = target.childNodes; const [item1, item2] = target.childNodes;
const [item1Btn1, item1Btn2] = item1.querySelectorAll('button'); const [item1_btn1, item1_btn2] = item1.querySelectorAll('button');
const [item2Btn1, item2Btn2] = item2.querySelectorAll('button'); const [item2_btn1, item2_btn2] = item2.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await item1Btn1.dispatchEvent(clickEvent); await item1_btn1.dispatchEvent(click_event);
assert.equal(component.getNormalCount(), 1); assert.equal(component.getNormalCount(), 1);
await item1Btn2.dispatchEvent(clickEvent); await item1_btn2.dispatchEvent(click_event);
assert.equal(component.getModifierCount(), 1); assert.equal(component.getModifierCount(), 1);
await item2Btn1.dispatchEvent(clickEvent); await item2_btn1.dispatchEvent(click_event);
assert.equal(component.getNormalCount(), 2); assert.equal(component.getNormalCount(), 2);
await item2Btn2.dispatchEvent(clickEvent); await item2_btn2.dispatchEvent(click_event);
assert.equal(component.getModifierCount(), 2); assert.equal(component.getModifierCount(), 2);
} }
}; };

@ -11,11 +11,11 @@ export default {
`, `,
test({ assert, component }) { test({ assert, component }) {
const visibleThings = component.visibleThings; const visible_things = component.visibleThings;
assert.deepEqual(visibleThings, ['first thing', 'second thing']); assert.deepEqual(visible_things, ['first thing', 'second thing']);
const snapshots = component.snapshots; const snapshots = component.snapshots;
assert.deepEqual(snapshots, [visibleThings]); assert.deepEqual(snapshots, [visible_things]);
// TODO minimise the number of recomputations during oncreate // TODO minimise the number of recomputations during oncreate
// assert.equal(counter.count, 1); // assert.equal(counter.count, 1);

@ -7,10 +7,14 @@ export default {
}, },
async test({ assert, target }) { async test({ assert, target }) {
const firstSpanList = target.children[0]; const first_span_list = target.children[0];
assert.htmlEqualWithOptions(firstSpanList.innerHTML, expected, { withoutNormalizeHtml: true }); assert.htmlEqualWithOptions(first_span_list.innerHTML, expected, {
withoutNormalizeHtml: true
});
const secondSpanList = target.children[1]; const second_span_list = target.children[1];
assert.htmlEqualWithOptions(secondSpanList.innerHTML, expected, { withoutNormalizeHtml: true }); assert.htmlEqualWithOptions(second_span_list.innerHTML, expected, {
withoutNormalizeHtml: true
});
} }
}; };

@ -2,9 +2,9 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [btn1, btn2] = target.querySelectorAll('button'); const [btn1, btn2] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn2.dispatchEvent(clickEvent); await btn2.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -17,7 +17,7 @@ export default {
` `
); );
await btn1.dispatchEvent(clickEvent); await btn1.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -30,7 +30,7 @@ export default {
` `
); );
await btn2.dispatchEvent(clickEvent); await btn2.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -43,7 +43,7 @@ export default {
` `
); );
await btn1.dispatchEvent(clickEvent); await btn1.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `

@ -4,14 +4,14 @@ export default {
<div>&nbsp;hello&nbsp; &nbsp;hello</div>`, <div>&nbsp;hello&nbsp; &nbsp;hello</div>`,
test({ assert, target }) { test({ assert, target }) {
const divList = target.querySelectorAll('div'); const div_list = target.querySelectorAll('div');
assert.equal(divList[0].textContent.charCodeAt(0), 160); assert.equal(div_list[0].textContent.charCodeAt(0), 160);
assert.equal(divList[1].textContent.charCodeAt(0), 160); assert.equal(div_list[1].textContent.charCodeAt(0), 160);
assert.equal(divList[1].textContent.charCodeAt(6), 160); assert.equal(div_list[1].textContent.charCodeAt(6), 160);
assert.equal(divList[1].textContent.charCodeAt(7), 160); assert.equal(div_list[1].textContent.charCodeAt(7), 160);
assert.equal(divList[2].textContent.charCodeAt(0), 160); assert.equal(div_list[2].textContent.charCodeAt(0), 160);
assert.equal(divList[2].textContent.charCodeAt(6), 160); assert.equal(div_list[2].textContent.charCodeAt(6), 160);
assert.equal(divList[2].textContent.charCodeAt(7), 32); //normal space assert.equal(div_list[2].textContent.charCodeAt(7), 32); //normal space
assert.equal(divList[2].textContent.charCodeAt(8), 160); assert.equal(div_list[2].textContent.charCodeAt(8), 160);
} }
}; };

@ -14,7 +14,7 @@ export default {
// it's okay not to remove the node during hydration // it's okay not to remove the node during hydration
// will not be seen by user anyway // will not be seen by user anyway
removeNoScript(target); remove_no_script(target);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -26,7 +26,7 @@ export default {
} }
}; };
function removeNoScript(target) { function remove_no_script(target) {
target.querySelectorAll('noscript').forEach((elem) => { target.querySelectorAll('noscript').forEach((elem) => {
elem.parentNode.removeChild(elem); elem.parentNode.removeChild(elem);
}); });

@ -6,9 +6,9 @@ export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -6,9 +6,9 @@ export default {
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -19,7 +19,7 @@ export default {
` `
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -1,7 +1,7 @@
export default { export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
assert.equal( assert.equal(
window.document.head.innerHTML.includes( window.document.head.innerHTML.includes(
@ -10,7 +10,7 @@ export default {
true true
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.equal( assert.equal(
window.document.head.innerHTML.includes( window.document.head.innerHTML.includes(
@ -19,7 +19,7 @@ export default {
true true
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.equal( assert.equal(
window.document.head.innerHTML.includes( window.document.head.innerHTML.includes(

@ -6,9 +6,9 @@ export default {
`, `,
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -19,7 +19,7 @@ export default {
` `
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -13,9 +13,9 @@ export default {
}, },
async test({ assert, target, window }) { async test({ assert, target, window }) {
const btn = target.querySelector('button'); const btn = target.querySelector('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -28,7 +28,7 @@ export default {
` `
); );
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -11,8 +11,8 @@ export default {
// and we determine if svelte does not set the `input.value` again by // and we determine if svelte does not set the `input.value` again by
// spying on the setter of `input.value` // spying on the setter of `input.value`
const spy1 = spyOnValueSetter(input1, input1.value); const spy1 = spy_on_value_setter(input1, input1.value);
const spy2 = spyOnValueSetter(input2, input2.value); const spy2 = spy_on_value_setter(input2, input2.value);
const event = new window.Event('input'); const event = new window.Event('input');
@ -38,25 +38,25 @@ export default {
} }
}; };
function spyOnValueSetter(input, initialValue) { function spy_on_value_setter(input, initial_value) {
let value = initialValue; let value = initial_value;
let isSet = false; let is_set = false;
Object.defineProperty(input, 'value', { Object.defineProperty(input, 'value', {
get() { get() {
return value; return value;
}, },
set(_value) { set(_value) {
value = _value; value = _value;
isSet = true; is_set = true;
} }
}); });
return { return {
isSetCalled() { isSetCalled() {
return isSet; return is_set;
}, },
reset() { reset() {
isSet = false; is_set = false;
} }
}; };
} }

@ -1,6 +1,6 @@
export function omit(obj, ...keysToOmit) { export function omit(obj, ...keys_to_omit) {
return Object.keys(obj).reduce((acc, key) => { return Object.keys(obj).reduce((acc, key) => {
if (keysToOmit.indexOf(key) === -1) acc[key] = obj[key]; if (keys_to_omit.indexOf(key) === -1) acc[key] = obj[key];
return acc; return acc;
}, {}); }, {});
} }

@ -9,9 +9,9 @@ export default {
const input = target.querySelector('input'); const input = target.querySelector('input');
input.value = 'foo'; input.value = 'foo';
const inputEvent = new window.InputEvent('input'); const input_event = new window.InputEvent('input');
await input.dispatchEvent(inputEvent); await input.dispatchEvent(input_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -16,11 +16,11 @@ export default {
const input = target.querySelector('input'); const input = target.querySelector('input');
const button = target.querySelector('button'); const button = target.querySelector('button');
const inputEvent = new window.InputEvent('input'); const input_event = new window.InputEvent('input');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
input.value = 'foo'; input.value = 'foo';
await input.dispatchEvent(inputEvent); await input.dispatchEvent(input_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -32,7 +32,7 @@ export default {
` `
); );
await button.dispatchEvent(clickEvent); await button.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -44,7 +44,7 @@ export default {
); );
input.value = 'bar'; input.value = 'bar';
await input.dispatchEvent(inputEvent); await input.dispatchEvent(input_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -16,11 +16,11 @@ export default {
const input = target.querySelector('input'); const input = target.querySelector('input');
const button = target.querySelector('button'); const button = target.querySelector('button');
const inputEvent = new window.InputEvent('input'); const input_event = new window.InputEvent('input');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
input.value = 'foo'; input.value = 'foo';
await input.dispatchEvent(inputEvent); await input.dispatchEvent(input_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
@ -32,7 +32,7 @@ export default {
` `
); );
await button.dispatchEvent(clickEvent); await button.dispatchEvent(click_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
` `
@ -44,7 +44,7 @@ export default {
); );
input.value = 'bar'; input.value = 'bar';
await input.dispatchEvent(inputEvent); await input.dispatchEvent(input_event);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,

@ -1,11 +1,11 @@
let unsubscribeCalled = false; let unsubscribe_called = false;
const fakeStore = (val) => ({ const fake_store = (val) => ({
subscribe: (cb) => { subscribe: (cb) => {
cb(val); cb(val);
return { return {
unsubscribe: () => { unsubscribe: () => {
unsubscribeCalled = true; unsubscribe_called = true;
} }
}; };
} }
@ -13,17 +13,17 @@ const fakeStore = (val) => ({
export default { export default {
get props() { get props() {
return { foo: fakeStore(1) }; return { foo: fake_store(1) };
}, },
html: ` html: `
<h1>1</h1> <h1>1</h1>
`, `,
async test({ assert, component, target }) { async test({ assert, component, target }) {
component.foo = fakeStore(5); component.foo = fake_store(5);
assert.htmlEqual(target.innerHTML, '<h1>5</h1>'); assert.htmlEqual(target.innerHTML, '<h1>5</h1>');
assert.ok(unsubscribeCalled); assert.ok(unsubscribe_called);
} }
}; };

@ -8,8 +8,8 @@ export default {
`, `,
test({ assert, target }) { test({ assert, target }) {
const foreignObject = target.querySelector('foreignObject'); const foreign_object = target.querySelector('foreignObject');
assert.equal(foreignObject.namespaceURI, 'http://www.w3.org/2000/svg'); assert.equal(foreign_object.namespaceURI, 'http://www.w3.org/2000/svg');
const p = target.querySelector('p'); const p = target.querySelector('p');
assert.equal(p.namespaceURI, 'http://www.w3.org/1999/xhtml'); assert.equal(p.namespaceURI, 'http://www.w3.org/1999/xhtml');

@ -18,50 +18,53 @@ multiple leading newlines</textarea> <div id="div-with-textarea-with-multiple-le
multiple leading newlines</textarea></div>`, multiple leading newlines</textarea></div>`,
test({ assert, target }) { test({ assert, target }) {
// Test for <textarea> tag // Test for <textarea> tag
const elementTextarea = target.querySelector('#textarea'); const element_textarea = target.querySelector('#textarea');
// Test for <textarea> tag in non <textarea> tag // Test for <textarea> tag in non <textarea> tag
const elementDivWithTextarea = target.querySelector('#div-with-textarea'); const element_div_with_textarea = target.querySelector('#div-with-textarea');
// Test for <textarea> tag with leading newline // Test for <textarea> tag with leading newline
const elementTextareaWithLeadingNewline = target.querySelector( const element_textarea_with_leading_newline = target.querySelector(
'#textarea-with-leading-newline' '#textarea-with-leading-newline'
); );
const elementTextareaWithoutLeadingNewline = target.querySelector( const element_textarea_without_leading_newline = target.querySelector(
'#textarea-without-leading-newline' '#textarea-without-leading-newline'
); );
const elementTextareaWithMultipleLeadingNewline = target.querySelector( const element_textarea_with_multiple_leading_newline = target.querySelector(
'#textarea-with-multiple-leading-newlines' '#textarea-with-multiple-leading-newlines'
); );
const elementDivWithTextareaWithMultipleLeadingNewline = target.querySelector( const element_div_with_textarea_with_multiple_leading_newline = target.querySelector(
'#div-with-textarea-with-multiple-leading-newlines' '#div-with-textarea-with-multiple-leading-newlines'
); );
assert.equal( assert.equal(
elementTextarea.value, element_textarea.value,
` A ` A
B B
` `
); );
assert.equal( assert.equal(
elementDivWithTextarea.children[0].value, element_div_with_textarea.children[0].value,
` A ` A
B B
` `
); );
assert.equal(elementTextareaWithLeadingNewline.children[0].value, 'leading newline'); assert.equal(element_textarea_with_leading_newline.children[0].value, 'leading newline');
assert.equal( assert.equal(
elementTextareaWithLeadingNewline.children[1].value, element_textarea_with_leading_newline.children[1].value,
' leading newline and spaces' ' leading newline and spaces'
); );
assert.equal(elementTextareaWithLeadingNewline.children[2].value, '\nleading newlines'); assert.equal(element_textarea_with_leading_newline.children[2].value, '\nleading newlines');
assert.equal(elementTextareaWithoutLeadingNewline.children[0].value, 'without spaces'); assert.equal(element_textarea_without_leading_newline.children[0].value, 'without spaces');
assert.equal(elementTextareaWithoutLeadingNewline.children[1].value, ' with spaces '); assert.equal(element_textarea_without_leading_newline.children[1].value, ' with spaces ');
assert.equal( assert.equal(
elementTextareaWithoutLeadingNewline.children[2].value, element_textarea_without_leading_newline.children[2].value,
' \nnewline after leading space' ' \nnewline after leading space'
); );
assert.equal(elementTextareaWithMultipleLeadingNewline.value, '\n\nmultiple leading newlines');
assert.equal( assert.equal(
elementDivWithTextareaWithMultipleLeadingNewline.children[0].value, element_textarea_with_multiple_leading_newline.value,
'\n\nmultiple leading newlines'
);
assert.equal(
element_div_with_textarea_with_multiple_leading_newline.children[0].value,
'\n\nmultiple leading newlines' '\n\nmultiple leading newlines'
); );
} }

@ -1,9 +1,9 @@
export default { export default {
async test({ assert, target, window }) { async test({ assert, target, window }) {
const [, btn] = target.querySelectorAll('button'); const [, btn] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const click_event = new window.MouseEvent('click');
await btn.dispatchEvent(clickEvent); await btn.dispatchEvent(click_event);
assert.equal(btn.x, 1); assert.equal(btn.x, 1);
} }

@ -1,6 +1,6 @@
import { vi } from 'vitest'; import { vi } from 'vitest';
let original_scrollTo; let original_scroll_to;
export default { export default {
before_test() { before_test() {
vi.useFakeTimers(); vi.useFakeTimers();
@ -17,7 +17,7 @@ export default {
writable: true writable: true
} }
}); });
original_scrollTo = window.scrollTo; original_scroll_to = window.scrollTo;
window.scrollTo = (x, y) => { window.scrollTo = (x, y) => {
window.pageXOffset = x; window.pageXOffset = x;
window.pageYOffset = y; window.pageYOffset = y;
@ -26,7 +26,7 @@ export default {
after_test() { after_test() {
vi.useRealTimers(); vi.useRealTimers();
window.scrollTo = original_scrollTo; window.scrollTo = original_scroll_to;
}, },
async test({ assert, component, window }) { async test({ assert, component, window }) {

@ -28,17 +28,17 @@ describe('ssr', async () => {
it_fn(dir, async () => { it_fn(dir, async () => {
dir = path.resolve(`${__dirname}/samples`, dir); dir = path.resolve(`${__dirname}/samples`, dir);
const compileOptions = { const compile_options = {
...config.compileOptions, ...config.compileOptions,
generate: 'ssr' generate: 'ssr'
}; };
const load = create_loader(compileOptions, dir); const load = create_loader(compile_options, dir);
const Component = (await load(`${dir}/main.svelte`)).default; const Component = (await load(`${dir}/main.svelte`)).default;
const expectedHtml = try_read_file(`${dir}/_expected.html`); const expected_html = try_read_file(`${dir}/_expected.html`);
const expectedCss = try_read_file(`${dir}/_expected.css`) || ''; const expected_css = try_read_file(`${dir}/_expected.css`) || '';
const props = try_load_json(`${dir}/data.json`) || undefined; const props = try_load_json(`${dir}/data.json`) || undefined;
@ -49,8 +49,8 @@ describe('ssr', async () => {
if (css.code) fs.writeFileSync(`${dir}/_actual.css`, css.code); if (css.code) fs.writeFileSync(`${dir}/_actual.css`, css.code);
try { try {
assert_html_equal_with_options(html, expectedHtml, { assert_html_equal_with_options(html, expected_html, {
preserveComments: compileOptions.preserveComments, preserveComments: compile_options.preserveComments,
withoutNormalizeHtml: config.withoutNormalizeHtml withoutNormalizeHtml: config.withoutNormalizeHtml
}); });
} catch (error) { } catch (error) {
@ -66,7 +66,7 @@ describe('ssr', async () => {
try { try {
assert.equal( assert.equal(
css.code.trim().replace(/[\r\n]/g, ''), css.code.trim().replace(/[\r\n]/g, ''),
expectedCss.trim().replace(/[\r\n]/g, '') expected_css.trim().replace(/[\r\n]/g, '')
); );
} catch (error) { } catch (error) {
if (should_update_expected()) { if (should_update_expected()) {
@ -86,7 +86,7 @@ describe('ssr', async () => {
head, head,
fs.readFileSync(`${dir}/_expected-head.html`, 'utf-8'), fs.readFileSync(`${dir}/_expected-head.html`, 'utf-8'),
{ {
preserveComments: compileOptions.hydratable preserveComments: compile_options.hydratable
} }
); );
} catch (error) { } catch (error) {

@ -31,12 +31,12 @@ function run_runtime_samples(suite) {
const it_fn = config.skip ? it.skip : solo ? it.only : it; const it_fn = config.skip ? it.skip : solo ? it.only : it;
it_fn(dir, async () => { it_fn(dir, async () => {
const compileOptions = { const compile_options = {
...config.compileOptions, ...config.compileOptions,
generate: 'ssr' generate: 'ssr'
}; };
const load = create_loader(compileOptions, cwd); const load = create_loader(compile_options, cwd);
try { try {
if (config.before_test) config.before_test(); if (config.before_test) config.before_test();
@ -48,12 +48,12 @@ function run_runtime_samples(suite) {
if (config.ssrHtml) { if (config.ssrHtml) {
assert_html_equal_with_options(html, config.ssrHtml, { assert_html_equal_with_options(html, config.ssrHtml, {
preserveComments: compileOptions.preserveComments, preserveComments: compile_options.preserveComments,
withoutNormalizeHtml: config.withoutNormalizeHtml withoutNormalizeHtml: config.withoutNormalizeHtml
}); });
} else if (config.html) { } else if (config.html) {
assert_html_equal_with_options(html, config.html, { assert_html_equal_with_options(html, config.html, {
preserveComments: compileOptions.preserveComments, preserveComments: compile_options.preserveComments,
withoutNormalizeHtml: config.withoutNormalizeHtml withoutNormalizeHtml: config.withoutNormalizeHtml
}); });
} }
@ -93,7 +93,7 @@ function run_runtime_samples(suite) {
mkdirp(dir); mkdirp(dir);
const { js } = compile(fs.readFileSync(`${cwd}/${file}`, 'utf-8'), { const { js } = compile(fs.readFileSync(`${cwd}/${file}`, 'utf-8'), {
...compileOptions, ...compile_options,
filename: file filename: file
}); });

@ -10,12 +10,12 @@ export async function test({ assert, css, js }) {
assert.notEqual(match, null); assert.notEqual(match, null);
const [mimeType, encoding, cssMapBase64] = match.slice(2); const [mime_type, encoding, css_map_base64] = match.slice(2);
assert.equal(mimeType, 'application/json'); assert.equal(mime_type, 'application/json');
assert.equal(encoding, 'utf-8'); assert.equal(encoding, 'utf-8');
const cssMapJson = b64dec(cssMapBase64); const css_map_json = b64dec(css_map_base64);
css.mapConsumer = await new SourceMapConsumer(cssMapJson); css.mapConsumer = await new SourceMapConsumer(css_map_json);
// TODO make util fn + move to test index.js // TODO make util fn + move to test index.js
const sourcefile = 'input.svelte'; const sourcefile = 'input.svelte';

@ -1,8 +1,8 @@
export function test({ assert, input, js }) { export function test({ assert, input, js }) {
const startIndex = js.code.indexOf('create_main_fragment'); const start_index = js.code.indexOf('create_main_fragment');
const expected = input.locate('each'); const expected = input.locate('each');
const start = js.locate('length', startIndex); const start = js.locate('length', start_index);
const actual = js.mapConsumer.originalPositionFor({ const actual = js.mapConsumer.originalPositionFor({
line: start.line + 1, line: start.line + 1,

@ -1,6 +1,6 @@
export function test({ assert, input, js }) { export function test({ assert, input, js }) {
const expectedBar = input.locate('baritone.baz'); const expected_bar = input.locate('baritone.baz');
const expectedBaz = input.locate('.baz'); const expected_baz = input.locate('.baz');
let start = js.locate('bar.baz'); let start = js.locate('bar.baz');
@ -12,8 +12,8 @@ export function test({ assert, input, js }) {
assert.deepEqual(actualbar, { assert.deepEqual(actualbar, {
source: 'input.svelte', source: 'input.svelte',
name: 'baritone', name: 'baritone',
line: expectedBar.line + 1, line: expected_bar.line + 1,
column: expectedBar.column column: expected_bar.column
}); });
start = js.locate('.baz'); start = js.locate('.baz');
@ -26,7 +26,7 @@ export function test({ assert, input, js }) {
assert.deepEqual(actualbaz, { assert.deepEqual(actualbaz, {
source: 'input.svelte', source: 'input.svelte',
name: null, name: null,
line: expectedBaz.line + 1, line: expected_baz.line + 1,
column: expectedBaz.column column: expected_baz.column
}); });
} }

@ -1,6 +1,6 @@
export function test({ assert, input, js, css }) { export function test({ assert, input, js, css }) {
const expectedBar = input.locate('baritone'); const expected_bar = input.locate('baritone');
const expectedBaz = input.locate('--bazitone'); const expected_baz = input.locate('--bazitone');
let start = js.locate('bar'); let start = js.locate('bar');
@ -12,8 +12,8 @@ export function test({ assert, input, js, css }) {
assert.deepEqual(actualbar, { assert.deepEqual(actualbar, {
source: 'input.svelte', source: 'input.svelte',
name: 'baritone', name: 'baritone',
line: expectedBar.line + 1, line: expected_bar.line + 1,
column: expectedBar.column column: expected_bar.column
}); });
start = css.locate('--baz'); start = css.locate('--baz');
@ -26,7 +26,7 @@ export function test({ assert, input, js, css }) {
assert.deepEqual(actualbaz, { assert.deepEqual(actualbaz, {
source: 'input.svelte', source: 'input.svelte',
name: '--bazitone', name: '--bazitone',
line: expectedBaz.line + 1, line: expected_baz.line + 1,
column: expectedBaz.column column: expected_baz.column
}); });
} }

@ -1,6 +1,6 @@
export function test({ assert, input, js }) { export function test({ assert, input, js }) {
const expectedBar = input.locate('baritone:'); const expected_bar = input.locate('baritone:');
const expectedBaz = input.locate('baz:'); const expected_baz = input.locate('baz:');
let start = js.locate('bar:'); let start = js.locate('bar:');
@ -14,8 +14,8 @@ export function test({ assert, input, js }) {
{ {
source: 'input.svelte', source: 'input.svelte',
name: 'baritone', name: 'baritone',
line: expectedBar.line + 1, line: expected_bar.line + 1,
column: expectedBar.column column: expected_bar.column
}, },
"couldn't find bar: in source" "couldn't find bar: in source"
); );
@ -32,8 +32,8 @@ export function test({ assert, input, js }) {
{ {
source: 'input.svelte', source: 'input.svelte',
name: null, name: null,
line: expectedBaz.line + 1, line: expected_baz.line + 1,
column: expectedBaz.column column: expected_baz.column
}, },
"couldn't find baz: in source" "couldn't find baz: in source"
); );

@ -1,6 +1,6 @@
export function test({ assert, input, css }) { export function test({ assert, input, css }) {
const expectedBar = input.locate('--baritone'); const expected_bar = input.locate('--baritone');
const expectedBaz = input.locate('--baz'); const expected_baz = input.locate('--baz');
let start = css.locate('--bar'); let start = css.locate('--bar');
@ -14,8 +14,8 @@ export function test({ assert, input, css }) {
{ {
source: 'input.svelte', source: 'input.svelte',
name: null, name: null,
line: expectedBar.line + 1, line: expected_bar.line + 1,
column: expectedBar.column column: expected_bar.column
}, },
"couldn't find bar in source" "couldn't find bar in source"
); );
@ -32,8 +32,8 @@ export function test({ assert, input, css }) {
{ {
source: 'input.svelte', source: 'input.svelte',
name: null, name: null,
line: expectedBaz.line + 1, line: expected_baz.line + 1,
column: expectedBaz.column column: expected_baz.column
}, },
"couldn't find baz in source" "couldn't find baz in source"
); );

@ -10,15 +10,15 @@ export function test({ assert, preprocessed, js, css }) {
function test_name(old_name, new_name, where) { function test_name(old_name, new_name, where) {
let loc = { character: -1 }; let loc = { character: -1 };
while ((loc = where.locate(new_name, loc.character + 1))) { while ((loc = where.locate(new_name, loc.character + 1))) {
const actualMapping = where.mapConsumer.originalPositionFor({ const actual_mapping = where.mapConsumer.originalPositionFor({
line: loc.line + 1, line: loc.line + 1,
column: loc.column column: loc.column
}); });
if (actualMapping.line === null) { if (actual_mapping.line === null) {
// location is not mapped - ignore // location is not mapped - ignore
continue; continue;
} }
assert.equal(actualMapping.name, old_name); assert.equal(actual_mapping.name, old_name);
} }
if (loc === undefined) { if (loc === undefined) {
// workaround for bug in locate-character, TODO remove // workaround for bug in locate-character, TODO remove

@ -25,15 +25,15 @@ describe('sourcemaps', async () => {
it_fn(dir, async () => { it_fn(dir, async () => {
const { test } = await import(`./samples/${dir}/test.js`); const { test } = await import(`./samples/${dir}/test.js`);
const inputFile = path.resolve(`${__dirname}/samples/${dir}/input.svelte`); const input_file = path.resolve(`${__dirname}/samples/${dir}/input.svelte`);
const outputName = '_actual'; const output_name = '_actual';
const outputBase = path.resolve(`${__dirname}/samples/${dir}/${outputName}`); const output_base = path.resolve(`${__dirname}/samples/${dir}/${output_name}`);
const inputCode = fs.readFileSync(inputFile, 'utf-8'); const input_code = fs.readFileSync(input_file, 'utf-8');
const input = { const input = {
code: inputCode, code: input_code,
locate: getLocator(inputCode), locate: getLocator(input_code),
locate_1: getLocator(inputCode, { offsetLine: 1 }) locate_1: getLocator(input_code, { offsetLine: 1 })
}; };
const preprocessed = await svelte.preprocess( const preprocessed = await svelte.preprocess(
input.code, input.code,
@ -46,8 +46,8 @@ describe('sourcemaps', async () => {
filename: 'input.svelte', filename: 'input.svelte',
// filenames for sourcemaps // filenames for sourcemaps
sourcemap: preprocessed.map, sourcemap: preprocessed.map,
outputFilename: `${outputName}.js`, outputFilename: `${output_name}.js`,
cssOutputFilename: `${outputName}.css`, cssOutputFilename: `${output_name}.css`,
...(config.compile_options || {}) ...(config.compile_options || {})
}); });
@ -55,22 +55,25 @@ describe('sourcemaps', async () => {
match.replace(/\d/g, 'x') match.replace(/\d/g, 'x')
); );
fs.writeFileSync(`${outputBase}.svelte`, preprocessed.code); fs.writeFileSync(`${output_base}.svelte`, preprocessed.code);
if (preprocessed.map) { if (preprocessed.map) {
fs.writeFileSync( fs.writeFileSync(
`${outputBase}.svelte.map`, `${output_base}.svelte.map`,
// TODO encode mappings for output - svelte.preprocess returns decoded mappings // TODO encode mappings for output - svelte.preprocess returns decoded mappings
JSON.stringify(preprocessed.map, null, 2) JSON.stringify(preprocessed.map, null, 2)
); );
} }
fs.writeFileSync(`${outputBase}.js`, `${js.code}\n//# sourceMappingURL=${outputName}.js.map`); fs.writeFileSync(
fs.writeFileSync(`${outputBase}.js.map`, JSON.stringify(js.map, null, 2)); `${output_base}.js`,
`${js.code}\n//# sourceMappingURL=${output_name}.js.map`
);
fs.writeFileSync(`${output_base}.js.map`, JSON.stringify(js.map, null, 2));
if (css.code) { if (css.code) {
fs.writeFileSync( fs.writeFileSync(
`${outputBase}.css`, `${output_base}.css`,
`${css.code}\n/*# sourceMappingURL=${outputName}.css.map */` `${css.code}\n/*# sourceMappingURL=${output_name}.css.map */`
); );
fs.writeFileSync(`${outputBase}.css.map`, JSON.stringify(css.map, null, ' ')); fs.writeFileSync(`${output_base}.css.map`, JSON.stringify(css.map, null, ' '));
} }
if (js.map) { if (js.map) {

@ -17,7 +17,7 @@ describe('stats', () => {
const filename = `${__dirname}/samples/${dir}/input.svelte`; const filename = `${__dirname}/samples/${dir}/input.svelte`;
const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, ''); const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, '');
const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`);
let result; let result;
let error; let error;
@ -29,19 +29,19 @@ describe('stats', () => {
error = e; error = e;
} }
if (error || expectedError) { if (error || expected_error) {
if (error && !expectedError) { if (error && !expected_error) {
throw error; throw error;
} }
if (expectedError && !error) { if (expected_error && !error) {
throw new Error(`Expected an error: ${expectedError.message}`); throw new Error(`Expected an error: ${expected_error.message}`);
} }
assert.equal(error.message, expectedError.message); assert.equal(error.message, expected_error.message);
assert.deepEqual(error.start, expectedError.start); assert.deepEqual(error.start, expected_error.start);
assert.deepEqual(error.end, expectedError.end); assert.deepEqual(error.end, expected_error.end);
assert.equal(error.pos, expectedError.pos); assert.equal(error.pos, expected_error.pos);
} }
}); });
}); });

@ -293,7 +293,7 @@ describe('store', () => {
it('passes optional set and update functions', () => { it('passes optional set and update functions', () => {
const number = writable(1); const number = writable(1);
const evensAndSquaresOf4 = derived( const evens_and_squares_of4 = derived(
number, number,
(n, set, update) => { (n, set, update) => {
if (n % 2 === 0) set(n); if (n % 2 === 0) set(n);
@ -304,7 +304,7 @@ describe('store', () => {
const values = []; const values = [];
const unsubscribe = evensAndSquaresOf4.subscribe((value) => { const unsubscribe = evens_and_squares_of4.subscribe((value) => {
values.push(value); values.push(value);
}); });
@ -542,18 +542,18 @@ describe('store', () => {
describe('readonly', () => { describe('readonly', () => {
it('makes a store readonly', () => { it('makes a store readonly', () => {
const writableStore = writable(1); const writable_store = writable(1);
const readableStore = readonly(writableStore); const readable_store = readonly(writable_store);
assert.equal(get(readableStore), get(writableStore)); assert.equal(get(readable_store), get(writable_store));
writableStore.set(2); writable_store.set(2);
assert.equal(get(readableStore), 2); assert.equal(get(readable_store), 2);
assert.equal(get(readableStore), get(writableStore)); assert.equal(get(readable_store), get(writable_store));
// @ts-ignore // @ts-ignore
assert.throws(() => readableStore.set(3)); assert.throws(() => readable_store.set(3));
}); });
}); });
}); });

@ -1,15 +1,10 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"include": ["."],
"exclude": ["./**/_output/**/*"], "exclude": ["./**/_output/**/*"],
"compilerOptions": { "compilerOptions": {
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
"noEmit": true, "noEmit": true
"paths": {
"svelte": [".."],
"svelte/*": ["../*"]
}
} }
} }

@ -20,7 +20,7 @@ describe('vars', () => {
.trimEnd() .trimEnd()
.replace(/\r/g, ''); .replace(/\r/g, '');
const expectedError = try_load_json(`${__dirname}/samples/${dir}/error.json`); const expected_error = try_load_json(`${__dirname}/samples/${dir}/error.json`);
/** /**
* @type {{ options: any, test: (assert: typeof import('vitest').assert, vars: any[]) => void }}} * @type {{ options: any, test: (assert: typeof import('vitest').assert, vars: any[]) => void }}}
@ -31,19 +31,19 @@ describe('vars', () => {
const { vars } = compile(input, { ...options, generate }); const { vars } = compile(input, { ...options, generate });
test(assert, vars); test(assert, vars);
} catch (error) { } catch (error) {
if (expectedError) { if (expected_error) {
assert.equal(error.message, expectedError.message); assert.equal(error.message, expected_error.message);
assert.deepEqual(error.start, expectedError.start); assert.deepEqual(error.start, expected_error.start);
assert.deepEqual(error.end, expectedError.end); assert.deepEqual(error.end, expected_error.end);
assert.equal(error.pos, expectedError.pos); assert.equal(error.pos, expected_error.pos);
return; return;
} else { } else {
throw error; throw error;
} }
} }
if (expectedError) { if (expected_error) {
assert.fail(`Expected an error: ${JSON.stringify(expectedError)}`); assert.fail(`Expected an error: ${JSON.stringify(expected_error)}`);
} }
}); });
}); });

@ -111,6 +111,9 @@ importers:
esbuild: esbuild:
specifier: ^0.18.11 specifier: ^0.18.11
version: 0.18.11 version: 0.18.11
eslint-plugin-lube:
specifier: ^0.1.7
version: 0.1.7
happy-dom: happy-dom:
specifier: ^9.20.3 specifier: ^9.20.3
version: 9.20.3 version: 9.20.3
@ -3932,6 +3935,12 @@ packages:
eslint: 8.47.0 eslint: 8.47.0
dev: true dev: true
/eslint-plugin-lube@0.1.7:
resolution: {integrity: sha512-jqeRZAG3vQWZR6Hue2tSx4bQUfpDYqeSOFf3MlqpUycb5q6av1bhnmfDkxHgsLQoK4Pt7H+puI0cYc/iEvFwfw==}
dependencies:
'@types/estree': 1.0.1
dev: true
/eslint-plugin-svelte@2.32.2(eslint@8.44.0)(svelte@packages+svelte): /eslint-plugin-svelte@2.32.2(eslint@8.44.0)(svelte@packages+svelte):
resolution: {integrity: sha512-Jgbop2fNZsoxxkklZAIbDNhwAPynvnCtUXLsEC6O2qax7N/pfe2cNqT0ZoBbubXKJitQQDEyVDQ1rZs4ZWcrTA==} resolution: {integrity: sha512-Jgbop2fNZsoxxkklZAIbDNhwAPynvnCtUXLsEC6O2qax7N/pfe2cNqT0ZoBbubXKJitQQDEyVDQ1rZs4ZWcrTA==}
engines: {node: ^14.17.0 || >=16.0.0} engines: {node: ^14.17.0 || >=16.0.0}

Loading…
Cancel
Save