You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/each-block-random-permute/_config.js

34 lines
711 B

const VALUES = Array.from( 'abcdefghijklmnopqrstuvwxyz' );
function permute () {
const values = VALUES.slice();
const number = Math.floor(Math.random() * VALUES.length);
const permuted = [];
for (let i = 0; i < number; i++) {
permuted.push( ...values.splice( Math.floor( Math.random() * ( number - i ) ), 1 ) );
}
return {
data: permuted,
expected: permuted.length ? `(${permuted.join(')(')})` : ''
};
}
let step = permute();
export default {
props: {
values: step.data
},
html: step.expected,
test({ assert, component, target }) {
for (let i = 0; i < 100; i++) {
step = permute();
component.values = step.data;
assert.htmlEqual( target.innerHTML, step.expected );
}
}
};