From: Eduardo San Martin Morote Date: Wed, 22 Apr 2020 12:13:50 +0000 (+0200) Subject: test: remove warning X-Git-Tag: v4.0.0-alpha.8~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5bb66adc6e5bf971a4211fb91d10f59e63f4d8b;p=thirdparty%2Fvuejs%2Frouter.git test: remove warning --- diff --git a/__tests__/guards/guardsContext.spec.ts b/__tests__/guards/guardsContext.spec.ts index f58ba03f..9592c496 100644 --- a/__tests__/guards/guardsContext.spec.ts +++ b/__tests__/guards/guardsContext.spec.ts @@ -10,18 +10,17 @@ const component = { describe('beforeRouteLeave', () => { it('invokes with the component context', async () => { - let componentInstance: any + expect.assertions(2) const spy = jest .fn() .mockImplementationOnce(function(this: any, to, from, next) { - expect(this).toBe(componentInstance) + expect(typeof this.counter).toBe('number') next() }) const WithLeave = defineComponent({ template: `text`, - created() { - componentInstance = this - }, + // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings + data: () => ({ counter: 0 }), beforeRouteLeave: spy, })