Skip to content

Commit

Permalink
chore: upgrade typescript and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanguy Antoine committed May 29, 2020
1 parent 261e7e1 commit 92e04fe
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 386 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"editor.formatOnSave": true,
"javascript.format.enable": false,
"typescript.tsdk": "node_modules/typescript/lib",
}
1 change: 1 addition & 0 deletions config/config.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"ts-jest": "^23.10.5",
"ts-loader": "^5.3.3",
"ts-node": "^8.10.1",
"typescript": "^3.2.2"
"typescript": "^3.9.3"
},
"jest": {
"collectCoverageFrom": [
Expand All @@ -97,7 +97,7 @@
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(.*/views/.*)((test|spec))\\.(jsx?|tsx?)$",
"testRegex": "(.*/clients/.*)((test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
Expand All @@ -123,13 +123,14 @@
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testRegex": "(.*/src/lib/.*)(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"modulePathIgnorePatterns": [
"<rootDir>/dist/"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/views/"
"/views/",
"legacy"
],
"moduleFileExtensions": [
"ts",
Expand Down
64 changes: 0 additions & 64 deletions src/clients/javascript/test/connect.test.js

This file was deleted.

76 changes: 76 additions & 0 deletions src/clients/javascript/test/connect.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import Pizzly from '../src/index'

describe('Connect', () => {
beforeAll(() => {
window.addEventListener = jest.fn()
// @ts-ignore
window.open = jest.fn(() => {
return { closed: false }
})
})

const publishableKey = 'foo'
const integration = 'github'

function setup() {
return new Pizzly(publishableKey)
}

describe('connect', () => {
it('is a function', () => {
const pizzly = setup()

expect(pizzly.connect).toBeInstanceOf(Function)
})

it('accepts an integration argument', () => {
const pizzly = setup()

expect(pizzly.connect(integration)).toBeInstanceOf(Promise)
})

it('must have an integration argument', () => {
const pizzly = setup()
expect(() => {
// @ts-expect-error
return pizzly.connect()
}).toThrowError()
})

it('accepts an (optional) options argument', () => {
const pizzly = setup()

expect(pizzly.connect(integration, {})).toBeInstanceOf(Promise)
})
})

it('opens a popup (window modal)', () => {
const pizzly = setup()
expect.assertions(1)

pizzly.connect(integration).catch()

expect(window.open).toHaveBeenCalled()
})

// More tests to add on that:
// - it opens a popup with this URL
// - it opens a popup with this size
// - it opens a popup with this position

it('listens to message', () => {
const pizzly = setup()
expect.assertions(1)

pizzly.connect(integration).catch()

expect(window.addEventListener).toHaveBeenCalledWith('message', expect.any(Function), false)
})

describe('Return values', () => {
// More test to add here:
// it returns a promise
// it returns an object on promise.resolve
// it returns an error on promise.reject
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Pizzly = require('../dist/index.umd.js')
import Pizzly from '../src/index'

describe('Pizzly class', () => {
const publishableKey = 'foo'
Expand All @@ -13,6 +13,7 @@ describe('Pizzly class', () => {

it('accepts no arguments', () => {
expect(() => {
// @ts-expect-error
new Pizzly()
}).not.toThrowError()
})
Expand All @@ -31,6 +32,7 @@ describe('Pizzly class', () => {

it('accepts invalid options', () => {
expect(() => {
// @ts-expect-error
new Pizzly(publishableKey, invalidOptions)
}).toBeInstanceOf(Function)
})
Expand Down
22 changes: 0 additions & 22 deletions src/legacy/auth/v3/strategies/__snapshots__/api-key.test.ts.snap

This file was deleted.

22 changes: 0 additions & 22 deletions src/legacy/auth/v3/strategies/__snapshots__/basic.test.ts.snap

This file was deleted.

44 changes: 0 additions & 44 deletions src/legacy/functions/__snapshots__/lambda-request.test.ts.snap

This file was deleted.

Loading

0 comments on commit 92e04fe

Please sign in to comment.