Try Install Learn Blog API Packages GitHub
Pages
Standard Library

Search
Entities

Test.Context

Functions

assertEqual
(
value
:
a
context
:
Test.Context(a)
)
:
Test.Context(a)

Asserts the equality of the current value of the test with the given one.

test {
  with Test.Context {
    of(5)
    |> assertEqual(5)
  }
}
assertFunctionCalled
(
entity
:
a
context
:
Test.Context(c)
)
:
Test.Context(c)

Asserts that a given spy (function) was called.

assertFunctionNotCalled
(
entity
:
a
context
:
Test.Context(c)
)
:
Test.Context(c)

Asserts that a given spy (function) was not called.

assertOf
(
value
:
b
method
:
Function(a, b)
context
:
Test.Context(a)
)
:
Test.Context(a)

Asserts if the given value equals of the returned value from the given function.

with Test.Context {
  of(5)
  |> assertOf("5", Number.toString)
}
map
(
method
:
Function(a, b)
context
:
Test.Context(a)
)
:
Test.Context(b)

Maps the given subject to a new subject.

test {
  with Test.Context {
    of(5)
    |> map(Number.toString)
  }
}
of
(
a
:
a
)
:
Test.Context(a)

Starts a test using the given value.

test {
  with Test.Context {
    of(5)
    |> assertEqual(5)
  }
}
spyOn
(
entity
:
a
)
:
a

Spies on the given entity if it's a function.

then
(
proc
:
Function(a, Promise(b, c))
context
:
Test.Context(a)
)
:
Test.Context(c)

Adds a transformation step to the test.

test {
  with Test.Context {
    of(5)
    |> then((number : Number) { Promise.resolve(number + 2) })
    |> assertEqual(7)
  }
}
timeout
(
duration
:
Number
context
:
Test.Context(a)
)
:
Test.Context(a)

Adds a timeout to the test using the given duration (in milliseconds).

test {
  with Test.Context {
    of(5)
    |> timeout(1000)
    |> assertEqual(5)
  }
}