steps.spec.js 3.7 KB

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