From d5bb66adc6e5bf971a4211fb91d10f59e63f4d8b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 22 Apr 2020 14:13:50 +0200 Subject: [PATCH] test: remove warning --- __tests__/guards/guardsContext.spec.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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, }) -- 2.39.5