SilderMenu.test.js 773 Bytes
Newer Older
1
import { getMeunMatchKeys } from './SiderMenu';
2

jim's avatar
jim committed
3
const meun = ['/dashboard', '/userinfo', '/dashboard/name', '/userinfo/:id', '/userinfo/:id/info'];
4 5 6

describe('test meun match', () => {
  it('simple path', () => {
7
    expect(getMeunMatchKeys(meun, '/dashboard')).toEqual(['/dashboard']);
8 9
  });
  it('error path', () => {
10
    expect(getMeunMatchKeys(meun, '/dashboardname')).toEqual([]);
11 12 13
  });

  it('Secondary path', () => {
14
    expect(getMeunMatchKeys(meun, '/dashboard/name')).toEqual(['/dashboard/name']);
15 16 17
  });

  it('Parameter path', () => {
18
    expect(getMeunMatchKeys(meun, '/userinfo/2144')).toEqual(['/userinfo/:id']);
19 20 21
  });

  it('three parameter path', () => {
22
    expect(getMeunMatchKeys(meun, '/userinfo/2144/info')).toEqual(['/userinfo/:id/info']);
23 24
  });
});