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

API Website #71

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_site/
.sass-cache/
8 changes: 8 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

gem 'jekyll', '3.7.2'

group :jekyll_plugins do
gem 'jekyll-seo-tag', '2.4.0'
gem 'jekyll-sitemap', '1.2.0'
end
69 changes: 69 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
colorator (1.1.0)
concurrent-ruby (1.0.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.5)
ffi (1.9.18)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (0.9.3)
concurrent-ruby (~> 1.0)
jekyll (3.7.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 0.7)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 2.0)
kramdown (~> 1.14)
liquid (~> 4.0)
mercenary (~> 0.3.3)
pathutil (~> 0.9)
rouge (>= 1.7, < 4)
safe_yaml (~> 1.0)
jekyll-sass-converter (1.5.2)
sass (~> 3.4)
jekyll-seo-tag (2.4.0)
jekyll (~> 3.3)
jekyll-sitemap (1.2.0)
jekyll (~> 3.3)
jekyll-watch (2.0.0)
listen (~> 3.0)
kramdown (1.16.2)
liquid (4.0.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
mercenary (0.3.6)
pathutil (0.16.1)
forwardable-extended (~> 2.6)
public_suffix (3.0.1)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rouge (3.1.1)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
sass (3.5.5)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)

PLATFORMS
ruby

DEPENDENCIES
jekyll (= 3.7.2)
jekyll-seo-tag (= 2.4.0)
jekyll-sitemap (= 1.2.0)

BUNDLED WITH
1.16.0
22 changes: 22 additions & 0 deletions docs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)
kanyewesternfront marked this conversation as resolved.
Show resolved Hide resolved

Copyright (c) 2014 James Newell - xhr-mock library
Copyright (c) 2016 CloudCannon - Aviator Jekyll Theme

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

137 changes: 137 additions & 0 deletions docs/_api/MockXMLHttpRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: MockXMLHttpRequest
position: 1.2
type:
description:
parameters:
- name:
content:
content_markdown: |-
MockXMLHttpRequest replaces XMLHttpRequest object.

For `xhr-mock.setup()` and `xhr-mock.teardown()` refer to XHRMock.

#### MockRequest

##### .method() : *requestMethod*
* __description:__
* Gets the request method.
* __return:__
* method: returns method as a string in one of the following: `DELETE`, `GET`, `HEAD`, `OPTIONS`, `POST`, or `PUT`.


##### .url() : *MockURL*
<!--MockURL contains url related data such as port and host. See source code for details. -->
* __description:__
* Gets the request MockURL object.
* __return:__
* MockURL object.

##### .header( *name* , *value* )
* __description:__
* Sets the request header's name and value.
* __parameters:__
* name : string
* value: string


##### .header( *name* ) : *value*
* __description:__
* Gets a request header and returns the value as a string, or `null` if no header has been set.
* __parameters:__
* name: string
* __return:__
* value: string or `null`

##### .headers() : *requestHeaders* <!--is it an object array? -->
* __description:__
* Gets the request headers and returns the value as an object.
* __return:__
* headers: object

##### .headers( *requestHeaders* ) <!--is it an object array? -->
* __description:__
* Sets the request headers.
* __parameters:__
* headers: object


##### .body() : *requestBody*
* __description:__
* Gets the request body.
* __return:__
* body: string

##### .body( *requestBody* )
* __description:__
* Sets the request body.
* __parameters:__
* body: string

#### MockResponse

##### .status() : *value*
* __description:__
* Gets the response status.
* __return:__
* value: number

##### .status( *code* )
* __description:__
* Sets the response status.
* __parameters:__
* code: number

##### .reason() : *responseReason*
* __description:__
* Gets the response reason.
* __return:__
* reason: string

##### .reason( *phrase* )
* __description:__
* Set the response reason.
* __parameters:__
* phrase: string

##### .header( *name* , *value* )
* __description:__
* Sets a response header.
* __parameters:__
* name: string
* value: string

##### .header( *name* ) : *value*
* __description:__
* Gets a response header and returns the value as a string or `null`
* __parameters:__
* name: string
* __return:__
* value: string or `null`

##### .headers() : *responseHeaders* <!--is it an object array? -->
* __description:__
* Get the response headers.
* __return:__
* headers: object

##### .headers( *responseHeaders* ) <!--is it an object array? -->
* __description:__
* Set the response headers.
* __parameters:__
* headers: object

##### .body() : *responseBody*
* __description:__
* Get the response body.
* __return:__
* body: string

##### .body( *ResponseBody* )
* __description:__
* Set the response body.
* __parameters:__
* body: string


---
17 changes: 17 additions & 0 deletions docs/_api/Mock_Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: MockFunction
position: 1.3
parameters:
- name:
content:
content_markdown: |-
#### MockFunction
* __description:__
* function object used by XHRMock object for processing requests.
* __parameters__:
* req: MockRequest object.
* res: MockResponse object.
* __return:__
* MockResponse object or `undefined`.

---
37 changes: 37 additions & 0 deletions docs/_api/Mock_URL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: MockURL
position: 1.4
parameters:
- name:
content:
content_markdown: |-
#### MockUrl

##### .protocol
* property .protocol is a **string** and not required.

##### .username
* property .username is a **string** and not required.

##### .password
* property .password is a **string** and not required.

##### .host
* property .host is a **string** and not required.

##### .path
* property .path is a **string** and not required.

##### .port
* property .port is a **number** and is not required.

##### .query
* {[name: string]: string};

##### .hash
* property .hash is a **string** and is not required.

##### .toString()
* method .toString formats and returns the url as a string

---
12 changes: 12 additions & 0 deletions docs/_api/_defaults.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title:
position:
parameters:
- name:
content:
content_markdown:
left_code_blocks:
- code_block:
title:
language:
---
80 changes: 80 additions & 0 deletions docs/_api/xhr_mock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: XHRMock
position: 1.1
type:
description:
parameters:
- name:
content:
- name:
content:
content_markdown: |-
<!-- Utility for mocking XMLHttpRequest -->
Methods used to mock the `XMLHttpRequest` object:

##### .setup()
* __description:__
* Replaces the global XMLHttpRequest object with the MockXMLHttpRequest.

##### .teardown()
* __description:__
* Restores the global `XMLHttpRequest` object to its original state.

##### .reset()
* __description:__
* Forgets all the request handlers.

##### .get( *url* \| *regex* , *mock* )
* __description:__
* Registers mock as a factory function by passing it as a parameter
to the .get function. When XHRMock receives GET request, it then uses the registered mock function to process the request. If the request is as expected, the mock returns a response. For greater detail, look at the source code.
* __parameters__:
* the url is passed into the function as either a string or a `RegExp` object.
* mock is a factory function, `MockFunction`, passed into the .get function as a parameter.

##### .post( *url* \| *regex* , *mock* )
* __description:__
* Registers mock as a factory function by passing it as a parameter
to the .post function. When XHRMock receives POST request, it then uses the registered mock function to process the request. If the request is as expected, the mock returns a response. For greater detail, look at the source code.
* __parameters__:
* the url is passed into the function as either a string or a `RegExp` object.
* mock is a factory function, `MockFunction`, passed into the .post function as a parameter.

##### .patch( *url* \| *regex* , *mock* )
* __description:__
* Registers mock as a factory function by passing it as a parameter
to the .patch function. When XHRMock receives PATCH request, it then uses the registered mock function to process the request. If the request is as expected, the mock returns a response. For greater detail, look at the source code.
* __parameters__:
* the url is passed into the function as either a string or a `RegExp` object.
* mock is a factory function, `MockFunction`, passed into the .patch function as a parameter.

##### .delete( *url* \| *regex* , *mock* )
* __description:__
* Registers mock as a factory function by passing it as a parameter
to the .delete function. When XHRMock receives DELETE request, it then uses the registered mock function to process the request. If the request is as expected, the mock returns a response. For greater detail, look at the source code.
* __parameters__:
* the url is passed into the function as either a string or a `RegExp` object.
* mock is a factory function, `MockFunction`, passed into the .delete function as a parameter.

##### .use( *method* , *url* \| *regex* , *mock* )
* __description:__
* The .use function includes a method. .use registers mock as a factory function by passing it as a parameter
to the .use function. When XHRMock receives USE request, it then uses the registered mock function to process the request. If the request is as expected, the mock returns a response. For greater detail, look at the source code.
* __parameters__:
* the method is passed as a string.
* the url is passed into the function as either a string or a `RegExp` object.
* mock is a factory function, `MockFunction`, passed into the .use function as a parameter.

##### .use( *mock* )
* __description:__
* Registers mock as a factory function to create mock responses for every request that passes through it. Url or method is not distinguished.
* __parameters__:
* mock is a factory function, `MockFunction`, passed into the .use function as a parameter.

##### .error( *fn* )
* __description:__
* Logs errors thrown by handlers.
* __parameters__:
* function

---
Loading