SilderMenu.test.js 818 Bytes
Newer Older
jim's avatar
jim committed
1
import { getMeunMatcheys } from './BaseMeun';
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

const meun = [
  '/dashboard',
  '/userinfo',
  '/dashboard/name',
  '/userinfo/:id',
  '/userinfo/:id/info',
];

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

  it('Secondary path', () => {
    expect(getMeunMatcheys(meun, '/dashboard/name')).toEqual([
      '/dashboard/name',
    ]);
  });

  it('Parameter path', () => {
    expect(getMeunMatcheys(meun, '/userinfo/2144')).toEqual([
      '/userinfo/:id',
    ]);
  });

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