Skip to content
代码片段 群组 项目
提交 b4bdbcae 编辑于 作者: Miguel Rincon's avatar Miguel Rincon
浏览文件

Add jest tests to visitUrl function

上级 aabe2df4
No related branches found
No related tags found
无相关合并请求
......@@ -397,6 +397,44 @@ describe('URL utility', () => {
});
});
describe('visitUrl', () => {
let originalLocation;
const mockUrl = 'http://example.com/page';
beforeAll(() => {
originalLocation = window.location;
Object.defineProperty(window, 'location', {
writable: true,
value: new URL(TEST_HOST),
});
});
afterAll(() => {
window.location = originalLocation;
});
it('navigates to a page', () => {
urlUtils.visitUrl(mockUrl);
expect(window.location.href).toBe(mockUrl);
});
it('navigates to a new page', () => {
const otherWindow = {};
Object.defineProperty(window, 'open', {
writable: true,
value: jest.fn().mockReturnValue(otherWindow),
});
urlUtils.visitUrl(mockUrl, true);
expect(otherWindow.opener).toBe(null);
expect(otherWindow.location).toBe(mockUrl);
});
});
describe('updateHistory', () => {
const state = { key: 'prop' };
const title = 'TITLE';
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册