Skip to content

Commit 9e6523f

Browse files
authored
refactor: transform test/utils to ts (#1785)
1 parent f31d71c commit 9e6523f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

test/utils/Subscription.spec.js renamed to test/utils/Subscription.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { createSubscription } from '../../src/utils/Subscription'
2+
import type { Subscription } from '../../src/utils/Subscription'
3+
import type { Store } from 'redux'
24

35
describe('Subscription', () => {
4-
let notifications
5-
let store
6-
let parent
6+
let notifications: string[]
7+
let store: Store
8+
let parent: Subscription
79

810
beforeEach(() => {
911
notifications = []
10-
store = { subscribe: () => jest.fn() }
12+
store = { subscribe: () => jest.fn() } as unknown as Store
1113

1214
parent = createSubscription(store)
1315
parent.onStateChange = () => {}
1416
parent.trySubscribe()
1517
})
1618

17-
function subscribeChild(name) {
19+
function subscribeChild(name: string) {
1820
const child = createSubscription(store, parent)
1921
child.onStateChange = () => notifications.push(name)
2022
child.trySubscribe()

test/utils/isPlainObject.spec.js renamed to test/utils/isPlainObject.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import isPlainObject from '../../src/utils/isPlainObject'
22
import vm from 'vm'
3-
3+
class Test {}
44
describe('isPlainObject', () => {
55
it('returns true only if plain object', () => {
6-
function Test() {
7-
this.prop = 1
8-
}
9-
106
const sandbox = { fromAnotherRealm: false }
117
vm.runInNewContext('fromAnotherRealm = {}', sandbox)
128

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

0 commit comments

Comments
 (0)