palmservicebridge-mock

    1.0.3 • Public • Published

    palmservicebridge-mock

    Utility for mocking PalmServiceBridge.

    Tested with NodeJS and karma

    PalmServiceBridge is for webOS

    Installation

    If you are using a bundler like Webpack or Browserify then install palmservicebridge-mock using yarn or npm:

    npm install --save-dev palmservicebridge-mock

    Now import palmservicebridge-mock and start using it in your scripts:

    import palmServiceBridgeMock from 'palmservicebridge-mock';

    Usage

    Example code to get palmServiceBridges

    it('+++ AI Nudge click should change settings service', () => {
        const switchItem = wrapper.find({id: 'aiNudge'}).filter('SwitchItem');
        switchItem.props().onToggle({selected: true});
        const palmServiceBridges = palmServiceBridgeMock.getPalmServiceBridges();
        expect(palmServiceBridges[palmServiceBridges.length - 1].uri).to.equal('luna://com.webos.settingsservice/setSystemSettings');
        expect(palmServiceBridges[palmServiceBridges.length - 1].params).to.equal('{"category":"general","settings":{"aiNudge":"on"}}');
    });

    Example code to get palmServiceBridges

    it('+++ Reset to Initial Settings click should call proper luna api when parentalControl is true', () => {
        palmServiceBridgeMock.send('luna://com.webos.notification/createPincodePrompt', {
                matched: true
        });
        const settingsItem = wrapper.find({id: 'resetSettings'}).filter('SettingsItem');
        settingsItem.props().onClick({type: ''});
        const palmServiceBridges = palmServiceBridgeMock.getPalmServiceBridges();
        expect(palmServiceBridges[palmServiceBridges.length - 1].uri).to.equal('luna://com.webos.notification/createPincodePrompt');
        expect(palmServiceBridges[palmServiceBridges.length - 1].params).to.equal( '{"promptType":"parental"}');
    });

    API

    palmservicebridge-mock

    .setup()

    Replace the global PalmServiceBridges object with the MockPalmServiceBridges.

    .teardown()

    Restore the global PalmServiceBridges object to its original state.

    .reset()

    Forget all the request handlers.

    .send(api, mock)

    Register a factory function to create mock responses for each SEND request to a specific API.

    Install

    npm i palmservicebridge-mock

    DownloadsWeekly Downloads

    136

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    6.25 kB

    Total Files

    4

    Last publish

    Collaborators

    • nanbean