From 8945bb5da68f08a9a7acccd664dc0306742c2b55 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 7 Jul 2017 16:51:06 +0800 Subject: [PATCH] Add test case for menu --- components/menu/__tests__/index.test.js | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/components/menu/__tests__/index.test.js b/components/menu/__tests__/index.test.js index 3331ec21fc..d9c3ed2972 100644 --- a/components/menu/__tests__/index.test.js +++ b/components/menu/__tests__/index.test.js @@ -127,4 +127,52 @@ describe('Menu', () => { wrapper.setProps({ mode: 'inline' }); expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true); }); + + it('should open submenu when click submenu title (inline)', () => { + const wrapper = mount( + + submenu1}> + Option 1 + Option 2 + + menu2 + + ); + expect(wrapper.find('.ant-menu-sub').length).toBe(0); + wrapper.find('#submenu').simulate('click'); + expect(wrapper.find('.ant-menu-sub').length).toBe(1); + expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true); + }); + + it('should open submenu when hover submenu title (vertical)', async () => { + const wrapper = mount( + + submenu1}> + Option 1 + Option 2 + + menu2 + + ); + expect(wrapper.find('.ant-menu-sub').length).toBe(0); + wrapper.find('.ant-menu-submenu-title').simulate('mouseenter'); + expect(wrapper.find('.ant-menu-sub').length).toBe(1); + expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true); + }); + + it('should open submenu when hover submenu title (horizontal)', async () => { + const wrapper = mount( + + submenu1}> + Option 1 + Option 2 + + menu2 + + ); + expect(wrapper.find('.ant-menu-sub').length).toBe(0); + wrapper.find('.ant-menu-submenu-title').simulate('mouseenter'); + expect(wrapper.find('.ant-menu-sub').length).toBe(1); + expect(wrapper.find('.ant-menu-sub').at(0).hasClass('ant-menu-hidden')).not.toBe(true); + }); });