Browse Source

Merge branch 'jdf2e:next' into next

JackieScorpio 4 years ago
parent
commit
066e038064

+ 1 - 0
jest.config.js

@@ -8,6 +8,7 @@ module.exports = {
   },
   },
   // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts
   // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts
   testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts)$',
   testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts)$',
+  //testRegex: '__tests__.action.spec.ts',
   // 支持源代码中相同的 `@` -> `src` 别名
   // 支持源代码中相同的 `@` -> `src` 别名
   moduleNameMapper: {
   moduleNameMapper: {
     '^@/(.*)$': '<rootDir>/src/$1'
     '^@/(.*)$': '<rootDir>/src/$1'

+ 1 - 0
src/packages/__VUE/checkboxgroup/index.vue

@@ -37,6 +37,7 @@ export default create({
 
 
     const updateValue = (value: any[]) => {
     const updateValue = (value: any[]) => {
       emit('update:modelValue', value);
       emit('update:modelValue', value);
+      emit('change', value);
     };
     };
 
 
     const toggleAll = (checked: boolean) => {
     const toggleAll = (checked: boolean) => {

+ 2 - 2
src/packages/__VUE/col/index.scss

@@ -17,10 +17,10 @@
 
 
 @for $i from 1 through 24 {
 @for $i from 1 through 24 {
   .nut-col-offset-#{$i} {
   .nut-col-offset-#{$i} {
-    margin-left: 100/ 24 * $i * 1%;
+    margin-left: math.div(100, 24) * $i * 1%;
   }
   }
 
 
   .nut-col-#{$i} {
   .nut-col-#{$i} {
-    width: 100/ 24 * $i * 1%;
+    width: math.div(100, 24) * $i * 1%;
   }
   }
 }
 }

+ 7 - 1
src/packages/__VUE/rate/index.scss

@@ -16,10 +16,16 @@
       }
       }
       &--half {
       &--half {
         position: absolute;
         position: absolute;
-        width: 50%;
+        width: 50% !important;
         left: 0;
         left: 0;
         top: 0;
         top: 0;
         overflow: hidden;
         overflow: hidden;
+
+        &::before {
+          top: 0;
+          left: 0;
+          transform: translate(0, 0);
+        }
       }
       }
     }
     }
   }
   }

+ 79 - 0
src/packages/__VUE/shortpassword/__tests__/shortpassword.spec.ts

@@ -0,0 +1,79 @@
+import { mount } from '@vue/test-utils';
+import ShortPassword from '../index.vue';
+import Icon from '../../icon/index.vue';
+
+test('base', () => {
+  const wrapper = mount(ShortPassword, {
+    props: {
+      visible: true,
+      value: 123
+    }
+  });
+  const input: any = wrapper.find('.nut-input-real');
+  expect(input.exists()).toBe(true);
+  expect(input.attributes('maxlength')).toBe('6');
+  expect(input.element.value).toBe('123');
+  //代码还没处理modelvalue值
+});
+test('base length and error', () => {
+  const wrapper = mount(ShortPassword, {
+    props: {
+      visible: true,
+      length: 4,
+      errorMsg: '错误信息',
+      noButton: false,
+      value: 'qwe'
+    }
+  });
+  const input = wrapper.find('.nut-input-real');
+  expect(input.exists()).toBe(true);
+  // expect(input.attributes("maxlength")).toBe("4");
+  const error = wrapper.find('.nut-shortpsd-error');
+  expect(error.exists()).toBe(true);
+  expect(error.text()).toBe('错误信息');
+  const cancle = wrapper.find('.nut-shortpsd-cancle');
+  expect(cancle.exists()).toBe(true);
+  const sure = wrapper.find('.nut-shortpsd-sure');
+  expect(sure.exists()).toBe(true);
+  cancle.trigger('click');
+  expect(wrapper.emitted('cancel')).toBeTruthy();
+  sure.trigger('click');
+  expect((wrapper.emitted('ok') as any)[0][0]).toBe('qwe');
+});
+
+test('event callback', async () => {
+  const wrapper = mount(ShortPassword, {
+    props: {
+      visible: true
+    }
+  });
+  const input: any = wrapper.find('.nut-input-real');
+  await input.trigger('click');
+  await input.trigger('input');
+  await wrapper.trigger('keydown', {
+    key: '123'
+  });
+  setTimeout(() => {
+    expect(wrapper.emitted('change') as any).toBe('123');
+  }, 400);
+
+  //代码还没处理modelvalue值
+});
+test('event callback', async () => {
+  const wrapper = mount(ShortPassword, {
+    props: {
+      visible: true
+    }
+  });
+  const input: any = wrapper.find('.nut-input-real');
+  await input.trigger('click');
+  await input.trigger('input');
+  await wrapper.trigger('keydown', {
+    key: '123456'
+  });
+  setTimeout(() => {
+    expect(wrapper.emitted('complete') as any).toBe('123456');
+  }, 400);
+
+  //代码还没处理modelvalue值
+});

+ 0 - 10
src/packages/__VUE/textarea/__tests__/textarea.spec.ts

@@ -1,10 +0,0 @@
-import { mount } from '@vue/test-utils';
-
-import TextArea from '../index.vue';
-
-test('Textarea base', () => {
-  //const wrapper = mount(TextArea, { props: { modelValue: 3 } });
-  // const input = wrapper.find('input');
-  // expect(input.exists()).toBe(true);
-  // expect(input.element.value).toBe("3");
-});