Socket
Socket
Sign inDemoInstall

@dynatrace-sdk/user-preferences

Package Overview
Dependencies
0
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dynatrace-sdk/user-preferences

An abstraction layer that provides user preferences (like theme, language etc.) from environment on which the app is run.


Version published
Weekly downloads
425
increased by32.81%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

user-preferences

An abstraction layer that provides user preferences (like theme, language etc.) from environment on which the app is run.

Unit testing app using user-preferences package with jest

Prerequisite

Add in your jest.config.js file entry with @dynatrace-sdk/user-preferences/testing setup:

setupFiles: ['@dynatrace-sdk/user-preferences/testing]

Configuring user-preferences mock

Testing package comes with some default mocked values. For example if you use getTheme() function it will return auto string value.

There is also option to provide custom values and mocked functions:

import { mockUserPreferences } from '@dynatrace-sdk/user-preferences/testing';

const getThemeMock = () => 'dark';

mockUserPreferences({
  getTheme: getThemeMock,
});

With such configuration getTheme() will return dark instead of default auto value. There will be also possibility to check for example call count of getTheme method with jest API: expect(getThemeMock.mock.calls.length).toBe(2);

All other user-preferences package functions can be mocked in same way.

FAQs

Last updated on 23 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc