Skip to content
This package is meant to be used as a fake Http Service when testing Kentico Cloud Delivery SDK (js/ts). It is basically an implementation of IHttpService.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github add tamplates + readme reafctor Feb 8, 2019
.vscode
src
.editorconfig
.gitignore
.npmignore
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.md
README.md
package.json
tsconfig.build.json
tsconfig.json
tslint.json
yarn.lock

README.md

Kentico Cloud JS SDK Test HTTP Service

npm npm npm Stack Overflow

Build Status dependency Status

Maintainability

This is the source for the npm package called kentico-cloud-js-sdk-test-http-service.

This package is meant to be used as a fake HTTP Service when testing the Kentico Cloud Delivery SDK. It is basically an implementation of IHttpService that could be used when configuring the Delivery client.

Install

With npm:

npm install kentico-cloud-js-sdk-test-http-service

Or with yarn

yarn add kentico-cloud-js-sdk-test-http-service

Usage

This it the example of the usage. The object fakeResponseConfig could contain multiple entries. An entry is chosen by matching the request url against the regular expression pattern provided as a key.

The full example is in delivery client tests.

const fakeResponseConfig = new Map<RegExp, FakeResponseConfig>()
fakeResponseConfig.set(
  // THIS IS A PATTERN THAT WOULD BE USED FOR MATCHING WHEN 
  // QUERYING THE DATA AGAINST THE URL
  /https:\/\/deliver.kenticocloud.com\/.*\/items/,  
  {
    // HERE YOU PROVIDE YOUR FAKE RESPONSE FOR THIS PATTERN
    fakeResponseJson: { 
      items: [
        {
          system: {...},
          elements: {...}
        }
      ],
      pagination: {
        continuation_token: null,
        next_page: null
      }
    },
    throwCloudError: false
  });

const fakeHttpService = 
 new KenticoCloudJsSdkTestHttpService(fakeResponseConfig);

const deliveryClientConfig = {
      projectId: 'dummyProject',
      typeResolvers: [],
      httpService: fakeHttpService
    };

const client = new DeliveryClient(deliveryClientConfig)

Author

Ondřej Chrastina — @Simply007

Thanks

Analytics

You can’t perform that action at this time.