Skip to content

Commit

Permalink
Use example tag in JSDoc (#13745)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored and youknowriad committed Mar 6, 2019
1 parent d043910 commit 978e8f7
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions packages/e2e-test-utils/src/mocks/set-up-response-mocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ let requestMocks = [];

/**
* Sets up mock checks and responses. Accepts a list of mock settings with the following properties:
* - match: function to check if a request should be mocked.
* - onRequestMatch: async function to respond to the request.
*
* Example:
* const MOCK_RESPONSES = [
* {
* match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/' ),
* onRequestMatch: JSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ),
* },
* {
* match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' ),
* onRequestMatch: JSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ),
* }
* ];
* setUpResponseMocking( MOCK_RESPONSES );
* - `match`: function to check if a request should be mocked.
* - `onRequestMatch`: async function to respond to the request.
*
* @example
*
* ```js
* const MOCK_RESPONSES = [
* {
* match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/' ),
* onRequestMatch: JSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ),
* },
* {
* match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/block-api/attributes/' ),
* onRequestMatch: JSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ),
* }
* ];
* setUpResponseMocking( MOCK_RESPONSES );
* ```
*
* If none of the mock settings match the request, the request is allowed to continue.
*
Expand Down

0 comments on commit 978e8f7

Please sign in to comment.