Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react: check callback values after multiple value changes #1194

Merged
merged 4 commits into from
Feb 26, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion exercises/react/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"exercise": "react",
"version": "1.1.0",
"version": "1.2.0",
"comments": [
"Note that, due to the nature of this exercise,",
"the tests are specified using their cells and a series of operations to perform on the cells.",
Expand Down Expand Up @@ -314,6 +314,53 @@
},
"expected": {}
},
{
"description": "callbacks only contain the latest values",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't mind, may I bikeshed this? Given that

  1. I believe this test is most useful for demonstrating a callback being called multiple times
  2. Given my interpretation of what a callback is, they do not contain values

I would prefer a description that doesn't use the word "contain". I think I would be happy with "callbacks can be called twice", "callbacks can be called multiple times". If wanting to stress the fact that new values will be present, perhaps "callbacks can be called multiple times with new values".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I'll work on it.

"property": "react",
"input": {
"cells": [
{
"name": "input",
"type": "input",
"initial_value": 1
},
{
"name": "output",
"type": "compute",
"inputs": ["input"],
"compute_function": "inputs[0] + 1"
}
],
"operations": [
{
"type": "add_callback",
"cell": "output",
"name": "callback1"
},
{
"type": "set_value",
"cell": "input",
"value": 2
},
{
"type": "expect_callback_values",
"callback": "callback1",
"values": [3]
},
{
"type": "set_value",
"cell": "input",
"value": 3
},
{
"type": "expect_callback_values",
"callback": "callback1",
"values": [4]
}
]
},
"expected": {}
},
{
"description": "callbacks can be added and removed",
"property": "react",
Expand Down