Skip to content

Add $mock.intersection to Mock module #51

@pierroberto

Description

@pierroberto

$mock module supports only unions of mocks ($mock.union).

It could be useful to have intersections of mocks as follows:

const mockA = $mock.struct({ a: $mock.string })
const mockB = $mock.struct({ b: $mock.number })

const mockC = $mock.intersection(mockA, mockB)

Something similar, currently can be achieved this way:

const mockC = pipe(
  mockA,
  $mock.bindTo('mockA'),
  $mock.apS('mockB', mockB),
  $mock.map(({ mockA, mockB }) => ({
    ...mockA,
    ...mockB,
  }))
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions