Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update jest.virtualHost.config.js #1566

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.virtualHost.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ module.exports = {
},
globalSetup: '<rootDir>/script/test/globalSetup.js',
snapshotSerializers: ['miniprogram-simulate/jest-snapshot-plugin'],
snapshotResolver: '<rootDir>/script/test/snapshotResolver.js',
};
12 changes: 12 additions & 0 deletions script/test/snapshotResolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
// resolves from test to snapshot path
resolveSnapshotPath: (testPath, snapshotExtension) =>
testPath.replace('__test__', '__test__/__virtualHostSnapshot__') + snapshotExtension,

// resolves from snapshot to test path
resolveTestPath: (snapshotFilePath, snapshotExtension) =>
snapshotFilePath.replace('__test__/__virtualHostSnapshot__', '__test__').slice(0, -snapshotExtension.length),

// Example test path, used for preflight consistency check of the implementation above
testPathForConsistencyCheck: 'some/__tests__/example.test.js',
LeeJim marked this conversation as resolved.
Show resolved Hide resolved
};
46 changes: 46 additions & 0 deletions src/avatar/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Avatar & Avatar Groups Avatar Props : style && customStyle 1`] = `
<main>
<main
class="avatar"
>
<wx-view
class="t-avatar__wrapper class t-class"
style="font-size: 9px;"
>
<t-badge
tClass=""
tClassContent=""
tClassCount=""
>
<wx-view
ariaDescribedby="t_badge_0_description"
ariaLabelledby="t_badge_0_label"
ariaRole="option"
class="t-badge class t-class"
style=""
>
<wx-view
ariaHidden="true"
class="t-badge__content t-class-content"
id="t_badge_0_label"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel="头像"
ariaRole="img"
class="t-avatar t-avatar--circle t-avatar--medium t-class-image"
style=""
>
<wx-view
class="t-avatar__text t-class-content"
/>
</wx-view>
</wx-view>
</wx-view>
</t-badge>
</wx-view>
</main>
</main>
`;
229 changes: 229 additions & 0 deletions src/avatar/__test__/__virtualHostSnapshot__/demo.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Avatar Avatar action demo works fine 1`] = `
<action>
<t-avatar-group
max="5"
>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar2.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar3.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar4.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar5.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
</t-avatar-group>
</action>
`;

exports[`Avatar Avatar badge-avatar demo works fine 1`] = `
<badge-avatar>
<t-avatar
badgeProps="{{
Object {
"dot": true,
"offset": Array [
4,
4,
],
}
}}"
class="avatar-example"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
<t-avatar
badgeProps="{{
Object {
"count": 8,
"offset": Array [
6,
6,
],
}
}}"
class="avatar-example"
tClassContent="external-class-content"
>
A
</t-avatar>
<t-avatar
badgeProps="{{
Object {
"count": 12,
"offset": Array [
6,
6,
],
}
}}"
class="avatar-example"
icon="user"
/>
</badge-avatar>
`;

exports[`Avatar Avatar character-avatar demo works fine 1`] = `
<character-avatar>
<t-avatar
ariaLabel="字符头像"
class="avatar-example"
tClassContent="external-class-content"
>
A
</t-avatar>
<t-avatar
class="avatar-example"
shape="round"
tClassContent="external-class-content"
>
A
</t-avatar>
</character-avatar>
`;

exports[`Avatar Avatar exhibition demo works fine 1`] = `
<exhibition>
<t-avatar-group
cascading="left-up"
collapseAvatar="+5"
max="5"
>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar2.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar3.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar4.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar5.png"
/>
<t-avatar
bordered="{{true}}"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
</t-avatar-group>
</exhibition>
`;

exports[`Avatar Avatar icon-avatar demo works fine 1`] = `
<icon-avatar>
<t-avatar
class="avatar-example"
icon="user"
/>
<t-avatar
class="avatar-example"
icon="user"
shape="round"
/>
</icon-avatar>
`;

exports[`Avatar Avatar image-avatar demo works fine 1`] = `
<image-avatar>
<t-avatar
class="avatar-example"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
<t-avatar
class="avatar-example"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
shape="round"
/>
</image-avatar>
`;

exports[`Avatar Avatar size demo works fine 1`] = `
<size>
<wx-view
class="avatar-example"
>
<t-avatar
class="avatar-example--large"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
size="large"
/>
<t-avatar
class="avatar-example--large"
size="large"
tClassContent="external-class-content"
>
A
</t-avatar>
<t-avatar
class="avatar-example--large"
icon="user"
size="large"
/>
</wx-view>
<wx-view
class="avatar-example"
>
<t-avatar
class="avatar-example--medium"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
/>
<t-avatar
class="avatar-example--medium"
size="medium"
tClassContent="external-class-content"
>
A
</t-avatar>
<t-avatar
class="avatar-example--medium"
icon="user"
size="medium"
/>
</wx-view>
<wx-view
class="avatar-example"
>
<t-avatar
class="avatar-example--small"
image="https://tdesign.gtimg.com/miniprogram/images/avatar1.png"
size="small"
/>
<t-avatar
class="avatar-example--small"
size="small"
tClassContent="external-class-content"
>
A
</t-avatar>
<t-avatar
class="avatar-example--small"
icon="user"
size="small"
/>
</wx-view>
</size>
`;
46 changes: 46 additions & 0 deletions src/avatar/__test__/__virtualHostSnapshot__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Avatar & Avatar Groups Avatar Props : style && customStyle 1`] = `
<main>
<main
class="avatar"
>
<wx-view
class="t-avatar__wrapper class t-class"
style="color: red; font-size: 9px;"
>
<t-badge
tClass=""
tClassContent=""
tClassCount=""
>
<wx-view
ariaDescribedby="t_badge_0_description"
ariaLabelledby="t_badge_0_label"
ariaRole="option"
class="t-badge class t-class"
style=""
>
<wx-view
ariaHidden="true"
class="t-badge__content t-class-content"
id="t_badge_0_label"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel="头像"
ariaRole="img"
class="t-avatar t-avatar--circle t-avatar--medium t-class-image"
style=""
>
<wx-view
class="t-avatar__text t-class-content"
/>
</wx-view>
</wx-view>
</wx-view>
</t-badge>
</wx-view>
</main>
</main>
`;
2 changes: 1 addition & 1 deletion src/avatar/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Avatar & Avatar Groups', () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));
const $avatar = comp.querySelector('.avatar >>> .t-avatar__wrapper');
// expect(comp.toJSON()).toMatchSnapshot();
expect(comp.toJSON()).toMatchSnapshot();
if (VIRTUAL_HOST) {
expect($avatar.dom.getAttribute('style').includes(`${comp.data.style}; ${comp.data.customStyle}`)).toBeTruthy();
} else {
Expand Down