steps.spec.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { createVue, destroyVM } from '../util';
  2. import Vue from 'vue';
  3. describe('Steps', () => {
  4. let vm;
  5. afterEach(() => {
  6. destroyVM(vm);
  7. });
  8. it('create', () => {
  9. vm = createVue(`
  10. <el-steps>
  11. <el-step title="step1"></el-step>
  12. <el-step title="step2"></el-step>
  13. <el-step title="step3"></el-step>
  14. </el-steps>
  15. `);
  16. expect(vm.$el.querySelectorAll('.el-step')).to.length(3);
  17. });
  18. it('space', done => {
  19. vm = createVue(`
  20. <el-steps>
  21. <el-step title="step1"></el-step>
  22. <el-step title="step2"></el-step>
  23. <el-step title="step3"></el-step>
  24. </el-steps>
  25. `);
  26. const vm2 = createVue(`
  27. <el-steps :space="100">
  28. <el-step title="step1"></el-step>
  29. <el-step title="step2"></el-step>
  30. <el-step title="step3"></el-step>
  31. <el-step title="step4"></el-step>
  32. </el-steps>
  33. `);
  34. Vue.nextTick(_ => {
  35. expect(vm.$el.querySelector('.el-step')).have.deep.property('style.webkitFlexBasis').equal('50%');
  36. expect(vm2.$el.querySelector('.el-step')).have.deep.property('style.webkitFlexBasis').equal('100px');
  37. done();
  38. });
  39. });
  40. it('processStatus', done => {
  41. vm = createVue(`
  42. <el-steps :active="1" process-status="error">
  43. <el-step title="step1"></el-step>
  44. <el-step title="step2"></el-step>
  45. <el-step title="step3"></el-step>
  46. </el-steps>
  47. `);
  48. vm.$nextTick(_ => {
  49. expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(1);
  50. done();
  51. });
  52. });
  53. it('finishStatus', done => {
  54. vm = createVue(`
  55. <el-steps :active="1" finish-status="error">
  56. <el-step title="abc"></el-step>
  57. <el-step title="abc2"></el-step>
  58. </el-steps>
  59. `);
  60. vm.$nextTick(_ => {
  61. expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(1);
  62. done();
  63. });
  64. });
  65. it('active', done => {
  66. vm = createVue({
  67. template: `
  68. <el-steps :active="active" finish-status="error">
  69. <el-step title="abc"></el-step>
  70. <el-step title="abc2"></el-step>
  71. </el-steps>
  72. `,
  73. data() {
  74. return { active: 0 };
  75. }
  76. });
  77. vm.$nextTick(_ => {
  78. expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(0);
  79. vm.active = 2;
  80. vm.$nextTick(_ => {
  81. expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(2);
  82. done();
  83. });
  84. });
  85. });
  86. it('create vertical', () => {
  87. vm = createVue(`
  88. <el-steps direction="vertical">
  89. <el-step title="aaa"></el-step>
  90. <el-step title="bbb"></el-step>
  91. </el-steps>
  92. `);
  93. expect(vm.$el.querySelector('.is-vertical')).to.exist;
  94. });
  95. it('vertical:height', done => {
  96. vm = createVue(`
  97. <el-steps direction="vertical" :space="200">
  98. <el-step title="aaa"></el-step>
  99. <el-step title="bbb"></el-step>
  100. </el-steps>
  101. `);
  102. vm.$nextTick(_ => {
  103. expect(vm.$el.querySelector('.el-step')).have.deep.property('style.webkitFlexBasis').equal('200px');
  104. done();
  105. });
  106. });
  107. it('step:status=error', done => {
  108. vm = createVue(`
  109. <el-steps :active="2" process-status="process" finish-status="success" direction="horizontal">
  110. <el-step title="step1"></el-step>
  111. <el-step title="step2" status="error"></el-step>
  112. <el-step title="step3"></el-step>
  113. </el-steps>
  114. `);
  115. vm.$nextTick(_ => {
  116. const errorLine = vm.$el.querySelector('.el-step:nth-child(2) .el-step__line-inner');
  117. expect(errorLine.getBoundingClientRect().width).to.equal(0);
  118. const nextStep = vm.$el.querySelector('.el-step:nth-child(3) .el-step__head');
  119. expect(nextStep.classList.contains('is-wait')).to.equal(true);
  120. done();
  121. });
  122. });
  123. });