Skip to content

Commit

Permalink
Merge pull request #47 from facile-it/AddedMorePossibleArgumentToMock…
Browse files Browse the repository at this point in the history
…Union

Changed overloads on $mock.union function
  • Loading branch information
Negator1989 authored Sep 22, 2022
2 parents 054339b + 83716da commit ea52ffe
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add `prefix` to `string` module.
- Add `suffix` to `string` module.

### Changed

- Changed overloads of `$mock.union` function.

### Fixed

- Update `yarn.lock` in order to fix "typescript (18.x)" and "jest (18.x)" jobs in CI.
Expand Down
18 changes: 17 additions & 1 deletion src/Mock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,23 @@ describe('Mock', () => {
})

describe('union', () => {
const M = union(boolean, number(), string)
const M = union(
boolean,
number(),
string,
boolean,
number(),
string,
boolean,
number(),
string,
boolean,
number(),
string,
boolean,
number(),
string,
)

it('should return a random value of one of the specified types', () => {
for (let i = 0; i < 10; i++) {
Expand Down
90 changes: 85 additions & 5 deletions src/Mock.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { PartialDeep } from '.'
import { curry, recurse, run } from './function'
import * as $St from './struct'
import * as $t from './Type'
import * as $Y from './Yield'
import * as Appli from 'fp-ts/Applicative'
import * as _Apply from 'fp-ts/Apply'
import * as C from 'fp-ts/Chain'
Expand All @@ -24,11 +29,6 @@ import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
import * as RR from 'fp-ts/ReadonlyRecord'
import * as Se from 'fp-ts/Semigroup'
import * as t from 'io-ts'
import { PartialDeep } from '.'
import { curry, recurse, run } from './function'
import * as $St from './struct'
import * as $t from './Type'
import * as $Y from './Yield'

export const URI = 'Mock'

Expand Down Expand Up @@ -209,6 +209,86 @@ export const partial = <A>(
struct,
) as any

export function union<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
a: Mock<A>,
b: Mock<B>,
c: Mock<C>,
d: Mock<D>,
e: Mock<E>,
f: Mock<F>,
g: Mock<G>,
h: Mock<H>,
i: Mock<I>,
j: Mock<J>,
k: Mock<K>,
l: Mock<L>,
m: Mock<M>,
n: Mock<N>,
o: Mock<O>,
): Mock<A | B | C | D | E | F | G | H | I | J | K | L | M | N | O>

export function union<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
a: Mock<A>,
b: Mock<B>,
c: Mock<C>,
d: Mock<D>,
e: Mock<E>,
f: Mock<F>,
g: Mock<G>,
h: Mock<H>,
i: Mock<I>,
j: Mock<J>,
k: Mock<K>,
l: Mock<L>,
m: Mock<M>,
n: Mock<N>,
): Mock<A | B | C | D | E | F | G | H | I | J | K | L | M | N>

export function union<A, B, C, D, E, F, G, H, I, J, K, L, M>(
a: Mock<A>,
b: Mock<B>,
c: Mock<C>,
d: Mock<D>,
e: Mock<E>,
f: Mock<F>,
g: Mock<G>,
h: Mock<H>,
i: Mock<I>,
j: Mock<J>,
k: Mock<K>,
l: Mock<L>,
m: Mock<M>,
): Mock<A | B | C | D | E | F | G | H | I | J | K | L | M>

export function union<A, B, C, D, E, F, G, H, I, J, K, L>(
a: Mock<A>,
b: Mock<B>,
c: Mock<C>,
d: Mock<D>,
e: Mock<E>,
f: Mock<F>,
g: Mock<G>,
h: Mock<H>,
i: Mock<I>,
j: Mock<J>,
k: Mock<K>,
l: Mock<L>,
): Mock<A | B | C | D | E | F | G | H | I | J | K | L>

export function union<A, B, C, D, E, F, G, H, I, J, K>(
a: Mock<A>,
b: Mock<B>,
c: Mock<C>,
d: Mock<D>,
e: Mock<E>,
f: Mock<F>,
g: Mock<G>,
h: Mock<H>,
i: Mock<I>,
j: Mock<J>,
k: Mock<K>,
): Mock<A | B | C | D | E | F | G | H | I | J | K>

export function union<A, B, C, D, E, F, G, H, I, J>(
a: Mock<A>,
b: Mock<B>,
Expand Down

0 comments on commit ea52ffe

Please sign in to comment.