ソースを参照

test: optimization (#1074)

Drjingfubo 3 年 前
コミット
fe5a9a439d

+ 6 - 0
src/packages/__VUE/cellgroup/test/__snapshots__/index.spec.ts.snap

@@ -0,0 +1,6 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render title、desc slot correctly 1`] = `
+"<view class=\\"nut-cell-group\\">Custom TitleCustom Desc<view class=\\"nut-cell-group__warp\\"></view>
+</view>"
+`;

+ 28 - 0
src/packages/__VUE/infiniteloading/__tests__/__snapshots__/infiniteloading.spec.ts.snap

@@ -24,3 +24,31 @@ exports[`infiniteloading base 1`] = `
   </view>
 </view>"
 `;
+
+exports[`pull base 1`] = `
+"<view class=\\"nut-infiniteloading\\">
+  <view class=\\"nut-infinite-top\\" style=\\"height: 0px; transition: height 0.2s cubic-bezier(0.25,0.1,0.25,1);\\">
+    <view class=\\"top-box\\"><img class=\\"nut-icon__img top-img\\" src=\\"https://img10.360buyimg.com/imagetools/jfs/t1/169863/6/4565/6306/60125948E7e92774e/40b3a0cf42852bcb.png\\">
+      <view class=\\"top-text\\">松开刷新</view>
+    </view>
+  </view>
+  <view class=\\"nut-infinite-container\\"></view>
+  <view class=\\"nut-infinite-bottom\\">
+    <!--v-if-->
+  </view>
+</view>"
+`;
+
+exports[`pull base 2`] = `
+"<view class=\\"nut-infiniteloading\\">
+  <view class=\\"nut-infinite-top\\" style=\\"height: 0px; transition: height 0.2s cubic-bezier(0.25,0.1,0.25,1);\\">
+    <view class=\\"top-box\\"><img class=\\"nut-icon__img top-img\\" src=\\"https://img10.360buyimg.com/imagetools/jfs/t1/169863/6/4565/6306/60125948E7e92774e/40b3a0cf42852bcb.png\\">
+      <view class=\\"top-text\\">松开刷新</view>
+    </view>
+  </view>
+  <view class=\\"nut-infinite-container\\"></view>
+  <view class=\\"nut-infinite-bottom\\">
+    <!--v-if-->
+  </view>
+</view>"
+`;

+ 1 - 1
src/packages/__VUE/noticebar/__tests__/__snapshots__/noticebar.spec.ts.snap

@@ -24,7 +24,7 @@ exports[`icon custom 1`] = `
       <!--v-if-->
     </view>
     <view class=\\"wrap\\">
-      <view class=\\"content nut-ellipsis\\" style=\\"padding-left: 0px; animation-delay: 1s; animation-duration: 0s;\\"><a href=\\"https://www.jd.com\\">京东商城</a></view>
+      <view class=\\"content\\" style=\\"animation-delay: 1s; animation-duration: 0s; transform: translateX(0);\\"><a href=\\"https://www.jd.com\\">京东商城</a></view>
     </view>
     <!--v-if-->
   </view>

+ 31 - 0
src/packages/__VUE/searchbar/__tests__/__snapshots__/searchbar.spec.ts.snap

@@ -0,0 +1,31 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`basic usage 1`] = `
+"<view class=\\"nut-searchbar\\">
+  <!--v-if-->
+  <view class=\\"nut-searchbar__search-input\\">
+    <!--v-if-->
+    <view class=\\"nut-searchbar__input-inner\\">
+      <form action=\\"#\\"><input class=\\"nut-searchbar__input-bar\\" type=\\"text\\" maxlength=\\"9999\\" placeholder=\\"请输入\\"></form>
+      <view class=\\"nut-searchbar__input-clear\\" style=\\"display: none;\\"><i class=\\"nutui-iconfont nut-icon nut-icon-circle-close\\" style=\\"color: rgb(85, 85, 85); font-size: 12px; width: 12px; height: 12px;\\" src=\\"\\"></i></view>
+    </view>
+    <!--v-if-->
+  </view>
+  <!--v-if-->
+</view>"
+`;
+
+exports[`slot test 1`] = `
+"<view class=\\"nut-searchbar\\">
+  <!--v-if-->
+  <view class=\\"nut-searchbar__search-input\\">
+    <!--v-if-->
+    <view class=\\"nut-searchbar__input-inner\\">
+      <form action=\\"#\\"><input class=\\"nut-searchbar__input-bar\\" type=\\"text\\" maxlength=\\"9999\\" placeholder=\\"请输入\\"></form>
+      <view class=\\"nut-searchbar__input-clear\\" style=\\"display: none;\\"><i class=\\"nutui-iconfont nut-icon nut-icon-circle-close\\" style=\\"color: rgb(85, 85, 85); font-size: 12px; width: 12px; height: 12px;\\" src=\\"\\"></i></view>
+    </view>
+    <!--v-if-->
+  </view>
+  <!--v-if-->
+</view>"
+`;

+ 5 - 6
src/packages/__VUE/searchbar/__tests__/searchbar.spec.ts

@@ -116,17 +116,16 @@ test('blur event test', async () => {
   expect(wrapper.emitted('blur')).toBeTruthy();
 });
 
-test('clear event test', () => {
+test('clear event test', async () => {
   const wrapper = mount(SearchBar, { props: { modelValue: 3 } });
   const input = wrapper.find('input');
   const clear = wrapper.find('.nut-searchbar__input-clear');
   wrapper.find('input').trigger('input');
-  clear.trigger('click');
-
+  expect(input.element.value).toBe('3');
+  await clear.trigger('click');
+  // 修改update:modelValue
+  expect((wrapper.emitted('update:modelValue') as any)[1][0]).toEqual('');
   expect(clear.exists()).toBe(true);
-  setTimeout(() => {
-    expect(input.element.value).toBe('');
-  });
 });
 
 test('slot test', () => {

+ 3 - 1
src/packages/__VUE/swiper/__tests__/index.spec.ts

@@ -76,7 +76,7 @@ test('should render initpage', async () => {
   });
 
   await nextTick();
-
+  await nextTick();
   const swiperItem = wrapper.findAll('.nut-swiper-inner')[0].element as HTMLElement;
 
   expect(swiperItem.style.transform).toEqual(`translateX(-${wrapper.vm.width * wrapper.vm.page}px)`);
@@ -113,6 +113,7 @@ test('should render direction', async () => {
   });
 
   await nextTick();
+  await nextTick();
 
   const swiperItem = wrapper.findAll('.nut-swiper-inner')[0].element as HTMLElement;
 
@@ -150,6 +151,7 @@ test('should render pagination', async () => {
   });
 
   await nextTick();
+  await nextTick();
 
   const swiperPagination = wrapper.find('.nut-swiper-pagination');
   expect(swiperPagination.exists()).toBe(true);

+ 11 - 0
src/packages/__VUE/switch/__tests__/__snapshots__/switch.spec.ts.snap

@@ -0,0 +1,11 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render ok 1`] = `
+"<view class=\\"nut-switch switch-close nut-switch-base\\">
+  <view class=\\"switch-button\\">
+    <!--v-if-->
+    <!-- <view v-show=\\"!modelValue\\" class=\\"close-line\\"></view> -->
+    <!--v-if-->
+  </view>
+</view>"
+`;