Skip to content

Commit a2b0199

Browse files
committed
Improve the description of unit test
1 parent cea14d2 commit a2b0199

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('InfiniteLoading.vue', () => {
4141
vm.$destroy();
4242
});
4343

44-
it('should render correct template', () => {
44+
it('should render a basic template', () => {
4545
vm.isDivScroll = false;
4646
vm.distance = undefined;
4747

@@ -50,27 +50,21 @@ describe('InfiniteLoading.vue', () => {
5050
expect(vm.$el.querySelector('.loading-default')).to.be.ok;
5151
});
5252

53-
it('should appear a loading animation', (done) => {
53+
it('should execute callback and display a spinner immediately after initialize', (done) => {
5454
vm.onInfinite = function test() {
5555
Vue.nextTick(() => {
5656
expect(isShow(vm.$el.querySelector('.loading-default'))).to.be.true;
57-
58-
this.$broadcast('$InfiniteLoading:loaded');
59-
60-
Vue.nextTick(() => {
61-
expect(isShow(vm.$el.querySelector('.loading-default'))).to.be.false;
62-
done();
63-
});
57+
done();
6458
});
65-
}.bind(vm);
59+
};
6660

6761
vm.$mount().$appendTo('body');
6862
});
6963

70-
it('should only load once', (done) => {
64+
it('should not to execute callback if the previous loading has not be completed', (done) => {
7165
vm.onInfinite = function test() {
72-
const length = this.list.length + 1;
73-
for (let i = length; i < length + 20; i++) {
66+
const len = this.list.length + 1;
67+
for (let i = len; i < len + 20; i++) {
7468
this.list.push(i);
7569
}
7670

@@ -81,7 +75,7 @@ describe('InfiniteLoading.vue', () => {
8175
done();
8276
});
8377

84-
// trigger scroll event
78+
// trigger scroll event manually
8579
vm.$el.scrollTop = vm.$el.scrollHeight;
8680
}
8781
});
@@ -90,7 +84,7 @@ describe('InfiniteLoading.vue', () => {
9084
vm.$mount().$appendTo('body');
9185
});
9286

93-
it('should be destroyed completely', (done) => {
87+
it('should be destroyed completely by v-if', (done) => {
9488
vm.onInfinite = function test() {
9589
this.isLoadedAll = true;
9690
Vue.nextTick(() => {

0 commit comments

Comments
 (0)