Skip to content

Commit

Permalink
test: adding test case (#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumdzeehol authored Dec 30, 2022
1 parent 3f0ec54 commit f54ccfb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/next/__tests__/moment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test('momentable is usable', () => {
moment.isMoment(item)
)
).toBe(true)
expect(momentable(0)).toBe(0)
})

test('formatMomentValue is usable', () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/reactive/src/__tests__/externals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ describe('mark operation', () => {
const obs = observable<any>(markObservable(markRaw({ aa: 111 })))
expect(isObservable(obs)).toBe(false)
})

test('function marked as observable should NOT be observable', () => {
const obs = observable<any>(markObservable(() => {}))
expect(isObservable(obs)).toBe(false)
})
})

test('recursive references tojs', () => {
Expand All @@ -82,4 +87,7 @@ test('recursive references tojs', () => {
const obs = observable<any>(obj)
obs.obs = obs
expect(toJS(obs)).toBeTruthy()

const arrObs = observable([{ aa: 1 }, { bb: 2 }, { cc: 3 }])
expect(toJS(arrObs)).toEqual([{ aa: 1 }, { bb: 2 }, { cc: 3 }])
})
25 changes: 24 additions & 1 deletion packages/shared/src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ import { stringLength } from '../string'
import { Subscribable } from '../subscribable'
import { lazyMerge, merge } from '../merge'
import { instOf } from '../instanceof'
import { isFn, isHTMLElement, isNumberLike, isReactElement } from '../checkers'
import {
isFn,
isHTMLElement,
isNumberLike,
isReactElement,
isMap,
isWeakMap,
isWeakSet,
isSet,
} from '../checkers'
import { defaults } from '../defaults'
import { applyMiddleware } from '../middleware'

Expand Down Expand Up @@ -530,6 +539,20 @@ describe('types', () => {
test('isHTMLElement', () => {
expect(isHTMLElement(document.createElement('div'))).toBeTruthy()
})
test('isMap', () => {
expect(isMap(new Map())).toBeTruthy()
})
test('isSet', () => {
expect(isSet(new Set())).toBeTruthy()
})
test('isWeakMap', () => {
expect(isWeakMap(new WeakMap())).toBeTruthy()
expect(isWeakMap(new Map())).toBeFalsy()
})
test('isWeakSet', () => {
expect(isWeakSet(new WeakSet())).toBeTruthy()
expect(isWeakSet(new Set())).toBeFalsy()
})
})

describe('merge', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/validator/src/__tests__/validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ test('max/maxItems/maxLength/minItems/minLength/min/maximum/exclusiveMaximum/min
hasError(await validate({ aa: 1, bb: 2, cc: 3 }, { maxProperties: 2 }))
noError(await validate({ aa: 1, cc: 3 }, { maxProperties: 2 }))
hasError(await validate({ aa: 1 }, { minProperties: 2 }))
noError(await validate({ aa: 1, bb: 2, cc: 3 }, { minProperties: 2 }))
noError(await validate({ aa: 1, cc: 3 }, { maxProperties: 2 }))
})

Expand Down

0 comments on commit f54ccfb

Please sign in to comment.