Skip to content

Commit

Permalink
test(hal): additional tests for templated HAL links
Browse files Browse the repository at this point in the history
  • Loading branch information
tompahoward committed Jan 13, 2021
1 parent 76044e9 commit 1d1e214
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const json = await apiResource.body()
- [x] add support for simple self `_links`
- [x] add methods for getting consumed body
- [x] add support for more general `_links`
- [ ] add support for templated `_links`
- [x] add support for templated `_links`
- [ ] add support for `rels` with an array of links
- [ ] add support for curies and curied `_links`
- [ ] add support for `_links` in `_embedded` resources
Expand Down
74 changes: 73 additions & 1 deletion src/test/hal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Feature: Invoke HAL Operation
And invokes each of the "next" operations in turn 3 times
Then the last resource returned will be the last item in the list

@wip
Scenario Outline: Invoke operation - parameterised
Given a HAL resource with a "https://waychaser.io/rel/pong" operation that returns the provided "ping" "<TYPE>" parameter
When waychaser successfully loads that resource
Expand All @@ -53,3 +52,76 @@ Feature: Invoke HAL Operation
| TYPE |
| query |
| path |

Scenario Outline: Invoke operation - parameterised with extra params
Given a HAL resource with a "https://waychaser.io/rel/pong" operation that returns the provided "ping" "<TYPE>" parameter
When waychaser successfully loads that resource
And we invoke the "https://waychaser.io/rel/pong" operation with the input
| ping | pong |
| other | notUsed |
Then resource returned will contain only
| ping | pong |

Examples:
| TYPE |
| query |
| path |

Scenario Outline: Invoke operation - multiple parameters of same type
Given a HAL resource with a "https://waychaser.io/rel/pong" operation with the "GET" method that returns the following provided parameters
| NAME | TYPE |
| alpha | <TYPE> |
| bravo | <TYPE> |
| charlie | <TYPE> |
When waychaser successfully loads that resource
And we invoke the "https://waychaser.io/rel/pong" operation with the input
| alpha | one |
| bravo | two |
| charlie | three |
Then resource returned will contain those values

Examples:
| TYPE |
| query |
| path |

Scenario Outline: Invoke operation - multiple parameters of same type with extra params
Given a HAL resource with a "https://waychaser.io/rel/pong" operation with the "GET" method that returns the following provided parameters
| NAME | TYPE |
| alpha | <TYPE> |
| bravo | <TYPE> |
| charlie | <TYPE> |
When waychaser successfully loads that resource
And we invoke the "https://waychaser.io/rel/pong" operation with the input
| bravo | two |
| other | notUsed |
| charlie | three |
| alpha | one |
Then resource returned will contain only
| alpha | one |
| bravo | two |
| charlie | three |

Examples:
| TYPE |
| query |
| path |

@wip
Scenario Outline: Invoke operation - multiple parameters of different type
Given a HAL resource with a "https://waychaser.io/rel/pong" operation with the "GET" method that returns the following provided parameters
| NAME | TYPE |
| alpha | <TYPE1> |
| bravo | <TYPE2> |
| charlie | <TYPE1> |
When waychaser successfully loads that resource
And we invoke the "https://waychaser.io/rel/pong" operation with the input
| alpha | one |
| bravo | two |
| charlie | three |
Then resource returned will contain those values

Examples:
| TYPE1 | TYPE2 |
| query | path |
| path | query |
15 changes: 15 additions & 0 deletions src/test/resource.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,21 @@ Given(
}
)

Given(
'a HAL resource with a {string} operation with the {string} method that returns the following provided parameters',
async function (relationship, method, dataTable) {
this.currentResourceRoute = await createRandomDynamicResourceRoute.bind(
this
)(
relationship,
method,
dataTable.hashes(),
undefined,
'application/hal+json'
)
}
)

Given(
'a resource with a {string} operation with the {string} method that returns the following {string} provided parameters and the content type',
async function (relationship, method, contentType, dataTable) {
Expand Down

0 comments on commit 1d1e214

Please sign in to comment.