4 buildRouteObjWithFilters,
6 } from 'utils/Routes.js';
9 } from 'utils/Crypto.js';
11 describe('Routes', () => {
12 it('build route with hash', () => {
13 const expectedResult = {
15 hashId: 'someCrazyHashHere'
18 const result = buildRouteObjWithHash(expectedResult.route, expectedResult.hashId);
20 expect(JSON.stringify(result)).toBe(JSON.stringify(expectedResult));
23 it('decrypt params for view', () => {
24 const stringToEncrypt = 'someCrazyStringHere';
25 const encryptedString = encrypt(stringToEncrypt);
26 const result = decryptParamsForView(encryptedString);
28 expect(JSON.stringify(result)).toBe(JSON.stringify({}));
31 it('decrypt params for view with obj', () => {
32 const objToEncrypt = [{id: 'someCrazyParamHere'}, {id: 'anotherCrazyParam'}];
33 const encryptedObj = encrypt(JSON.stringify(objToEncrypt));
34 const result = decryptParamsForView(encryptedObj);
36 expect(JSON.stringify(result)).toBe(JSON.stringify(objToEncrypt));
39 it('build routes with filters', () => {
40 const objToEncrypt = [{id: 'someCrazyParamHere'}, {id: 'anotherCrazyParam'}];
41 const encryptedObj = encrypt(JSON.stringify(objToEncrypt));
42 const result = decryptParamsForView(encryptedObj);
44 expect(JSON.stringify(result)).toBe(JSON.stringify(objToEncrypt));
48 filter3: 'anotherValue'
50 const routePath = '/vnfSearch';
51 const expectedResults = {
64 filterValue: 'anotherValue'
69 const routeWithFilters = buildRouteObjWithFilters(routePath, filterObj);
71 expect(JSON.stringify(routeWithFilters)).toBe(JSON.stringify(expectedResults));
74 it('change URL address for well known paths', () => {
84 filterValue: undefined
88 filterValue: 'anotherValue'
96 'filter3=anotherValue'
98 const toGo = '/' + pathObj.route + '/' + filterList.toString();
99 const expectedResult = [
102 lastRoute: pathObj.route
106 changeUrlAddress(pathObj, historyObj);
108 expect(JSON.stringify(historyObj)).toBe(JSON.stringify(expectedResult));
111 it('change URL address for well known paths with hash id', () => {
114 hashId: 'someCrazyHashIdHere'
117 const toGo = '/' + pathObj.route + '/' + pathObj.hashId;
118 const expectedResult = [
121 lastRoute: pathObj.route
125 changeUrlAddress(pathObj, historyObj);
127 expect(JSON.stringify(historyObj)).toBe(JSON.stringify(expectedResult));