Merge pull request #565 from sveltejs/coverage

[WIP] increase test coverage
pull/566/head
Rich Harris 7 years ago committed by GitHub
commit cedd318945

@ -1,5 +1,5 @@
--require babel-register
--require reify
--recursive
--recursive
./**/__test__.js
test/*/index.js

@ -80,10 +80,12 @@
},
"nyc": {
"include": [
"src/**/*.js"
"src/**/*.js",
"shared.js"
],
"exclude": [
"src/**/__test__.js"
"src/**/__test__.js",
"src/shared/**"
]
},
"babel": {

@ -183,7 +183,8 @@ export default function dom ( parsed, source, options ) {
};
${name}.prototype.teardown = ${name}.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );${templateProperties.ondestroy ? `\n${generator.alias( 'template' )}.ondestroy.call( this );` : ``}
this.fire( 'destroy' );
${templateProperties.ondestroy && `${generator.alias( 'template' )}.ondestroy.call( this );`}
this._fragment.destroy( detach !== false );
this._fragment = null;

@ -60,11 +60,6 @@ export default function visitWindow ( generator, block, node ) {
}
if ( attribute.type === 'Binding' ) {
if ( attribute.value.type !== 'Identifier' ) {
const { parts, keypath } = flattenReference( attribute.value );
throw new Error( `Bindings on <:Window/> must be to top-level properties, e.g. '${parts.pop()}' rather than '${keypath}'` );
}
// in dev mode, throw if read-only values are written to
if ( readonly.has( attribute.name ) ) {
generator.readonly.add( attribute.value.name );

@ -215,6 +215,7 @@ function compoundWithOutros ( generator, block, state, node, branches, dynamic,
const if_current_block_index = hasElse ? '' : `if ( ~${current_block_index} ) `;
block.addVariable( current_block_index );
block.addVariable( name );
block.builders.create.addBlock( deindent`
var ${if_block_creators} = [
@ -233,12 +234,12 @@ function compoundWithOutros ( generator, block, state, node, branches, dynamic,
if ( hasElse ) {
block.builders.create.addBlock( deindent`
${current_block_index} = ${get_block}( ${params} );
${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
${name} = ${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
` );
} else {
block.builders.create.addBlock( deindent`
if ( ~( ${current_block_index} = ${get_block}( ${params} ) ) ) {
${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
${name} = ${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
}
` );
}
@ -253,37 +254,35 @@ function compoundWithOutros ( generator, block, state, node, branches, dynamic,
const parentNode = state.parentNode || `${anchor}.parentNode`;
const changeBlock = deindent`
var ${name} = ${if_blocks}[ ${previous_block_index} ];
if ( ${name} ) {
${name}.outro( function () {
${if_blocks}[ ${previous_block_index} ].destroy( true );
${if_blocks}[ ${previous_block_index} ] = null;
});
}
const destroyOldBlock = deindent`
${name}.outro( function () {
${if_blocks}[ ${previous_block_index} ].destroy( true );
${if_blocks}[ ${previous_block_index} ] = null;
});
`;
if ( hasElse ) {
block.builders.create.addBlock( deindent`
${name} = ${if_blocks}[ ${current_block_index} ];
if ( !${name} ) {
${name} = ${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
const createNewBlock = deindent`
${name} = ${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
${name}.${mountOrIntro}( ${parentNode}, ${anchor} );
`;
const changeBlock = hasElse ?
deindent`
${destroyOldBlock}
${createNewBlock}
` :
deindent`
if ( ${name} ) {
${destroyOldBlock}
}
${name}.${mountOrIntro}( ${parentNode}, ${anchor} );
` );
} else {
block.builders.create.addBlock( deindent`
if ( ~${current_block_index} ) {
${name} = ${if_blocks}[ ${current_block_index} ];
if ( !${name} ) {
${name} = ${if_blocks}[ ${current_block_index} ] = ${if_block_creators}[ ${current_block_index} ]( ${params}, ${block.component} );
}
${name}.${mountOrIntro}( ${parentNode}, ${anchor} );
${createNewBlock}
} else {
${name} = null;
}
` );
}
`;
if ( dynamic ) {
block.builders.update.addBlock( deindent`

@ -56,19 +56,16 @@ export function create ( source, _options = {} ) {
return;
}
let result;
try {
result = (new Function( 'return ' + compiled.code ))();
return (new Function( 'return ' + compiled.code ))();
} catch ( err ) {
if ( _options.onerror ) {
_options.onerror( err );
return;
} else {
throw err;
}
return;
}
return result;
}
export { parse, validate, version as VERSION };

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
// borrowed from Ractive https://github.com/ractivejs/ractive/blob/faf93cbd33c3fedfd8d6dd48340990540bde4a94/src/utils/html.js
const htmlEntities = { quot: 34, amp: 38, apos: 39, lt: 60, gt: 62, nbsp: 160, iexcl: 161, cent: 162, pound: 163, curren: 164, yen: 165, brvbar: 166, sect: 167, uml: 168, copy: 169, ordf: 170, laquo: 171, not: 172, shy: 173, reg: 174, macr: 175, deg: 176, plusmn: 177, sup2: 178, sup3: 179, acute: 180, micro: 181, para: 182, middot: 183, cedil: 184, sup1: 185, ordm: 186, raquo: 187, frac14: 188, frac12: 189, frac34: 190, iquest: 191, Agrave: 192, Aacute: 193, Acirc: 194, Atilde: 195, Auml: 196, Aring: 197, AElig: 198, Ccedil: 199, Egrave: 200, Eacute: 201, Ecirc: 202, Euml: 203, Igrave: 204, Iacute: 205, Icirc: 206, Iuml: 207, ETH: 208, Ntilde: 209, Ograve: 210, Oacute: 211, Ocirc: 212, Otilde: 213, Ouml: 214, times: 215, Oslash: 216, Ugrave: 217, Uacute: 218, Ucirc: 219, Uuml: 220, Yacute: 221, THORN: 222, szlig: 223, agrave: 224, aacute: 225, acirc: 226, atilde: 227, auml: 228, aring: 229, aelig: 230, ccedil: 231, egrave: 232, eacute: 233, ecirc: 234, euml: 235, igrave: 236, iacute: 237, icirc: 238, iuml: 239, eth: 240, ntilde: 241, ograve: 242, oacute: 243, ocirc: 244, otilde: 245, ouml: 246, divide: 247, oslash: 248, ugrave: 249, uacute: 250, ucirc: 251, uuml: 252, yacute: 253, thorn: 254, yuml: 255, OElig: 338, oelig: 339, Scaron: 352, scaron: 353, Yuml: 376, fnof: 402, circ: 710, tilde: 732, Alpha: 913, Beta: 914, Gamma: 915, Delta: 916, Epsilon: 917, Zeta: 918, Eta: 919, Theta: 920, Iota: 921, Kappa: 922, Lambda: 923, Mu: 924, Nu: 925, Xi: 926, Omicron: 927, Pi: 928, Rho: 929, Sigma: 931, Tau: 932, Upsilon: 933, Phi: 934, Chi: 935, Psi: 936, Omega: 937, alpha: 945, beta: 946, gamma: 947, delta: 948, epsilon: 949, zeta: 950, eta: 951, theta: 952, iota: 953, kappa: 954, lambda: 955, mu: 956, nu: 957, xi: 958, omicron: 959, pi: 960, rho: 961, sigmaf: 962, sigma: 963, tau: 964, upsilon: 965, phi: 966, chi: 967, psi: 968, omega: 969, thetasym: 977, upsih: 978, piv: 982, ensp: 8194, emsp: 8195, thinsp: 8201, zwnj: 8204, zwj: 8205, lrm: 8206, rlm: 8207, ndash: 8211, mdash: 8212, lsquo: 8216, rsquo: 8217, sbquo: 8218, ldquo: 8220, rdquo: 8221, bdquo: 8222, dagger: 8224, Dagger: 8225, bull: 8226, hellip: 8230, permil: 8240, prime: 8242, Prime: 8243, lsaquo: 8249, rsaquo: 8250, oline: 8254, frasl: 8260, euro: 8364, image: 8465, weierp: 8472, real: 8476, trade: 8482, alefsym: 8501, larr: 8592, uarr: 8593, rarr: 8594, darr: 8595, harr: 8596, crarr: 8629, lArr: 8656, uArr: 8657, rArr: 8658, dArr: 8659, hArr: 8660, forall: 8704, part: 8706, exist: 8707, empty: 8709, nabla: 8711, isin: 8712, notin: 8713, ni: 8715, prod: 8719, sum: 8721, minus: 8722, lowast: 8727, radic: 8730, prop: 8733, infin: 8734, ang: 8736, and: 8743, or: 8744, cap: 8745, cup: 8746, int: 8747, there4: 8756, sim: 8764, cong: 8773, asymp: 8776, ne: 8800, equiv: 8801, le: 8804, ge: 8805, sub: 8834, sup: 8835, nsub: 8836, sube: 8838, supe: 8839, oplus: 8853, otimes: 8855, perp: 8869, sdot: 8901, lceil: 8968, rceil: 8969, lfloor: 8970, rfloor: 8971, lang: 9001, rang: 9002, loz: 9674, spades: 9824, clubs: 9827, hearts: 9829, diams: 9830 };
const controlCharacters = [ 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376 ];
const entityPattern = new RegExp( '&(#?(?:x[\\w\\d]+|\\d+|' + Object.keys( htmlEntities ).join( '|' ) + '));?', 'g' );
import htmlEntities from './entities.js';
const windows1252 = [ 8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376 ];
const entityPattern = new RegExp( `&(#?(?:x[\\w\\d]+|\\d+|${Object.keys( htmlEntities ).join( '|' )}));?`, 'g' );
export function decodeCharacterReferences ( html ) {
return html.replace( entityPattern, ( match, entity ) => {
@ -23,7 +23,8 @@ export function decodeCharacterReferences ( html ) {
return String.fromCodePoint( validateCode( code ) );
});
}
const invalid = 65533;
const NUL = 0;
// some code points are verboten. If we were inserting HTML, the browser would replace the illegal
// code points with alternatives in some cases - since we're bypassing that mechanism, we need
@ -31,10 +32,6 @@ const invalid = 65533;
//
// Source: http://en.wikipedia.org/wiki/Character_encodings_in_HTML#Illegal_characters
function validateCode ( code ) {
if ( !code ) {
return invalid;
}
// line feed becomes generic whitespace
if ( code === 10 ) {
return 32;
@ -48,7 +45,7 @@ function validateCode ( code ) {
// code points 128-159 are dealt with leniently by browsers, but they're incorrect. We need
// to correct the mistake or we'll end up with missing € signs and so on
if ( code <= 159 ) {
return controlCharacters[ code - 128 ];
return windows1252[ code - 128 ];
}
// basic multilingual plane
@ -58,7 +55,7 @@ function validateCode ( code ) {
// UTF-16 surrogate halves
if ( code <= 57343 ) {
return invalid;
return NUL;
}
// rest of the basic multilingual plane
@ -76,5 +73,5 @@ function validateCode ( code ) {
return code;
}
return invalid;
return NUL;
}

@ -1,10 +1,4 @@
import flattenReference from '../../utils/flattenReference.js';
const validBuiltins = new Set([
'set',
'fire',
'destroy'
]);
import validateEventHandler from './validateEventHandler.js';
export default function validateElement ( validator, node ) {
const isComponent = node.name === ':Self' || validator.components.has( node.name );
@ -53,30 +47,7 @@ export default function validateElement ( validator, node ) {
}
if ( attribute.type === 'EventHandler' ) {
const { callee, start, type } = attribute.expression;
if ( type !== 'CallExpression' ) {
validator.error( `Expected a call expression`, start );
}
const { name } = flattenReference( callee );
if ( name === 'this' || name === 'event' ) return;
if ( callee.type === 'Identifier' && validBuiltins.has( callee.name ) || validator.methods.has( callee.name ) ) return;
const validCallees = [ 'this.*', 'event.*' ]
.concat(
Array.from( validBuiltins ),
Array.from( validator.methods.keys() )
);
let message = `'${validator.source.slice( callee.start, callee.end )}' is an invalid callee (should be one of ${list( validCallees )})`;
if ( callee.type === 'Identifier' && validator.helpers.has( callee.name ) ) {
message += `. '${callee.name}' exists on 'helpers', did you put it in the wrong place?`;
}
validator.error( message, start );
validateEventHandler( validator, attribute );
}
});
}
@ -95,8 +66,3 @@ function getType ( validator, node ) {
return attribute.value[0].data;
}
function list ( items, conjunction = 'or' ) {
if ( items.length === 1 ) return items[0];
return `${items.slice( 0, -1 ).join( ', ' )} ${conjunction} ${items[ items.length - 1 ]}`;
}

@ -0,0 +1,35 @@
import flattenReference from '../../utils/flattenReference.js';
import list from '../utils/list.js';
const validBuiltins = new Set([
'set',
'fire',
'destroy'
]);
export default function validateEventHandlerCallee ( validator, attribute ) {
const { callee, start, type } = attribute.expression;
if ( type !== 'CallExpression' ) {
validator.error( `Expected a call expression`, start );
}
const { name } = flattenReference( callee );
if ( name === 'this' || name === 'event' ) return;
if ( callee.type === 'Identifier' && validBuiltins.has( callee.name ) || validator.methods.has( callee.name ) ) return;
const validCallees = [ 'this.*', 'event.*' ]
.concat(
Array.from( validBuiltins ),
Array.from( validator.methods.keys() )
);
let message = `'${validator.source.slice( callee.start, callee.end )}' is an invalid callee (should be one of ${list( validCallees )})`;
if ( callee.type === 'Identifier' && validator.helpers.has( callee.name ) ) {
message += `. '${callee.name}' exists on 'helpers', did you put it in the wrong place?`;
}
validator.error( message, start );
}

@ -1,3 +1,48 @@
export default function validateWindow () {
// TODO
import flattenReference from '../../utils/flattenReference.js';
import fuzzymatch from '../utils/fuzzymatch.js';
import list from '../utils/list.js';
import validateEventHandler from './validateEventHandler.js';
const validBindings = [
'innerWidth',
'innerHeight',
'outerWidth',
'outerHeight',
'scrollX',
'scrollY'
];
export default function validateWindow ( validator, node ) {
node.attributes.forEach( attribute => {
if ( attribute.type === 'Binding' ) {
if ( attribute.value.type !== 'Identifier' ) {
const { parts } = flattenReference( attribute.value );
validator.error(
`Bindings on <:Window/> must be to top-level properties, e.g. '${parts[ parts.length - 1 ]}' rather than '${parts.join( '.' )}'`,
attribute.value.start
);
}
if ( !~validBindings.indexOf( attribute.name ) ) {
const match = (
attribute.name === 'width' ? 'innerWidth' :
attribute.name === 'height' ? 'innerHeight' :
fuzzymatch( attribute.name, validBindings )
);
const message = `'${attribute.name}' is not a valid binding on <:Window>`;
if ( match ) {
validator.error( `${message} (did you mean '${match}'?)`, attribute.start );
} else {
validator.error( `${message} — valid bindings are ${list( validBindings )}`, attribute.start );
}
}
}
else if ( attribute.type === 'EventHandler' ) {
validateEventHandler( validator, attribute );
}
});
}

@ -1,13 +1,11 @@
import propValidators from './propValidators/index.js';
import FuzzySet from './utils/FuzzySet.js';
import fuzzymatch from '../utils/fuzzymatch.js';
import checkForDupes from './utils/checkForDupes.js';
import checkForComputedKeys from './utils/checkForComputedKeys.js';
import namespaces from '../../utils/namespaces.js';
const validPropList = Object.keys( propValidators );
const fuzzySet = new FuzzySet( validPropList );
export default function validateJs ( validator, js ) {
js.content.body.forEach( node => {
// check there are no named exports
@ -45,9 +43,9 @@ export default function validateJs ( validator, js ) {
if ( propValidator ) {
propValidator( validator, prop );
} else {
const matches = fuzzySet.get( prop.key.name );
if ( matches && matches[0] && matches[0][0] > 0.7 ) {
validator.error( `Unexpected property '${prop.key.name}' (did you mean '${matches[0][1]}'?)`, prop.start );
const match = fuzzymatch( prop.key.name, validPropList );
if ( match ) {
validator.error( `Unexpected property '${prop.key.name}' (did you mean '${match}'?)`, prop.start );
} else if ( /FunctionExpression/.test( prop.value.type ) ) {
validator.error( `Unexpected property '${prop.key.name}' (did you mean to include it in 'methods'?)`, prop.start );
} else {

@ -1,7 +1,6 @@
import * as namespaces from '../../../utils/namespaces.js';
import FuzzySet from '../utils/FuzzySet.js';
import fuzzymatch from '../../utils/fuzzymatch.js';
const fuzzySet = new FuzzySet( namespaces.validNamespaces );
const valid = new Set( namespaces.validNamespaces );
export default function namespace ( validator, prop ) {
@ -12,9 +11,9 @@ export default function namespace ( validator, prop ) {
}
if ( !valid.has( ns ) ) {
const matches = fuzzySet.get( ns );
if ( matches && matches[0] && matches[0][0] > 0.7 ) {
validator.error( `Invalid namespace '${ns}' (did you mean '${matches[0][1]}'?)`, prop.start );
const match = fuzzymatch( ns, namespaces.validNamespaces );
if ( match ) {
validator.error( `Invalid namespace '${ns}' (did you mean '${match}'?)`, prop.start );
} else {
validator.error( `Invalid namespace '${ns}'`, prop.start );
}

@ -0,0 +1,10 @@
import FuzzySet from './FuzzySet.js';
export default function fuzzymatch ( name, names ) {
const set = new FuzzySet( names );
const matches = set.get( name );
return matches && matches[0] && matches[0][0] > 0.7 ?
matches[0][1] :
null;
}

@ -0,0 +1,4 @@
export default function list ( items, conjunction = 'or' ) {
if ( items.length === 1 ) return items[0];
return `${items.slice( 0, -1 ).join( ', ' )} ${conjunction} ${items[ items.length - 1 ]}`;
}

@ -6,7 +6,8 @@ describe( 'css', () => {
fs.readdirSync( 'test/css/samples' ).forEach( dir => {
if ( dir[0] === '.' ) return;
const solo = exists( `test/css/samples/${dir}/solo` );
// add .solo to a sample directory name to only run that test
const solo = /\.solo/.test( dir );
if ( solo && process.env.CI ) {
throw new Error( 'Forgot to remove `solo: true` from test' );

@ -0,0 +1,9 @@
@keyframes svelte-4112859982-why {
0% { color: red; }
100% { color: blue; }
}
[svelte-4112859982].animated, [svelte-4112859982] .animated {
animation: svelte-4112859982-why 2s;
}

@ -0,0 +1,12 @@
<div class='animated'>animated</div>
<style>
@keyframes why {
0% { color: red; }
100% { color: blue; }
}
.animated {
animation: why 2s;
}
</style>

@ -0,0 +1,6 @@
@media (min-width: 400px) {
[svelte-2352010302].large-screen, [svelte-2352010302] .large-screen {
display: block;
}
}

@ -0,0 +1,9 @@
<div class='large-screen'>animated</div>
<style>
@media (min-width: 400px) {
.large-screen {
display: block;
}
}
</style>

@ -0,0 +1,86 @@
import Imported from './Imported.html';
import { assign, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js";
var template = (function () {
return {
components: {
NonImported
}
};
}());
function create_main_fragment ( state, component ) {
var imported = new Imported({
target: null,
_root: component._root
});
var text = createText( "\n" );
var nonimported = new template.components.NonImported({
target: null,
_root: component._root
});
return {
mount: function ( target, anchor ) {
imported._fragment.mount( target, anchor );
insertNode( text, target, anchor );
nonimported._fragment.mount( target, anchor );
},
destroy: function ( detach ) {
imported.destroy( detach );
nonimported.destroy( detach );
if ( detach ) {
detachNode( text );
}
}
};
}
function SvelteComponent ( options ) {
options = options || {};
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._torndown = false;
this._renderHooks = [];
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) this._fragment.mount( options.target, null );
this._flush();
}
assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState );
this._flush();
};
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
this._fragment.destroy( detach !== false );
this._fragment = null;
this._state = {};
this._torndown = true;
};
export default SvelteComponent;

@ -0,0 +1,13 @@
<Imported/>
<NonImported/>
<script>
import Imported from './Imported.html';
export default {
components: {
Imported,
NonImported
}
};
</script>

@ -0,0 +1,67 @@
import { assign, dispatchObservers, noop, proto } from "svelte/shared.js";
var template = (function () {
return {
// this test should be removed in v2
oncreate () {},
ondestroy () {}
};
}());
function create_main_fragment ( state, component ) {
return {
mount: noop,
destroy: noop
};
}
function SvelteComponent ( options ) {
options = options || {};
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._torndown = false;
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) this._fragment.mount( options.target, null );
if ( options._root ) {
options._root._renderHooks.push( template.oncreate.bind( this ) );
} else {
template.oncreate.call( this );
}
}
assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) {
var oldState = this._state;
this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState );
};
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {
this.fire( 'destroy' );
template.ondestroy.call( this );
this._fragment.destroy( detach !== false );
this._fragment = null;
this._state = {};
this._torndown = true;
};
export default SvelteComponent;

@ -0,0 +1,7 @@
<script>
export default {
// this test should be removed in v2
onrender () {},
onteardown () {}
};
</script>

@ -0,0 +1,14 @@
export default {
html: `
<span>*</span>
<span>*</span>
<span>*</span>
<span>*</span>
<span></span>
<span>A</span>
<span></span>
<span>&notanentity;</span>
`
};

@ -0,0 +1,10 @@
<span>&ast;</span>
<span>&midast;</span>
<span>&#x0002A;</span>
<span>&#42;</span>
<span>&#10;</span>
<span>&#65;</span>
<span>&#128;</span>
<span>&notanentity;</span>

@ -0,0 +1,22 @@
export default {
data: {
z: 'z'
},
test ( assert, component, target, window, raf ) {
assert.equal( target.querySelector( 'div' ), component.refs.no );
component.set({ x: true });
raf.tick( 25 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.75 );
raf.tick( 75 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.25 );
raf.tick( 100 );
component.destroy();
}
};

@ -0,0 +1,20 @@
{{#if x}}
<div ref:yes out:foo>{{z}}</div>
{{else}}
<div ref:no out:foo>{{z}}</div>
{{/if}}
<script>
export default {
transitions: {
foo: function ( node, params ) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>

@ -0,0 +1,18 @@
export default {
test ( assert, component, target, window, raf ) {
assert.equal( target.querySelector( 'div' ), component.refs.no );
component.set({ x: true });
raf.tick( 25 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.75 );
raf.tick( 75 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.25 );
raf.tick( 100 );
component.destroy();
}
};

@ -0,0 +1,20 @@
{{#if x}}
<div ref:yes out:foo>yes</div>
{{else}}
<div ref:no out:foo>no</div>
{{/if}}
<script>
export default {
transitions: {
foo: function ( node, params ) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>

@ -0,0 +1,23 @@
export default {
data: {
x: false,
y: true
},
test ( assert, component, target, window, raf ) {
assert.equal( target.querySelector( 'div' ), component.refs.no );
component.set({ x: true, y: false });
raf.tick( 25 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.75 );
raf.tick( 75 );
assert.equal( component.refs.yes.foo, undefined );
assert.equal( component.refs.no.foo, 0.25 );
raf.tick( 100 );
component.destroy();
}
};

@ -0,0 +1,20 @@
{{#if x}}
<div ref:yes out:foo>yes</div>
{{elseif y}}
<div ref:no out:foo>no</div>
{{/if}}
<script>
export default {
transitions: {
foo: function ( node, params ) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>

@ -0,0 +1,8 @@
[{
"message": "'innerwidth' is not a valid binding on <:Window> (did you mean 'innerWidth'?)",
"loc": {
"line": 1,
"column": 9
},
"pos": 9
}]

@ -0,0 +1,8 @@
[{
"message": "Bindings on <:Window/> must be to top-level properties, e.g. 'baz' rather than 'foo.bar.baz'",
"loc": {
"line": 1,
"column": 26
},
"pos": 26
}]

@ -0,0 +1 @@
<:Window bind:innerWidth='foo.bar.baz'/>

@ -0,0 +1,8 @@
[{
"message": "'width' is not a valid binding on <:Window> (did you mean 'innerWidth'?)",
"loc": {
"line": 1,
"column": 9
},
"pos": 9
}]

@ -0,0 +1,8 @@
[{
"message": "'potato' is not a valid binding on <:Window> — valid bindings are innerWidth, innerHeight, outerWidth, outerHeight, scrollX or scrollY",
"loc": {
"line": 1,
"column": 9
},
"pos": 9
}]

@ -0,0 +1,8 @@
[{
"message": "'resize' is an invalid callee (should be one of this.*, event.*, set, fire or destroy)",
"loc": {
"line": 1,
"column": 20
},
"pos": 20
}]
Loading…
Cancel
Save