Skip to content

Commit 22888a7

Browse files
authored
test: should not emit deprecation warning in test (#7356)
1 parent 1b97315 commit 22888a7

File tree

20 files changed

+47
-75
lines changed

20 files changed

+47
-75
lines changed

src/collapse-item/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default createComponent({
4646
const { value, accordion } = this.parent;
4747

4848
if (
49-
process.env.NODE_ENV !== 'production' &&
49+
process.env.NODE_ENV === 'development' &&
5050
!accordion &&
5151
!Array.isArray(value)
5252
) {

src/collapse/test/index.spec.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,6 @@ test('lazy render collapse content', async () => {
123123
expect(wrapper).toMatchSnapshot();
124124
});
125125

126-
test('warn when value type is incorrect', () => {
127-
const originConsoleError = console.error;
128-
const error = jest.fn();
129-
console.error = error;
130-
131-
mount({
132-
template: `
133-
<van-collapse v-model="active">
134-
<van-collapse-item title="a" name="first"></van-collapse-item>
135-
</van-collapse>
136-
`,
137-
data() {
138-
return {
139-
active: 0,
140-
};
141-
},
142-
});
143-
144-
expect(error).toHaveBeenCalledTimes(1);
145-
console.error = originConsoleError;
146-
});
147-
148126
test('toggle method', (done) => {
149127
mount({
150128
template: `

src/goods-action-icon/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default createComponent({
3131
const slot = this.slots('icon');
3232
const info = this.badge ?? this.info;
3333

34-
if (process.env.NODE_ENV !== 'production' && this.info) {
34+
if (process.env.NODE_ENV === 'development' && this.info) {
3535
console.warn(
3636
'[Vant] GoodsActionIcon: "info" prop is deprecated, use "badge" prop instead.'
3737
);

src/goods-action/test/__snapshots__/index.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ exports[`Icon render icon slot 1`] = `
2222
</div>
2323
`;
2424

25-
exports[`Icon render icon slot with dot 1`] = `
25+
exports[`Icon render icon slot with badge 1`] = `
2626
<div role="button" tabindex="0" class="van-goods-action-icon">
27-
<div class="van-goods-action-icon__icon">Custom Icon<div class="van-info van-info--dot"></div>
27+
<div class="van-goods-action-icon__icon">Custom Icon<div class="van-info">1</div>
2828
</div>Text
2929
</div>
3030
`;
3131

32-
exports[`Icon render icon slot with info 1`] = `
32+
exports[`Icon render icon slot with dot 1`] = `
3333
<div role="button" tabindex="0" class="van-goods-action-icon">
34-
<div class="van-goods-action-icon__icon">Custom Icon<div class="van-info">1</div>
34+
<div class="van-goods-action-icon__icon">Custom Icon<div class="van-info van-info--dot"></div>
3535
</div>Text
3636
</div>
3737
`;

src/goods-action/test/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ test('Icon render icon slot', () => {
5050
expect(wrapper).toMatchSnapshot();
5151
});
5252

53-
test('Icon render icon slot with info', () => {
53+
test('Icon render icon slot with badge', () => {
5454
const wrapper = mount({
5555
render(h) {
5656
return h(Icon, {
5757
props: {
58-
info: '1',
58+
badge: '1',
5959
},
6060
scopedSlots: {
6161
default: () => 'Text',

src/grid-item/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default createComponent({
7474
const iconSlot = this.slots('icon');
7575
const info = this.badge ?? this.info;
7676

77-
if (process.env.NODE_ENV !== 'production' && this.info) {
77+
if (process.env.NODE_ENV === 'development' && this.info) {
7878
console.warn(
7979
'[Vant] GridItem: "info" prop is deprecated, use "badge" prop instead.'
8080
);

src/grid/test/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('render icon-slot', () => {
4949
const wrapper = mount({
5050
template: `
5151
<van-grid icon-size="10">
52-
<van-grid-item info="1">
52+
<van-grid-item badge="1">
5353
<template #icon>
5454
<div>Custom Icon</div>
5555
</template>

src/icon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Icon(
5050
const name = correctName(props.name);
5151
const imageIcon = isImage(name);
5252

53-
if (process.env.NODE_ENV !== 'production' && props.info) {
53+
if (process.env.NODE_ENV === 'development' && props.info) {
5454
console.warn(
5555
'[Vant] Icon: "info" prop is deprecated, use "badge" prop instead.'
5656
);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`should not render when info is empty string 1`] = ``;
3+
exports[`should not render when badge is empty string 1`] = ``;
44

5-
exports[`should not render when info is empty undefined 1`] = ``;
5+
exports[`should not render when badge is empty undefined 1`] = ``;
66

7-
exports[`should render when info is zero 1`] = `<div class="van-info">0</div>`;
7+
exports[`should render when badge is zero 1`] = ``;

src/info/test/index.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import Info from '..';
22
import { mount } from '../../../test';
33

4-
test('should not render when info is empty string', () => {
4+
test('should not render when badge is empty string', () => {
55
const wrapper = mount(Info, {
66
propsData: {
7-
info: '',
7+
badge: '',
88
},
99
});
1010

1111
expect(wrapper).toMatchSnapshot();
1212
});
1313

14-
test('should not render when info is empty undefined', () => {
14+
test('should not render when badge is empty undefined', () => {
1515
const wrapper = mount(Info, {
1616
propsData: {
17-
info: undefined,
17+
badge: undefined,
1818
},
1919
});
2020

2121
expect(wrapper).toMatchSnapshot();
2222
});
2323

24-
test('should render when info is zero', () => {
24+
test('should render when badge is zero', () => {
2525
const wrapper = mount(Info, {
2626
propsData: {
27-
info: 0,
27+
badge: 0,
2828
},
2929
});
3030

0 commit comments

Comments
 (0)