From dacebb70d24f6514df19e173915de499be46fa7c Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 26 Dec 2018 16:44:06 +0100 Subject: [PATCH] Fixed TypeScript typings after update --- Makefile | 5 ++-- package.json | 2 +- tests/suites/unit/viewport.spec.ts | 44 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 213213a3..cfd0c1aa 100644 --- a/Makefile +++ b/Makefile @@ -73,10 +73,11 @@ clean: # Lint source files lint: node_modules - $(shell npm bin)/tslint -p tsconfig.json "{src,tests}/**/*.ts" + $(shell npm bin)/tslint -p tsconfig.json "src/**/*.ts" + $(shell npm bin)/tslint -p tests/tsconfig.json "tests/**/*.ts" # Execute integration tests -test/integration: node_modules build +test-integration: node_modules build $(shell npm bin)/karma start tests/karma.integration.conf.ts \ --single-run diff --git a/package.json b/package.json index 18b25d87..50937e10 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "clean": "make clean", "lint": "make lint", "test": "make test", - "test/integration": "make test/integration", + "test:integration": "make test-integration", "watch": "make watch" }, "dependencies": { diff --git a/tests/suites/unit/viewport.spec.ts b/tests/suites/unit/viewport.spec.ts index 9071a562..bdfb7ad8 100644 --- a/tests/suites/unit/viewport.spec.ts +++ b/tests/suites/unit/viewport.spec.ts @@ -54,7 +54,7 @@ describe("Viewport", () => { /* Hack: Internet Explorer doesn't initialize the document for an empty iframe, so we have to do it by ourselves, see https://bit.ly/2GaF6Iw */ - context.contentDocument.write("") + context.contentDocument!.write("") }) /* Detach context */ @@ -180,12 +180,12 @@ describe("Viewport", () => { it("should set horizontal offset", () => { const viewport = new Viewport(config, window) const x = chance.integer({ min: 10, max: 100 }) - context.contentDocument.body.style.width = - `${context.contentWindow.innerWidth + x}px` - context.contentDocument.body.style.height = - `${context.contentWindow.innerHeight}px` + context.contentDocument!.body.style.width = + `${context.contentWindow!.innerWidth + x}px` + context.contentDocument!.body.style.height = + `${context.contentWindow!.innerHeight}px` viewport.offset(x) - expect(viewport.context.contentWindow.pageXOffset).toEqual(x) + expect(viewport.context.contentWindow!.pageXOffset).toEqual(x) }) /* Test: should set horizontal and vertical offset */ @@ -193,13 +193,13 @@ describe("Viewport", () => { const viewport = new Viewport(config, window) const x = chance.integer({ min: 10, max: 100 }) const y = chance.integer({ min: 10, max: 100 }) - context.contentDocument.body.style.width = - `${context.contentWindow.innerWidth + x}px` - context.contentDocument.body.style.height = - `${context.contentWindow.innerHeight + y}px` + context.contentDocument!.body.style.width = + `${context.contentWindow!.innerWidth + x}px` + context.contentDocument!.body.style.height = + `${context.contentWindow!.innerHeight + y}px` viewport.offset(x, y) - expect(viewport.context.contentWindow.pageXOffset).toEqual(x) - expect(viewport.context.contentWindow.pageYOffset).toEqual(y) + expect(viewport.context.contentWindow!.pageXOffset).toEqual(x) + expect(viewport.context.contentWindow!.pageYOffset).toEqual(y) }) }) @@ -237,11 +237,11 @@ describe("Viewport", () => { /* Test: should force layout */ it("should force layout", () => { - spyOn(context.contentDocument.body, "getBoundingClientRect") + spyOn(context.contentDocument!.body, "getBoundingClientRect") const viewport = new Viewport(config, window) const width = chance.integer({ min: 100, max: 400 }) viewport.set(width) - expect(context.contentDocument.body.getBoundingClientRect) + expect(context.contentDocument!.body.getBoundingClientRect) .toHaveBeenCalled() }) @@ -291,14 +291,14 @@ describe("Viewport", () => { const viewport = new Viewport(config, window) const x = chance.integer({ min: 10, max: 100 }) const y = chance.integer({ min: 10, max: 100 }) - context.contentDocument.body.style.width = - `${context.contentWindow.innerWidth + x}` - context.contentDocument.body.style.height = - `${context.contentWindow.innerHeight + y}` + context.contentDocument!.body.style.width = + `${context.contentWindow!.innerWidth + x}` + context.contentDocument!.body.style.height = + `${context.contentWindow!.innerHeight + y}` viewport.offset(x, y) viewport.reset() - expect(viewport.context.contentWindow.pageXOffset).toEqual(0) - expect(viewport.context.contentWindow.pageYOffset).toEqual(0) + expect(viewport.context.contentWindow!.pageXOffset).toEqual(0) + expect(viewport.context.contentWindow!.pageYOffset).toEqual(0) }) /* Test: should reset width and height */ @@ -314,10 +314,10 @@ describe("Viewport", () => { /* Test: should force layout */ it("should force layout", () => { - spyOn(context.contentDocument.body, "getBoundingClientRect") + spyOn(context.contentDocument!.body, "getBoundingClientRect") const viewport = new Viewport(config, window) viewport.reset() - expect(context.contentDocument.body.getBoundingClientRect) + expect(context.contentDocument!.body.getBoundingClientRect) .toHaveBeenCalled() }) })