Skip to content

Commit 55b3b43

Browse files
committed
Add unit test for the responsive feature of force-use-infinite-wrapper property
1 parent 1ac465c commit 55b3b43

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ describe('vue-infinite-loading', () => {
249249
vm.$mount('#app');
250250
});
251251

252-
it('should works properly with scroll plugins through the `infinite-wrapper` attribute', (done) => {
252+
it('should works properly with scroll plugins through the `infinite-wrapper` property', (done) => {
253253
const app = document.getElementById('app');
254254
const wrapper = document.createElement('div');
255255

256256
app.appendChild(wrapper);
257-
app.setAttribute('infinite-wrapper', ''); // add `infinite-wrapper` attribute for app container
257+
app.setAttribute('infinite-wrapper', ''); // add `infinite-wrapper` property for app container
258258
vm = new Vue(Object.assign({}, basicConfig, {
259259
methods: {
260260
infiniteHandler: function infiniteHandler() {
@@ -460,7 +460,7 @@ describe('vue-infinite-loading', () => {
460460
vm.$mount('#app');
461461
});
462462

463-
it('should find my forcible element as scroll wrapper when using `force-use-infinite-wrapper` attribute', (done) => {
463+
it('should find my forcible element as scroll wrapper when using `force-use-infinite-wrapper` property', (done) => {
464464
vm = new Vue(Object.assign({}, basicConfig, {
465465
template: `
466466
<div infinite-wrapper>
@@ -536,4 +536,34 @@ describe('vue-infinite-loading', () => {
536536

537537
vm.$mount('#app');
538538
});
539+
540+
it('should search scroll wrapper again when change the `force-use-infinite-wrapper` property', (done) => {
541+
vm = new Vue(Object.assign({}, basicConfig, {
542+
data: {
543+
forceUseInfiniteWrapper: true,
544+
},
545+
template: `
546+
<div infinite-wrapper>
547+
<div style="overflow: auto;">
548+
<infinite-loading
549+
:force-use-infinite-wrapper="forceUseInfiniteWrapper"
550+
@infinite="infiniteHandler"
551+
ref="infiniteLoading"
552+
>
553+
</infinite-loading>
554+
</div>
555+
</div>
556+
`,
557+
mounted: function mounted() {
558+
expect(this.$refs.infiniteLoading.scrollParent).to.equal(this.$el);
559+
this.forceUseInfiniteWrapper = false;
560+
this.$nextTick(() => {
561+
expect(this.$refs.infiniteLoading.scrollParent).to.equal(this.$el.querySelector('div'));
562+
done();
563+
});
564+
},
565+
}));
566+
567+
vm.$mount('#app');
568+
});
539569
});

0 commit comments

Comments
 (0)