Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: transform test/utils to ts #1785

Merged
merged 1 commit into from
Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { createSubscription } from '../../src/utils/Subscription'
import type { Subscription } from '../../src/utils/Subscription'
import type { Store } from 'redux'

describe('Subscription', () => {
let notifications
let store
let parent
let notifications: string[]
let store: Store
let parent: Subscription

beforeEach(() => {
notifications = []
store = { subscribe: () => jest.fn() }
store = { subscribe: () => jest.fn() } as unknown as Store

parent = createSubscription(store)
parent.onStateChange = () => {}
parent.trySubscribe()
})

function subscribeChild(name) {
function subscribeChild(name: string) {
const child = createSubscription(store, parent)
child.onStateChange = () => notifications.push(name)
child.trySubscribe()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import isPlainObject from '../../src/utils/isPlainObject'
import vm from 'vm'

class Test {}
describe('isPlainObject', () => {
it('returns true only if plain object', () => {
function Test() {
this.prop = 1
}

const sandbox = { fromAnotherRealm: false }
vm.runInNewContext('fromAnotherRealm = {}', sandbox)

Expand All @@ -15,6 +11,7 @@ describe('isPlainObject', () => {
expect(isPlainObject(new Date())).toBe(false)
expect(isPlainObject([1, 2, 3])).toBe(false)
expect(isPlainObject(null)).toBe(false)
//@ts-expect-error
expect(isPlainObject()).toBe(false)
expect(isPlainObject({ x: 1, y: 2 })).toBe(true)
expect(isPlainObject(Object.create(null))).toBe(true)
Expand Down
File renamed without changes.