Try Install Learn Blog API Packages GitHub
Pages
core

Search
Entities

Test.Context

Functions

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

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

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

Asserts that a given spy (function) was called.

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

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

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

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

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

Maps the given subject to a new subject.

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

Starts a test using the given value.

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

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

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

Adds a transformation step to the test.

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

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

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