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

jim's avatar
jim committed
3
const meun = ['/dashboard', '/userinfo', '/dashboard/name', '/userinfo/:id', '/userinfo/:id/info'];
4 5 6 7 8 9 10 11 12 13

describe('test meun match', () => {
  it('simple path', () => {
    expect(getMeunMatcheys(meun, '/dashboard')).toEqual(['/dashboard']);
  });
  it('error path', () => {
    expect(getMeunMatcheys(meun, '/dashboardname')).toEqual([]);
  });

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

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

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