@vergiss/chooks
Version:
React hooks library
34 lines (30 loc) • 956 B
JavaScript
;
import "core-js/modules/es.object.define-property";
Object.defineProperty(exports, "__esModule", {
value: true
});
var react_hooks_1 = require("@testing-library/react-hooks");
var index_1 = require("../index");
describe('useUrlParams', function () {
it('should be defined', function () {
expect(index_1.useUrlParams).toBeDefined();
});
it('should return params value', function () {
Object.defineProperty(window, "location", {
value: {
href: 'https://localhost'
},
writable: true
});
window.location.href = 'https://www.example.com?hello=world';
var hook = react_hooks_1.renderHook(function () {
return index_1.useUrlParams('hello');
});
expect(hook.result.current).toBe('world');
react_hooks_1.act(function () {
window.location.href = 'https://www.example.com?hello=coma';
hook.rerender();
});
expect(hook.result.current).toBe('coma');
});
});