infiniteScroll.spec.js 703 B

1234567891011121314151617181920212223242526272829303132
  1. import { createVue, wait, destroyVM } from '../util';
  2. describe('InfiniteScroll', () => {
  3. let vm;
  4. afterEach(() => {
  5. destroyVM(vm);
  6. });
  7. it('create', async() => {
  8. vm = createVue({
  9. template: `
  10. <ul ref="scrollTarget" v-infinite-scroll="load" style="height: 300px;overflow: auto;">
  11. <li v-for="i in count" style="display: flex;height: 50px;">{{ i }}</li>
  12. </ul>
  13. `,
  14. data() {
  15. return {
  16. count: 0
  17. };
  18. },
  19. methods: {
  20. load() {
  21. this.count += 2;
  22. }
  23. }
  24. }, true);
  25. vm.$refs.scrollTarget.scrollTop = 2000;
  26. await wait();
  27. expect(vm.$el.innerText.indexOf('2') > -1).to.be.true;
  28. });
  29. });