[FIX] portal: unskip some tests

This commit is contained in:
Géry Debongnie
2021-11-14 15:39:03 +01:00
committed by Aaron Bohy
parent af80cefa76
commit ae30d9db7d
3 changed files with 69 additions and 13 deletions
+46 -4
View File
@@ -372,11 +372,11 @@ exports[`Portal portal with only text as content 1`] = `
exports[`Portal portal with target not in dom 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture } = helpers;
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
let assign = Object.assign;
let block1 = createBlock(\`<div><owl-child-0/></div>\`);
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block2 = createBlock(\`<div>2</div>\`);
const slot2 = ctx => (node, key) => {
@@ -384,7 +384,7 @@ exports[`Portal portal with target not in dom 1`] = `
}
return function template(ctx, node, key = \\"\\") {
let b3 = assign(node.getChild(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, ctx), {slots: {'default': slot2(ctx)}});
let b3 = assign(component(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
return block1([], [b3]);
}
}"
@@ -466,6 +466,48 @@ exports[`Portal with target in template (before portal) 1`] = `
}"
`;
exports[`Portal: Props validation target is mandatory 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
let assign = Object.assign;
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block2 = createBlock(\`<div>2</div>\`);
const slot2 = ctx => (node, key) => {
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = assign(component(\`Portal\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
return block1([], [b3]);
}
}"
`;
exports[`Portal: Props validation target is not list 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
let assign = Object.assign;
let block1 = createBlock(\`<div><block-child-0/></div>\`);
let block2 = createBlock(\`<div>2</div>\`);
const slot2 = ctx => (node, key) => {
return block2();
}
return function template(ctx, node, key = \\"\\") {
let b3 = assign(component(\`Portal\`, {target: ['body']}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
return block1([], [b3]);
}
}"
`;
exports[`Portal: UI/UX focus is kept across re-renders 1`] = `
"function anonymous(bdom, helpers
) {
+18 -9
View File
@@ -149,9 +149,7 @@ describe("Portal", () => {
);
});
test.skip("portal with target not in dom", async () => {
// need error handling to unskip this one
test("portal with target not in dom", async () => {
class Parent extends Component {
static components = { Portal };
static template = xml`
@@ -170,8 +168,8 @@ describe("Portal", () => {
}
expect(error).toBeDefined();
expect(error.message).toBe('Could not find any match for "#does-not-exist"');
expect(fixture.innerHTML).toBe(`<div id="outside"></div>`);
expect(error.message).toBe("invalid portal target");
expect(fixture.innerHTML).toBe(`<div></div>`);
});
test("portal with child and props", async () => {
@@ -508,7 +506,10 @@ describe("Portal: UI/UX", () => {
});
describe("Portal: Props validation", () => {
test.skip("target is mandatory", async () => {
test("target is mandatory", async () => {
const consoleInfo = console.info;
console.info = jest.fn();
class Parent extends Component {
static components = { Portal };
static template = xml`
@@ -519,16 +520,21 @@ describe("Portal: Props validation", () => {
</div>`;
}
let error;
let app = new App(Parent);
app.configure({ dev: true });
try {
await mount(Parent, fixture);
await app.mount(fixture);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.message).toBe(`Missing props 'target' (component 'Portal')`);
console.info = consoleInfo;
});
test.skip("target is not list", async () => {
test("target is not list", async () => {
const consoleInfo = console.info;
console.info = jest.fn();
class Parent extends Component {
static components = { Portal };
static template = xml`
@@ -539,12 +545,15 @@ describe("Portal: Props validation", () => {
</div>`;
}
let error;
let app = new App(Parent);
app.configure({ dev: true });
try {
await mount(Parent, fixture);
await app.mount(fixture);
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error.message).toBe(`Invalid Prop 'target' in component 'Portal'`);
console.info = consoleInfo;
});
});