Skip to content

Commit 6707f8c

Browse files
committed
Modify all the test cases to adapt to the $state argument
1 parent 9533bfb commit 6707f8c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/unit/specs/InfiniteLoading.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('vue-infinite-loading', () => {
112112
it('should complete a standard life circle\n (init -> loading -> loaded -> complete)', (done) => {
113113
vm = new Vue(Object.assign({}, basicConfig, {
114114
methods: {
115-
infiniteHandler: function infiniteHandler() {
115+
infiniteHandler: function infiniteHandler($state) {
116116
for (let i = 0, j = this.list.length; i < 3; i += 1) {
117117
this.list.push(j + i);
118118
}
@@ -124,9 +124,9 @@ describe('vue-infinite-loading', () => {
124124
expect(isShow(this.$el.querySelector('.loading-default'))).to.be.true;
125125

126126
if (isComplete) {
127-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
127+
$state.complete();
128128
} else {
129-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
129+
$state.loaded();
130130
}
131131

132132
this.$nextTick(() => {
@@ -186,17 +186,17 @@ describe('vue-infinite-loading', () => {
186186
direction: 'top',
187187
},
188188
methods: {
189-
infiniteHandler: function infiniteHandler() {
189+
infiniteHandler: function infiniteHandler($state) {
190190
calledTimes += 1;
191191

192192
if (calledTimes === 1) {
193-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
193+
$state.complete();
194194
this.$nextTick(() => {
195195
// check no results text
196196
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[0])).to.be.true;
197197

198198
// reset component
199-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
199+
$state.reset();
200200
});
201201
} else if (calledTimes === 2) {
202202
// check spinner
@@ -220,10 +220,10 @@ describe('vue-infinite-loading', () => {
220220
direction: 'bottom',
221221
},
222222
methods: {
223-
infiniteHandler: function infiniteHandler() {
223+
infiniteHandler: function infiniteHandler($state) {
224224
this.list.push(this.list.length + 1);
225225
this.$nextTick(() => {
226-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
226+
$state.loaded();
227227
});
228228

229229
// wait for the container be filled up
@@ -272,15 +272,15 @@ describe('vue-infinite-loading', () => {
272272
};
273273
},
274274
methods: {
275-
infiniteHandler: function infiniteHandler() {
275+
infiniteHandler: function infiniteHandler($state) {
276276
calledTimes += 1;
277277

278278
if (calledTimes === 1) {
279279
// change view to deactivate the component
280280
this.$parent.currentView = null;
281281
this.$nextTick(() => {
282282
// trigger loaded event
283-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
283+
$state.loaded();
284284
this.$nextTick(() => {
285285
// doesnot care the loaded event when it be deactivated
286286
expect(calledTimes).to.equal(1);
@@ -343,24 +343,24 @@ describe('vue-infinite-loading', () => {
343343

344344
vm = new Vue(Object.assign({}, basicConfig, {
345345
methods: {
346-
infiniteHandler: function infiniteHandler() {
346+
infiniteHandler: function infiniteHandler($state) {
347347
if (calledTimes) {
348-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:load');
349-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
348+
$state.loaded();
349+
$state.complete();
350350
this.$nextTick(() => {
351351
// check for no-more result display
352352
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[1])).to.be.false;
353353
done();
354354
});
355355
} else {
356356
calledTimes += 1;
357-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
357+
$state.complete();
358358
this.$nextTick(() => {
359359
// check for no-result result display
360360
expect(isShow(this.$el.querySelectorAll('.infinite-status-prompt')[0])).to.be.false;
361361

362362
// reset component to check no-more status
363-
this.$refs.infiniteLoading.$emit('$InfiniteLoading:reset');
363+
$state.reset();
364364
});
365365
}
366366
},

0 commit comments

Comments
 (0)