UNPKG

uno-react

Version:

Common functions, and hooks for React.

33 lines (32 loc) 1.38 kB
"use strict"; /** * @jest-environment jsdom */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("@testing-library/react"); const useResolutionSwitch_1 = __importDefault(require("./useResolutionSwitch")); const mockOuterWidth = (width) => { Object.defineProperty(window, 'outerWidth', { writable: true, configurable: true, value: width, }); }; test('should get flag depends on window outerSize besides the default outerWith ', () => { mockOuterWidth(1001); const { result } = (0, react_1.renderHook)(() => (0, useResolutionSwitch_1.default)(window)); expect(result.current[0]).toBe(false); }); test('should get flag depends on window outerSize besides the default outerWith given', () => { mockOuterWidth(1001); const { result } = (0, react_1.renderHook)(() => (0, useResolutionSwitch_1.default)(window, 2020)); expect(result.current[0]).toBe(true); }); test('should get flag depends on window outerSize besides the default outerWith and timeout given ', () => { mockOuterWidth(1001); const { result } = (0, react_1.renderHook)(() => (0, useResolutionSwitch_1.default)(window, 2020, 1000)); expect(result.current[0]).toBe(true); });