Skip to content

Commit

Permalink
Fixed TypeScript typings after update
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Dec 26, 2018
1 parent b6d2c63 commit dacebb7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
44 changes: 22 additions & 22 deletions tests/suites/unit/viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("<body></body>")
context.contentDocument!.write("<body></body>")
})

/* Detach context */
Expand Down Expand Up @@ -180,26 +180,26 @@ 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 */
it("should set horizontal and vertical offset", () => {
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)
})
})

Expand Down Expand Up @@ -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()
})

Expand Down Expand Up @@ -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 */
Expand All @@ -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()
})
})
Expand Down

0 comments on commit dacebb7

Please sign in to comment.