added test that fails on master

pull/4309/head
Avi Marcus 6 years ago
parent abd55510be
commit bd42d64da4

@ -48,7 +48,7 @@ describe('hydration', () => {
throw new Error('Forgot to remove `solo: true` from test'); throw new Error('Forgot to remove `solo: true` from test');
} }
(config.skip ? it.skip : solo ? it.only : it)(dir, () => { (config.skip ? it.skip : solo ? it.only : it)(dir, async () => {
const cwd = path.resolve(`${__dirname}/samples/${dir}`); const cwd = path.resolve(`${__dirname}/samples/${dir}`);
compileOptions = config.compileOptions || {}; compileOptions = config.compileOptions || {};
@ -110,7 +110,7 @@ describe('hydration', () => {
} }
if (config.test) { if (config.test) {
config.test(assert, target, snapshot, component, window); await config.test(assert, target, snapshot, component, window);
} else { } else {
component.$destroy(); component.$destroy();
assert.equal(target.innerHTML, ''); assert.equal(target.innerHTML, '');

@ -0,0 +1,3 @@
<div>
<iframe title="test"></iframe>
</div>

@ -0,0 +1,3 @@
<div>
<iframe title="test"></iframe>
</div>

@ -0,0 +1,65 @@
export default {
props: {
done: false,
},
snapshot(target) {
let domMutated;
const mutationRecords = [];
const mutationObserver = new global.window.MutationObserver(records => {
Array.from(
records
).forEach(
({ type, childList, target, attributes, addedNodes, removedNodes }) => {
childList = Array.from(childList|| []).map(n => n.nodeName);
addedNodes = Array.from(addedNodes|| []).map(n => n.nodeName);
removedNodes = Array.from(removedNodes|| []).map(n => n.nodeName);
mutationRecords.push({
type,
childList,
target,
attributes,
addedNodes,
removedNodes,
});
});
domMutated && domMutated(mutationRecords);
});
mutationObserver.observe(target, { childList: true, subtree: true });
mutationRecords.length = 0;
const trigger = new Promise(resolve => (domMutated = resolve));
return {
mutationRecords,
mutationObserver,
trigger,
};
},
async test(assert, target, snapshot, component, window) {
component.$set({done:true});
await snapshot.trigger;
snapshot.mutationObserver.disconnect();
console.log(snapshot.mutationRecords);
const iframeMutations = snapshot.mutationRecords.filter(({addedNodes, removedNodes}) => {
console.log({addedNodes, removedNodes});
return addedNodes.includes('IFRAME')|| removedNodes.includes('IFRAME');
});
console.log({iframeMutations});
assert(iframeMutations.length === 0, 'iframe added/removed');
// assert(false, 'test')
assert.htmlEqual(
target.innerHTML,
`
<div>
<iframe title="test"></iframe>
<span>done</span>
</div>
`
);
},
};

@ -0,0 +1,8 @@
<script>
export let done;
</script>
<div>
<iframe title="test"></iframe>
{#if done}<span>done</span>{/if}
</div>
Loading…
Cancel
Save