Napoleon's Pixelated Mugshot

    This package has been deprecated

    Author message:

    WARNING: This project has been renamed to @vkontakte/vk-bridge-mock. Install using @vkontakte/vk-bridge-mock instead.

    @vkontakte/vk-connect-mock
    TypeScript icon, indicating that this package has built-in type declarations

    2.3.2 • Public • Published

    VK Connect Mock npm Build Status

    This library mocks VK Connect methods.

    Usage

    Install the library via yarn

    $ yarn add @vkontakte/vk-connect-mock
    

    or npm

    $ npm install @vkontakte/vk-connect-mock
    

    Use in your code instead of using vk-connect by following way:

    import vkConnect from '@vkontakte/vk-connect-mock';
    
    vkConnect.sendPromise('VKWebAppGetUserInfo', {}).then(data => {
      // Do something
    });

    Or event-based way:

    import vkConnect from '@vkontakte/vk-connect-mock';
    
    vkConnect.subscribe(e => {
      if (e.detail.type === 'VKWebAppGetUserInfoResult') {
        // Do something
      }
    });
    
    vkConnect.send('VKWebAppGetUserInfo', {});

    Please note that some methods may only receive (for example, VKWebAppUpdateConfig, VKWebAppViewHide, VKWebAppViewRestore, etc.). To obtain data from them you need to use the event-based way and callReceiveOnlyMethod()

    import vkConnect, { callReceiveOnlyMethod } from '@vkontakte/vk-connect-mock';
    
    vkConnect.subscribe(e => {
      if (e.detail.type === 'VKWebAppUpdateConfig') {
        // Do something
      }
    });
    
    // Use this function when you need to get data
    callReceiveOnlyMethod('VKWebAppUpdateConfig');

    More documentation regarding VK Connect is here.

    Using with VK Mini Apps API

    You can also use this library in conjunction with VK Mini Apps API:

    import { VKMiniAppAPI } from '@vkontakte/vk-mini-apps-api';
    import vkConnectMock from '@vkontakte/vk-connect-mock';
    
    // Creating API instance
    const api = new VKMiniAppAPI(vkConnectMock);
    
    // Using methods
    api.getUserInfo().then(userInfo => {
      // Do something with mock data of user info
    });

    Install

    npm i @vkontakte/vk-connect-mock

    DownloadsWeekly Downloads

    23

    Version

    2.3.2

    License

    MIT

    Unpacked Size

    113 kB

    Total Files

    16

    Last publish

    Collaborators