5.2.4 • Published 6 years ago

@unction/streamsatisfies v5.2.4

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

@unction/streamSatisfies

Tests Stability Dependencies

(TextType | Array<A | string>) => MapperFunctionType<B, PredicateFunctionType<A | string>> => MapperFunctionType<unknown, C> => MapperFunctionType<Array<A | string>, MapperFunctionType<number, D>> => StreamType => any

Takes a marble string, an assertion, a final state callback, and a stream so that you can assert in tests how a stream will function. Each marble should be deliniated by a "---" notation. If the last marble node is a "|" then it will make sure the stream has ended. Each "marble" will be evaluated before being compared.

test("String diagram", ({equal, doesNotThrow, end}) => {
  const left = xstream.of("a")
  const right = xstream.of("b")

  streamSatisfies(
    "'b'---'a'---|"
  )(
    (given) => (expected) => equal(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("String diagram", ({equal, doesNotThrow, end}) => {
  const left = xstream.of(1)
  const right = xstream.of(2)

  streamSatisfies(
    "2---1---|"
  )(
    (given) => (expected) => equal(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("String diagram", ({same, equal, doesNotThrow, end}) => {
  const left = xstream.of({aaa: "aaa"})
  const right = xstream.of({bbb: "bbb"})

  streamSatisfies(
    "{bbb: \"bbb\"}---{aaa: \"aaa\"}---|"
  )(
    (given) => (expected) => same(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("String diagram", ({equal, doesNotThrow, end}) => {
  const left = xstream.of("a")
  const right = xstream.of("b")

  streamSatisfies(
    "'b'---'a'--=>"
  )(
    (given) => (expected) => equal(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("Array diagram", ({equal, doesNotThrow, end}) => {
  const left = xstream.of("a")
  const right = xstream.of("b")

  streamSatisfies(
    ["b", "a"]
  )(
    (given) => (expected) => equal(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("Array diagram", ({equal, doesNotThrow, end}) => {
  const left = xstream.of(1)
  const right = xstream.of(2)

  streamSatisfies(
    [2, 1]
  )(
    (given) => (expected) => equal(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})

test("Array diagram", ({same, equal, doesNotThrow, end}) => {
  const left = xstream.of({aaa: "aaa"})
  const right = xstream.of({bbb: "bbb"})

  streamSatisfies(
    [{bbb: "bbb"}, {aaa: "aaa"}]
  )(
    (given) => (expected) => same(given, expected)
  )(
    doesNotThrow
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    mergeRight(left)(right)
  )
})


test("Array diagram with error", ({equal, match, end}) => {
  const stream = xstream
    .from([
      {unction: () => true},
      {unction: () => true},
      null,
    ])
    .map((object) => object.unction())

  streamSatisfies(
    [true, true]
  )(
    (given) => (expected) => equal(given, expected)
  )(
    (exception) => {
      match(exception, TypeError)
      end()
    }
  )(
    ({length}) => (size) => {
      equal(length, size)

      end()
    }
  )(
    stream
  )
})
5.2.4

6 years ago

5.2.3

6 years ago

5.2.2

6 years ago

5.2.1

6 years ago

5.2.0

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.0

8 years ago

4.2.0

8 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.56.0

8 years ago

3.55.0

8 years ago

3.54.0

8 years ago

3.53.0

8 years ago

3.52.0

8 years ago

3.51.0

8 years ago

3.50.0

8 years ago

3.49.0

8 years ago

3.48.0

8 years ago

3.47.0

8 years ago

3.46.0

8 years ago

3.45.0

8 years ago

3.44.0

8 years ago

3.43.0

8 years ago

3.42.0

8 years ago

3.41.0

8 years ago

3.40.0

8 years ago

3.39.0

8 years ago

3.38.0

8 years ago

3.37.0

8 years ago

3.36.0

8 years ago

3.35.0

8 years ago

3.34.0

8 years ago

3.33.0

8 years ago

3.32.0

8 years ago

3.31.0

8 years ago

3.30.0

8 years ago

3.29.0

8 years ago

3.28.0

8 years ago

3.27.0

8 years ago

3.26.0

8 years ago

3.25.0

8 years ago

3.24.0

8 years ago

3.23.0

8 years ago

3.22.0

8 years ago

3.21.0

8 years ago

3.20.0

8 years ago

3.19.0

8 years ago

3.18.0

8 years ago

3.17.0

8 years ago

3.16.0

8 years ago

3.15.0

8 years ago

3.14.0

8 years ago

3.13.0

8 years ago

3.12.0

8 years ago

3.11.0

8 years ago

3.10.0

8 years ago

3.9.0

8 years ago

3.8.0

8 years ago

3.7.0

8 years ago

3.6.0

8 years ago

3.5.0

8 years ago

3.4.0

8 years ago

3.3.0

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.4.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago