steps.spec.js 3.0 KB

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