Skip to content

Commit

Permalink
refactor: transform test/utils to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
myNameIsDu committed Aug 1, 2021
1 parent f31d71c commit 7dafc33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
@@ -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
@@ -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.

0 comments on commit 7dafc33

Please sign in to comment.