Skip to content

Commit 08861e3

Browse files
committed
test: add test case for remove slot styles logic
1 parent c9383bc commit 08861e3

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('vue-infinite-loading:component', () => {
119119

120120
if (isComplete) {
121121
// check no more text
122-
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[1])).to.be.true;
122+
expect(isShow(this.$el.querySelector('.infinite-status-prompt:nth-child(3)'))).to.be.true;
123123
done();
124124
}
125125
});
@@ -179,7 +179,7 @@ describe('vue-infinite-loading:component', () => {
179179
$state.complete();
180180
this.$nextTick(() => {
181181
// check no results text
182-
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[0])).to.be.true;
182+
expect(isShow(this.$el.querySelector('.infinite-status-prompt:nth-child(2)'))).to.be.true;
183183

184184
// reset component
185185
$state.reset();
@@ -343,40 +343,22 @@ describe('vue-infinite-loading:component', () => {
343343
vm.$mount('#app');
344344
});
345345

346-
it('should support hide load result through blank slots', (done) => {
347-
let calledTimes = 0;
348-
346+
it('should remove slot styles if does not configure with `template` tag', (done) => {
349347
vm = new Vue(Object.assign({}, basicConfig, {
350348
methods: {
351349
infiniteHandler: function infiniteHandler($state) {
352-
if (calledTimes) {
353-
$state.loaded();
354-
$state.complete();
355-
this.$nextTick(() => {
356-
// check for no-more result display
357-
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[1])).to.be.false;
358-
done();
359-
});
360-
} else {
361-
calledTimes += 1;
362-
$state.complete();
363-
this.$nextTick(() => {
364-
// check for no-result result display
365-
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[0])).to.be.false;
350+
// expect empty styles for no results slot
351+
expect(this.$el.querySelector('.infinite-status-prompt:nth-child(2)').style.color).to.be.empty;
366352

367-
// reset component to check no-more status
368-
$state.reset();
369-
});
370-
}
353+
// expect valid styles for no more slot
354+
expect(this.$el.querySelector('.infinite-status-prompt:nth-child(3)').style.color).to.not.be.empty;
355+
$state.complete();
356+
done();
371357
},
372358
},
373359
template: `
374-
<infinite-loading
375-
@infinite="infiniteHandler"
376-
ref="infiniteLoading"
377-
>
360+
<infinite-loading @infinite="infiniteHandler">
378361
<span slot="no-results"></span>
379-
<span slot="no-more"></span>
380362
</infinite-loading>
381363
`,
382364
}));

0 commit comments

Comments
 (0)