This package has been deprecated

Author message:

Package moved to @kentico/kontent-test-http-service-js

kentico-cloud-js-sdk-test-http-service
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Kentico Cloud JS SDK Test Http Service

npm npm npm Stack Overflow

Build Status dependency Status

Maintainability

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

This package is meant to be used as a fake Http Service when testing Kentico Cloud Delivery SDK. It is basically an implementation of IHttpService that could be used when configuring 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. Object fakeResponseConfig could contain multiple entries - entry is chosen by matching request url against the regular expression pattern provided as a key.

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

Readme

Keywords

none

Package Sidebar

Install

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

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12.3 kB

Total Files

9

Last publish

Collaborators

  • simply007