Skip to content

Commit 7f151bf

Browse files
committed
add tests for encode (#284)
1 parent f6eb85d commit 7f151bf

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/intersection.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,20 @@ describe('intersection', () => {
113113
})
114114

115115
it('should encode a prismatic value', () => {
116-
const T = t.intersection([t.type({ a: t.string }), t.type({ b: NumberFromString })])
117-
assert.deepStrictEqual(T.encode({ a: 'a', b: 1 }), { a: 'a', b: '1' })
116+
const T1 = t.intersection([t.type({ a: t.string }), t.type({ b: NumberFromString })])
117+
assert.deepStrictEqual(T1.encode({ a: 'a', b: 1 }), { a: 'a', b: '1' })
118+
const T2 = t.intersection([t.type({ b: NumberFromString }), t.type({ a: t.string })])
119+
assert.deepStrictEqual(T2.encode({ a: 'a', b: 1 }), { a: 'a', b: '1' })
120+
const T3 = t.intersection([t.type({ b: NumberFromString }), t.type({ a: t.string }), t.type({ c: t.string })])
121+
assert.deepStrictEqual(T3.encode({ a: 'a', b: 1, c: 'c' }), { a: 'a', b: '1', c: 'c' })
122+
const T4 = t.intersection([
123+
t.type({ b: NumberFromString }),
124+
t.type({ a: t.string }),
125+
t.type({ c: NumberFromString })
126+
])
127+
assert.deepStrictEqual(T4.encode({ a: 'a', b: 1, c: 2 }), { a: 'a', b: '1', c: '2' })
128+
const T5 = t.intersection([t.type({ b: NumberFromString }), t.type({})])
129+
assert.deepStrictEqual(T5.encode({ b: 1 }), { b: '1' })
118130
})
119131

120132
it('should return the same reference while encoding', () => {

0 commit comments

Comments
 (0)