feat(blockAtnd): Affix and tests

This commit is contained in:
Gervwyk 2020-11-24 16:57:15 +02:00
parent cef1f2ba98
commit 5c73d3f51b
5 changed files with 202 additions and 5 deletions

View File

@ -8,3 +8,8 @@
type: Affix
properties:
offsetBottom: 15
- id: "properties.style"
type: Affix
properties:
style:
border: 5px solid blue

View File

@ -25,7 +25,8 @@
"additionalProperties": false,
"properties": {
"onChange": {
"type": "array"
"type": "array",
"description": "Triggered when container affix status changes."
}
}
}

View File

@ -0,0 +1,38 @@
/*
Copyright 2020 Lowdefy, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { runMockRenderTests } from '@lowdefy/block-tools';
import Enzyme, { mount } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import { Affix } from 'antd';
Enzyme.configure({ adapter: new Adapter() });
import AffixBlock from '../src/blocks/Affix/Affix';
import examples from '../demo/examples/Affix.yaml';
import meta from '../src/blocks/Affix/Affix.json';
jest.mock('antd/lib/affix', () => {
return jest.fn(() => 'mocked');
});
const mocks = [
{
name: 'default',
fn: Affix,
},
];
runMockRenderTests({ examples, Block: AffixBlock, meta, mocks, enzyme: { mount } });

View File

@ -0,0 +1,101 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Mock render - default - value[0] - default 1`] = `
Array [
Array [
Object {
"children": <div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>,
"className": "css-0",
"id": "default",
"offsetBottom": undefined,
"offsetTop": undefined,
"onChange": [Function],
},
Object {},
],
]
`;
exports[`Mock render - properties.offsetBottom - value[0] - default 1`] = `
Array [
Array [
Object {
"children": <div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>,
"className": "css-0",
"id": "properties.offsetBottom",
"offsetBottom": 15,
"offsetTop": undefined,
"onChange": [Function],
},
Object {},
],
]
`;
exports[`Mock render - properties.offsetTop - value[0] - default 1`] = `
Array [
Array [
Object {
"children": <div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>,
"className": "css-0",
"id": "properties.offsetTop",
"offsetBottom": undefined,
"offsetTop": 15,
"onChange": [Function],
},
Object {},
],
]
`;
exports[`Mock render - properties.style - value[0] - default 1`] = `
Array [
Array [
Object {
"children": <div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>,
"className": "css-1dcnkry",
"id": "properties.style",
"offsetBottom": undefined,
"offsetTop": undefined,
"onChange": [Function],
},
Object {},
],
]
`;

View File

@ -22,10 +22,54 @@ exports[`Render default - value[0] 1`] = `
</div>
`;
exports[`Render properties.top - value[0] 1`] = `
exports[`Render properties.offsetBottom - value[0] 1`] = `
<div
className="{}"
id="properties.top"
id="properties.offsetBottom"
>
<div
className=""
>
<div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>
</div>
</div>
`;
exports[`Render properties.offsetTop - value[0] 1`] = `
<div
className="{}"
id="properties.offsetTop"
>
<div
className=""
>
<div
style={
Object {
"border": "1px solid red",
"padding": 10,
}
}
>
content
</div>
</div>
</div>
`;
exports[`Render properties.style - value[0] 1`] = `
<div
className="{\\"style\\":{\\"border\\":\\"5px solid blue\\"}}"
id="properties.style"
>
<div
className=""
@ -48,6 +92,14 @@ exports[`Test Schema default 1`] = `true`;
exports[`Test Schema default 2`] = `null`;
exports[`Test Schema properties.top 1`] = `true`;
exports[`Test Schema properties.offsetBottom 1`] = `true`;
exports[`Test Schema properties.top 2`] = `null`;
exports[`Test Schema properties.offsetBottom 2`] = `null`;
exports[`Test Schema properties.offsetTop 1`] = `true`;
exports[`Test Schema properties.offsetTop 2`] = `null`;
exports[`Test Schema properties.style 1`] = `true`;
exports[`Test Schema properties.style 2`] = `null`;