8. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/12/2019 4:22:12 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

8.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\CC CC SEOC 1.7\seocui-release1.7@bb33f84589b\cc_seoc_ui\src\components\user-management UserManagement.spec.js Tue Jan 29 13:55:38 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\Community Care Care Coordination SEOC 1.7-redacted\CC CC SEOC 1.7\seocui-release1.7@bb33f84589b\cc_seoc_ui\src\components\user-management UserManagement.spec.js Tue Mar 12 21:09:33 2019 UTC

8.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 37 2764
Changed 36 106
Inserted 0 0
Removed 0 0

8.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

8.4 Active regular expressions

No regular expressions were active.

8.5 Comparison detail

  1   import Rea ct from 'r eact';
  2   import { m ount } fro m 'enzyme' ;
  3   import { P rovider }  from 'reac t-redux';
  4   import { C onnectedRo uter } fro m 'react-r outer-redu x';
  5   import { c reateMemor yHistory }  from 'his tory';
  6   import { R edirect }  from 'reac t-router-d om';
  7  
  8   import con figureStor e, { histo ry } from  '../../sto re/configu reStore';
  9  
  10   import req uest from  '../../uti ls/request ';
  11   jest.mock( '../../uti ls/request ');
  12  
  13   import { u pdatePageT itle } fro m '../../u tils/pageU tils';
  14   jest.mock( '../../uti ls/pageUti ls');
  15  
  16   import { e xtend } fr om '../../ utils/obje ctUtils';
  17   import { g enerateAle rtData } f rom '../.. /utils/mes sageUtils' ;
  18   import { r oleFilterT ypes } fro m '../../c onstants/f ilterTypes ';
  19   import { P UBLISHER,  ADMINISTRA TOR } from  '../../co nstants/us erRoles';
  20   import { s howModal }  from '../ ../actions ';
  21  
  22   import Ale rt from '. ./alert/Al ert';
  23   import Use rManagemen t from './ UserManage ment';
  24  
  25   describe(' UserManage ment compo nent', ()  => {
  26     const us ers = [
  27       {
  28         id:  '1',
  29           userName:  ' R E DACT E D ',
  30         role : 'VIEWER' ,
  31           vaNetworkI d: ' R E DA C T E D ',
  32           domain: ' RE D ACT E D '
  33       },
  34       {
  35         id:  '2',
  36           userName:  ' RED A C T ED ',
  37         role : 'AUTHOR' ,
  38           vaNetworkI d: ' R E D A C T
E D ',
  39           domain: ' RE D ACT E D '
  40       },
  41       {
  42         id:  '3',
  43           userName:  '
R EDACTED ',
  44         role : 'PUBLISH ER',
  45           vaNetworkI d: ' R E DA C T E D ',
  46           domain: ' RE D ACT E D '
  47       },
  48       {
  49         id:  '4',
  50           userName:  ' RED A CTED ',
  51         role : 'ADMINIS TRATOR',
  52           vaNetworkI d: ' R E DA C T E D ',
  53           domain: ' RE D ACT E D '
  54       },
  55       {
  56         id:  '5',
  57           userName:  ' R E DA C T E D ',
  58         role : 'VIEWER' ,
  59           vaNetworkI d: '
RE
D ACT E D ',
  60           domain: ' RE D ACT E D '
  61       },
  62       {
  63         id:  '6',
  64           userName:  ' R E D A CTED ',
  65         role : 'VIEWER' ,
  66           vaNetworkI d: '
R
E DACT E D ',
  67           domain: ' RE D ACT E D '
  68       }
  69     ];
  70  
  71     let focu s;
  72     let scro llIntoView ;
  73  
  74     let stor e;
  75  
  76     let wrap per;
  77     let inst ance;
  78     let layo ut;
  79     let layo utInstance ;
  80  
  81     const cu rrentUser  = 'SEOCADM INPRIVILEG ESUSER';
  82  
  83     const mo untWrapper  = () => {
  84       wrappe r = mount(
  85         <Pro vider stor e={store}>
  86           <C onnectedRo uter histo ry={ creat eMemoryHis tory('/')  }>
  87              <UserManag ement />
  88           </ ConnectedR outer>
  89         </Pr ovider>
  90       );
  91  
  92       instan ce = wrapp er.find('U serManagem ent').inst ance();
  93       layout  = wrapper .find('Lay out');
  94       layout Instance =  layout.in stance();
  95     };
  96  
  97     beforeEa ch(() => {
  98       store  = configur eStore({
  99         sess ion: {
  100           ro le: ADMINI STRATOR,
  101           us er: curren tUser
  102         },
  103         user s
  104       });
  105  
  106       focus  = jest.fn( );
  107       scroll IntoView =  jest.fn() ;
  108  
  109       window .innerHeig ht = 0;
  110  
  111       docume nt.querySe lector = j est.fn().m ockImpleme ntation(()  => ({
  112         clie ntWidth: 0 ,
  113         offs etHeight:  0,
  114         offs etWidth: 0 ,
  115         focu s,
  116         scro llIntoView
  117       }));
  118  
  119       mountW rapper();
  120     });
  121  
  122     describe ('initial  state', ()  => {
  123       it('sh ould set d efaults in  the state ', () => {
  124         cons t actual =  instance. state;
  125         cons t expected  = {
  126           co ntent: '',
  127           us er: instan ce.getEmpt yUser(),
  128           se lected: nu ll,
  129           fi lterBy: 'A LL',
  130           se archBy: '' ,
  131           sh owEdit: fa lse
  132         };
  133  
  134         expe ct(actual) .toEqual(e xpected);
  135       });
  136     });
  137  
  138     describe ('getEmpty User', ()  => {
  139       it('sh ould retur n an objec t with def ault value s', () =>  {
  140         cons t actual =  instance. getEmptyUs er();
  141         cons t expected  = {
  142           us erName: '' ,
  143           ro le: 'VIEWE R',
  144           va NetworkId:  '',
  145           pr evNetworkI d: '',
  146           do main: ''
  147         };
  148  
  149         expe ct(actual) .toEqual(e xpected);
  150       });
  151     });
  152  
  153     describe ('role-bas ed permiss ions', ()  => {
  154       descri be('ADMINI STRATOR',  () => {
  155         befo reEach(()  => {
  156           re quest.mock Reset();
  157  
  158           fo cus = jest .fn();
  159  
  160           do cument.que rySelector  = jest.fn ().mockImp lementatio n(() => ({
  161              clientWidt h: 0,
  162              offsetHeig ht: 0,
  163              offsetWidt h: 0,
  164              focus
  165           }) );
  166  
  167           st ore = conf igureStore ({
  168              session: {
  169                role: AD MINISTRATO R,
  170                user: cu rrentUser
  171              }
  172           }) ;
  173           mo untWrapper ();
  174         });
  175  
  176         it(' should not  redirect  the user t o the land ing page',  () => {
  177           co nst actual  = instanc e.state.co ntent;
  178           co nst expect ed = '';
  179     
  180           ex pect(actua l).toEqual (expected) ;
  181         });
  182  
  183         it(' should fet ch the lis t of users ', () => {
  184           ex pect(reque st).toBeCa lled();
  185           ex pect(reque st.mock.ca lls[0][0]. endpoint). toEqual('u sers');
  186         });
  187  
  188         it(' should foc us on the  header', ( ) => {
  189           ex pect(docum ent.queryS elector).t oBeCalledW ith('.subh eading-tit le');
  190           ex pect(focus ).toBeCall ed();
  191         });
  192       });
  193  
  194       descri be('Non-AD MINISTRATO R', () =>  {
  195         befo reEach(()  => {
  196           re quest.mock Reset();
  197  
  198           fo cus = jest .fn();
  199  
  200           do cument.que rySelector  = jest.fn ().mockImp lementatio n(() => ({
  201              clientWidt h: 0,
  202              offsetHeig ht: 0,
  203              offsetWidt h: 0,
  204              focus
  205           }) );
  206  
  207           st ore = conf igureStore ({
  208              session: {
  209                role: PU BLISHER,
  210                user: cu rrentUser
  211              }
  212           }) ;
  213           mo untWrapper ();
  214         });
  215  
  216         it(' should red irect the  user to th e landing  page', ()  => {
  217           co nst actual  = instanc e.state.co ntent;
  218           co nst expect ed = (<Red irect to=" /" />);
  219     
  220           ex pect(actua l).toEqual (expected) ;
  221         });
  222  
  223         it(' should not  fetch the  list of u sers', ()  => {
  224           ex pect(reque st).not.to BeCalled() ;
  225         });
  226  
  227         it(' should not  focus on  the header ', () => {
  228           ex pect(docum ent.queryS elector).n ot.toBeCal ledWith('. subheading -title');
  229         });
  230       });
  231     });
  232  
  233     describe ('updatePa geTitle',  () => {
  234       it('sh ould updat e the page  title to  User Manag ement', ()  => {
  235         requ est.mockRe set();
  236         upda tePageTitl e.mockRese t();
  237  
  238         focu s = jest.f n();
  239  
  240         docu ment.query Selector =  jest.fn() .mockImple mentation( () => ({
  241           cl ientWidth:  0,
  242           of fsetHeight : 0,
  243           of fsetWidth:  0,
  244           fo cus
  245         }));
  246  
  247         moun tWrapper() ;
  248  
  249         expe ct(updateP ageTitle). toBeCalled With('User  Managemen t');
  250       });
  251     });
  252  
  253     describe ('updateFi lterBy', ( ) => {
  254       it('sh ould updat e filterBy  in the st ate', () = > {
  255         inst ance.updat eFilterBy( 'new filte r');
  256  
  257         cons t actual =  instance. state.filt erBy;
  258         cons t expected  = 'new fi lter';
  259  
  260         expe ct(actual) .toEqual(e xpected);
  261       });
  262     });
  263  
  264     describe ('updateSe archBy', ( ) => {
  265       it('sh ould updat e searchBy  in the st ate', () = > {
  266         inst ance.updat eSearchBy( 'new searc h');
  267  
  268         cons t actual =  instance. state.sear chBy;
  269         cons t expected  = 'new se arch';
  270  
  271         expe ct(actual) .toEqual(e xpected);
  272       });
  273     });
  274  
  275     describe ('getUsers List', ()  => {
  276       it('sh ould show  all users  by default ', () => {
  277         inst ance.setSt ate({
  278           fi lterBy: 'A LL',
  279           se archBy: ''
  280         });
  281  
  282         cons t actual =  instance. getUsersLi st();
  283         cons t expected  = users;
  284  
  285         expe ct(actual) .toEqual(e xpected);
  286       });
  287  
  288       it('sh ould filte r the user s by role  using the  filterBy i n the stat e', () =>  {
  289         inst ance.setSt ate({
  290           fi lterBy: 'V IEWER',
  291           se archBy: ''
  292         });
  293  
  294         cons t actual =  instance. getUsersLi st();
  295         cons t expected  = users.f ilter((use r) => user .role ===  instance.s tate.filte rBy);
  296  
  297         expe ct(actual) .toEqual(e xpected);
  298       });
  299  
  300       it('sh ould searc h for the  users by n ame using  the search By in the  state', ()  => {
  301         inst ance.setSt ate({
  302           fi lterBy: 'A LL',
  303           se archBy: 'A dmin'
  304         });
  305  
  306         cons t actual =  instance. getUsersLi st();
  307         cons t expected  = [
  308           {
  309              id: '4',
  310               userName:  ' RED A CTED ',
  311              role: 'ADM INISTRATOR ',
  312               vaNetworkI d: ' R E DA C T E D ',
  313               domain: ' RE D ACT E D '
  314           },
  315           {
  316              id: '6',
  317               userName:  ' R E D A CTED ',
  318              role: 'VIE WER',
  319               vaNetworkI d: '
R
E DACT E D ',
  320               domain: ' RE D ACT E D '
  321           }
  322         ];
  323  
  324         expe ct(actual) .toEqual(e xpected);
  325       });
  326  
  327       it('sh ould filte r the user s by both  the filter By and the  searchBy  in the sta te', () =>  {
  328         inst ance.setSt ate({
  329           fi lterBy: 'V IEWER',
  330           se archBy: 'U ser, SEOC'
  331         });
  332  
  333         cons t actual =  instance. getUsersLi st();
  334         cons t expected  = users.f ilter((use r) => user .role ===  instance.s tate.filte rBy && use r.userName .indexOf(i nstance.st ate.search By) !== -1 );
  335  
  336         expe ct(actual) .toEqual(e xpected);
  337       });
  338     });
  339  
  340     describe ('updateSe lected', ( ) => {
  341       it('sh ould updat e selected  on the st ate', () = > {
  342         inst ance.updat eSelected( '1');
  343         
  344         cons t actual =  instance. state.sele cted;
  345         cons t expected  = '1';
  346  
  347         expe ct(actual) .toEqual(e xpected);
  348       });
  349     });
  350  
  351     describe ('showHide EditForm',  () => {
  352       before Each(() =>  {
  353         inst ance.setSt ate({ cont ent: 'some  content'  });
  354         layo utInstance .setupGetS tyles = je st.fn();
  355         wind ow.onresiz e = jest.f n();
  356       });
  357  
  358       it('sh ould reset  the conte nt on the  state', ()  => {
  359         inst ance.showH ideEditFor m();
  360  
  361         cons t actual =  instance. state.cont ent;
  362         cons t expected  = '';
  363  
  364         expe ct(actual) .toEqual(e xpected);
  365       });
  366  
  367       it('sh ould call  window.onr esize', ()  => {
  368         inst ance.showH ideEditFor m();
  369  
  370         expe ct(window. onresize). toBeCalled ();
  371       });
  372  
  373       it('sh ould set s howEdit on  the state  to true i f true is  passed', ( ) => {
  374         inst ance.setSt ate({ show Edit: fals e });
  375  
  376         inst ance.showH ideEditFor m(true);
  377         
  378         cons t actual =  instance. state.show Edit;
  379         cons t expected  = true;
  380  
  381         expe ct(actual) .toEqual(e xpected);
  382       });
  383  
  384       it('sh ould set s howEdit on  the state  to false  if false i s passed',  () => {
  385         inst ance.setSt ate({ show Edit: true  });
  386  
  387         inst ance.showH ideEditFor m(false);
  388         
  389         cons t actual =  instance. state.show Edit;
  390         cons t expected  = false;
  391  
  392         expe ct(actual) .toEqual(e xpected);
  393       });
  394  
  395       it('sh ould set s howEdit on  the state  to false  by default ', () => {
  396         inst ance.setSt ate({ show Edit: true  });
  397  
  398         inst ance.showH ideEditFor m();
  399         
  400         cons t actual =  instance. state.show Edit;
  401         cons t expected  = false;
  402  
  403         expe ct(actual) .toEqual(e xpected);
  404       });
  405  
  406       it('sh ould call  the given  callback',  () => {
  407         cons t callback  = jest.fn ();
  408  
  409         inst ance.setSt ate({ show Edit: true  });
  410  
  411         inst ance.showH ideEditFor m(false, c allback);
  412         
  413         expe ct(callbac k).toBeCal led();
  414       });
  415     });
  416  
  417     describe ('showEdit Form', ()  => {
  418       before Each(() =>  {
  419         inst ance.showH ideEditFor m = jest.f n();
  420  
  421         focu s = jest.f n();
  422         scro llIntoView  = jest.fn ();
  423  
  424         inst ance.showE ditForm();
  425       });
  426  
  427       it('sh ould call  showHideEd itForm wit h true', ( ) => {
  428         expe ct(instanc e.showHide EditForm). toBeCalled ();
  429         expe ct(instanc e.showHide EditForm.m ock.calls[ 0][0]).toE qual(true) ;
  430       });
  431  
  432       descri be('after  calling sh owHideEdit Form', ()  => {
  433         befo reEach(()  => {
  434           in stance.sho wHideEditF orm.mock.c alls[0][1] ();
  435         });
  436  
  437         it(' should foc us on the  required-t ag', () =>  {
  438           ex pect(docum ent.queryS elector).t oBeCalledW ith('.requ ired-tag') ;
  439           ex pect(focus ).toBeCall ed();
  440         });
  441     
  442         it(' should scr oll the ed it form ro w into vie w', () =>  {
  443           ex pect(docum ent.queryS elector).t oBeCalledW ith('.add- edit-user- row');
  444           ex pect(scrol lIntoView) .toBeCalle d();
  445         });
  446       });
  447     });
  448  
  449     describe ('editUser ', () => {
  450       before Each(() =>  {
  451         inst ance.setSt ate({
  452           se lected: '1 ',
  453           us er: instan ce.getEmpt yUser()
  454         });
  455  
  456         inst ance.showE ditForm =  jest.fn();
  457  
  458         inst ance.editU ser();
  459       });
  460  
  461       it('sh ould corre ctly updat e the user  on the st ate with t he selecte d user', ( ) => {
  462         cons t user = u sers[0];
  463  
  464         cons t actual =  instance. state.user ;
  465         cons t expected  = extend( { prevNetw orkId: use r.vaNetwor kId }, use r);
  466  
  467         expe ct(actual) .toEqual(e xpected);
  468       });
  469  
  470       it('sh ould call  showEditFo rm', () =>  {
  471         expe ct(instanc e.showEdit Form).toBe Called();
  472       });
  473     });
  474  
  475     describe ('closeEdi tForm', ()  => {
  476       before Each(() =>  {
  477         inst ance.showH ideEditFor m = jest.f n();
  478         inst ance.focus Heading =  jest.fn();
  479  
  480         inst ance.close EditForm() ;
  481       });
  482  
  483       it('sh ould reset  the user' , () => {
  484         cons t actual =  instance. state.user ;
  485         cons t expected  = instanc e.getEmpty User();
  486  
  487         expe ct(actual) .toEqual(e xpected);
  488       });
  489  
  490       it('sh ould call  showHideEd itForm wit h false',  () => {
  491         expe ct(instanc e.showHide EditForm). toBeCalled ();
  492         expe ct(instanc e.showHide EditForm.m ock.calls[ 0][0]).toE qual(false );
  493       });
  494  
  495       it('sh ould focus  on the he ading', ()  => {
  496         inst ance.showH ideEditFor m.mock.cal ls[0][1]() ;
  497  
  498         expe ct(instanc e.focusHea ding).toBe Called();
  499       });
  500     });
  501  
  502     describe ('updateUs er', () =>  {
  503       const  user = {
  504           userName:  ' R E D A C T ED ',
  505         role : 'AUTHOR' ,
  506           vaNetworkI d: ' R E D A C T ED ',
  507           domain: ' RE D ACT E D '
  508       };
  509  
  510       before Each(() =>  {
  511         inst ance.setSt ate({
  512           us er: instan ce.getEmpt yUser(),
  513           co ntent: 'co ntent'
  514         });
  515  
  516         layo utInstance .setupGetS tyles = je st.fn();
  517         wind ow.onresiz e = jest.f n();
  518  
  519         inst ance.updat eUser(user );
  520       });
  521  
  522       it('sh ould updat e user on  the state' , () => {
  523         cons t actual =  instance. state.user ;
  524         cons t expected  = user;
  525  
  526         expe ct(actual) .toEqual(e xpected);
  527       });
  528  
  529       it('sh ould clear  the conte nt on the  state', ()  => {
  530         cons t actual =  instance. state.cont ent;
  531         cons t expected  = '';
  532  
  533         expe ct(actual) .toEqual(e xpected);
  534       });
  535  
  536       it('sh ould call  window.onr esize', ()  => {
  537         expe ct(window. onresize). toBeCalled ();
  538       });
  539     });
  540  
  541     describe ('isDuplic ateUser',  () => {
  542       it('sh ould retur n false by  default',  () => {
  543         cons t actual =  instance. isDuplicat eUser();
  544         cons t expected  = false;
  545  
  546         expe ct(actual) .toEqual(e xpected);
  547       });
  548  
  549       it('sh ould retur n true if  the userNa me matches ', () => {
  550         cons t actual =  instance. isDuplicat eUser({
  551             userName:  '
R ED A CTED ',
  552           ro le: 'Admin istrator',
  553             vaNetworkI d: ' REDACT E
D',
  554             domain: ' R ED
A CTED '
  555         });
  556         cons t expected  = true;
  557  
  558         expe ct(actual) .toEqual(e xpected);
  559       });
  560  
  561       it('sh ould retur n true if  the vaNetw orkId matc hes', () = > {
  562         cons t actual =  instance. isDuplicat eUser({
  563             userName:  ' REDACTED ',
  564           ro le: 'Admin istrator',
  565             vaNetworkI d: ' R E DA C T E D ',
  566             domain: ' R ED
A CTED '
  567         });
  568         cons t expected  = true;
  569  
  570         expe ct(actual) .toEqual(e xpected);
  571       });
  572  
  573       it('sh ould retur n false if  the user  is unique' , () => {
  574         cons t actual =  instance. isDuplicat eUser({
  575             userName:  ' REDACTED ',
  576           ro le: 'Admin istrator',
  577             vaNetworkI d: ' REDACT E
D',
  578             domain: ' R ED
A CTED '
  579         });
  580         cons t expected  = false;
  581  
  582         expe ct(actual) .toEqual(e xpected);
  583       });
  584  
  585       it('sh ould retur n false if  the only  duplicate  is the cur rent user' , () => {
  586         cons t actual =  instance. isDuplicat eUser({
  587           id : '4',
  588             userName:  ' RED A CTED ',
  589           ro le: 'ADMIN ISTRATOR',
  590             vaNetworkI d: ' R E DA C T E D ',
  591             domain: ' RE D ACT E D '
  592         });
  593         cons t expected  = false;
  594  
  595         expe ct(actual) .toEqual(e xpected);
  596       });
  597     });
  598  
  599     describe ('validate User', ()  => {
  600       it('sh ould retur n null if  the user i s valid',  () => {
  601         inst ance.setSt ate({
  602           us er: {
  603               userName:  ' REDACTED ',
  604              role: 'Adm inistrator ',
  605               vaNetworkI d: ' REDACT E
D',
  606               domain: ' R ED
A CTED '
  607           }
  608         });
  609  
  610         cons t actual =  instance. validateUs er();
  611         cons t expected  = null;
  612  
  613         expe ct(actual) .toEqual(e xpected);
  614       });
  615  
  616       it('sh ould retur n an error  if the us er is a du plicate',  () => {
  617         inst ance.setSt ate({
  618           us er: {
  619               userName:  '
R ED A CTED ',
  620              role: 'Adm inistrator ',
  621               vaNetworkI d: ' REDACT E
D',
  622               domain: ' R ED
A CTED '
  623           }
  624         });
  625  
  626         cons t actual =  instance. validateUs er();
  627         cons t expected  = ['A Use r already  exists wit h that Use r Name or  VA Network  ID'];
  628  
  629         expe ct(actual) .toEqual(e xpected);
  630       });
  631  
  632       it('sh ould retur n errors i f the user Name, vaNe tworkId, a nd domain  are not gi ven', () = > {
  633         inst ance.setSt ate({ user : instance .getEmptyU ser() });
  634  
  635         cons t actual =  instance. validateUs er();
  636         cons t expected  = [
  637           'U ser Name i s required ',
  638           'V A Network  ID is requ ired',
  639           'D omain is r equired'
  640         ];
  641  
  642         expe ct(actual) .toEqual(e xpected);
  643       });
  644  
  645       it('sh ould retur n errors i f the user Name, vaNe tworkId, a nd domain  only conta in spaces' , () => {
  646         inst ance.setSt ate({
  647           us er: extend (
  648              {},
  649              instance.g etEmptyUse r(),
  650              {
  651                userName : '    ',
  652                vaNetwor kId: '     ',
  653                domain:  '    '
  654              }
  655           )
  656         });
  657         
  658         cons t actual =  instance. validateUs er();
  659         cons t expected  = [
  660           'U ser Name i s required ',
  661           'V A Network  ID is requ ired',
  662           'D omain is r equired'
  663         ];
  664  
  665         expe ct(actual) .toEqual(e xpected);
  666       });
  667  
  668       it('sh ould retur n errors i f the vaNe tworkId an d domain h ave non-al phanumeric  character s', () =>  {
  669         inst ance.setSt ate({
  670           us er: {
  671              userName:  'Special,  Characters  don\'t ma tter in th e username ',
  672              role: 'Adm inistrator ',
  673              vaNetworkI d: 'ABCDEF GHIJKLMNOP QRSTUVWXYZ abcdefghij klmnopqrst uvwxyz0123 456789,,/. /,',
  674              domain: 'A BCDEFGHIJK LMNOPQRSTU VWXYZabcde fghijklmno pqrstuvwxy z012345678 9,,/./,'
  675           }
  676         });
  677  
  678         cons t actual =  instance. validateUs er();
  679         cons t expected  = [
  680           'V A Network  ID must co ntain only  letters o r numbers' ,
  681           'D omain must  contain o nly letter s or numbe rs'
  682         ];
  683  
  684         expe ct(actual) .toEqual(e xpected);
  685       });
  686  
  687       it('sh ould retur n errors i f the user Name, vaNe tworkId, a nd domain  are too lo ng', () =>  {
  688         inst ance.setSt ate({
  689           us er: {
  690              userName:  'abcdefghi jklmnopqrs tuvwxyz ab cdefghijkl mnopqrstuv wxyz',
  691              role: 'Adm inistrator ',
  692              vaNetworkI d: 'ABCDEF GHIJKLMNOP QRSTUVWXYZ ',
  693              domain: 'A BCDEFGHIJK LMNOPQRSTU VWXYZ'
  694           }
  695         });
  696  
  697         cons t actual =  instance. validateUs er();
  698         cons t expected  = [
  699           'U ser Name m ust be les s than or  equal to 5 0 characte rs',
  700           'V A Network  ID must be  less than  or equal  to 25 char acters',
  701           'D omain must  be less t han or equ al to 25 c haracters'
  702         ];
  703  
  704         expe ct(actual) .toEqual(e xpected);
  705       });
  706  
  707       it('sh ould not r eturn erro rs if the  userName,  vaNetworkI d, and dom ain are to o long bec ause they  have leadi ng or trai ling space s', () =>  {
  708         inst ance.setSt ate({
  709           us er: {
  710              userName:  '  abcdefg hijklmnopq rstuvw abc defghijklm nopqrstuvw   ',
  711              role: 'Adm inistrator ',
  712              vaNetworkI d: '  ABCD EFGHIJKLMN OPQRSTUV   ',
  713              domain: '   ABCDEFGHI JKLMNOPQRS TUV  '
  714           }
  715         });
  716  
  717         cons t actual =  instance. validateUs er();
  718         cons t expected  = null;
  719  
  720         expe ct(actual) .toEqual(e xpected);
  721       });
  722     });
  723  
  724  
  725     describe ('saveUser ', () => {
  726       before Each(() =>  {
  727         inst ance.showH ideEditFor m = jest.f n();
  728  
  729         inst ance.saveU ser();
  730       });
  731  
  732       it('sh ould call  showHideEd itForm', ( ) => {
  733         expe ct(instanc e.showHide EditForm). toBeCalled ();
  734         expe ct(instanc e.showHide EditForm.m ock.calls[ 0][0]).toE qual(true) ;
  735       });
  736  
  737       descri be('callba ck', () =>  {
  738         let  callback;
  739  
  740         befo reEach(()  => {
  741           ca llback = i nstance.sh owHideEdit Form.mock. calls[0][1 ];
  742         });
  743  
  744         desc ribe('vali dation err ors', () = > {
  745           be foreEach(( ) => {
  746              layoutInst ance.setup GetStyles  = jest.fn( );
  747              window.onr esize = je st.fn();
  748     
  749              instance.s etState({  user: inst ance.getEm ptyUser()  });
  750     
  751              request.mo ckReset();
  752     
  753              callback() ;
  754           }) ;
  755     
  756           it ('should n ot make a  request',  () => {
  757              expect(req uest).not. toBeCalled ();
  758           }) ;
  759     
  760           it ('should s how an ale rt', () =>  {
  761              const erro rs = insta nce.valida teUser();
  762              const actu al = insta nce.state. content;
  763              const expe cted = <Al ert alert= { generate AlertData( undefined,  errors, ' error') }  />;
  764     
  765              expect(act ual).toEqu al(expecte d);
  766           }) ;
  767     
  768           it ('should c all window .onresize' , () => {
  769              expect(win dow.onresi ze).toBeCa lled();
  770           }) ;
  771         });
  772     
  773         desc ribe('no v alidation  errors', ( ) => {
  774           le t user;
  775           le t requestO ptions;
  776     
  777           be foreEach(( ) => {
  778              mountWrapp er();
  779     
  780              user = {
  781                id: '7',
  782                  userName:  AI      SEOC, AUTH OR     ',
  783                role: 'A UTHOR',
  784                vaNetwor kId: '   S EOCAUTHOR    ',
  785                prevNetw orkId: '',
  786                domain:  '   DEV    '
  787              };
  788     
  789              instance.s etState({
  790                content:  '',
  791                user,
  792                showEdit : true
  793              });
  794     
  795              request.mo ckReset();
  796  
  797              instance.s howHideEdi tForm = je st.fn();
  798  
  799              instance.s aveUser();
  800     
  801              instance.s howHideEdi tForm.mock .calls[0][ 1]();
  802     
  803              requestOpt ions = req uest.mock. calls[0][0 ];
  804           }) ;
  805     
  806           it ('should m ake a PUT  request wi th the cor rect data' , () => {
  807              expect(req uestOption s.type).to Equal('PUT ');
  808              expect(req uestOption s.endpoint ).toEqual( 'saveUser' );
  809           }) ;
  810     
  811           it ('should u se the cor rect data  and trim e xtra white space', ()  => {
  812              expect(req uestOption s.data).to Equal({
  813                id: user .id,
  814                userName : user.use rName.trim (),
  815                role: us er.role,
  816                vaNetwor kId: user. vaNetworkI d.trim(),
  817                prevNetw orkId: use r.prevNetw orkId,
  818                domain:  user.domai n.trim()
  819              });
  820           }) ;
  821     
  822           it ('should n ot update  the user o n the stat e', () =>  {
  823              const data User = req uestOption s.data;
  824     
  825              expect(use r.userName ).not.toEq ual(dataUs er.userNam e);
  826              expect(use r.vaNetwor kId).not.t oEqual(dat aUser.vaNe tworkId);
  827              expect(use r.domain). not.toEqua l(dataUser .domain);
  828           }) ;
  829     
  830           de scribe('su ccessful r equest', ( ) => {
  831              beforeEach (() => {
  832                request. mockReset( );
  833     
  834                instance .closeEdit Form = jes t.fn();
  835     
  836                requestO ptions.suc cess();
  837              });
  838     
  839              it('should  not show  an alert',  () => {
  840                const ac tual = ins tance.stat e.content;
  841                const ex pected = ' ';
  842     
  843                expect(a ctual).toE qual(expec ted);
  844              });
  845     
  846              it('should  re-fetch  the list o f users',  () => {
  847                expect(r equest).to BeCalled() ;
  848                expect(r equest.moc k.calls[0] [0].type). toEqual('G ET');
  849                expect(r equest.moc k.calls[0] [0].endpoi nt).toEqua l('users') ;
  850              });
  851     
  852              it('should  close the  edit form ', () => {
  853                expect(i nstance.cl oseEditFor m).toBeCal led();
  854              });
  855           }) ;
  856     
  857           de scribe('un successful  request',  () => {
  858              beforeEach (() => {
  859                request. mockReset( );
  860     
  861                instance .closeEdit Form = jes t.fn();
  862     
  863                requestO ptions.err or();
  864              });
  865     
  866              it('should  not re-fe tch the li st of user s', () =>  {
  867                expect(r equest).no t.toBeCall ed();
  868              });
  869     
  870              it('should  not close  the edit  form', ()  => {
  871                expect(i nstance.cl oseEditFor m).not.toB eCalled();
  872              });
  873     
  874              it('should  show an A lert messa ge', () =>  {
  875                requestO ptions.err or(JSON.st ringify({  apierror:  { message:  'User exi sts with t he same va UserId.' } }));
  876  
  877                const er rors = ['U ser exists  with the  same vaUse rId.'];
  878     
  879                const ac tual = ins tance.stat e.content;
  880                const ex pected = < Alert aler t={ genera teAlertDat a(undefine d, errors,  'error')  } />;
  881  
  882                expect(a ctual).toE qual(expec ted);
  883              });
  884  
  885              it('should  show a de fault Aler t if there  is no res ponse from  the reque st', () =>  {
  886                const ac tual = ins tance.stat e.content;
  887                const ex pected = < Alert aler t={ genera teAlertDat a('Unable  to save th e user', ' Please try  again lat er', 'erro r') } />;
  888       
  889                expect(a ctual).toE qual(expec ted);
  890              });
  891       
  892              it('should  show an A lert with  the messag e in the r esponse',  () => {
  893                requestO ptions.err or(JSON.st ringify({  apierror:  { message:  'User exi sts with t he same va UserId.' } }));
  894  
  895                const er rors = ['U ser exists  with the  same vaUse rId.'];
  896     
  897                const ac tual = ins tance.stat e.content;
  898                const ex pected = < Alert aler t={ genera teAlertDat a(undefine d, errors,  'error')  } />;
  899  
  900                expect(a ctual).toE qual(expec ted);
  901              });
  902           }) ;
  903         });
  904       });
  905     });
  906  
  907     describe ('isUserSe lected', ( ) => {
  908       it('sh ould retur n false if  selected  on the sta te is null ', () => {
  909         inst ance.setSt ate({ sele cted: null  });
  910  
  911         cons t actual =  instance. isUserSele cted();
  912         cons t expected  = false;
  913  
  914         expe ct(actual) .toEqual(e xpected);
  915       });
  916  
  917       it('sh ould retur n false if  the selec ted user i s the same  as the cu rrent user ', () => {
  918         inst ance.setSt ate({ sele cted: '6'  });
  919  
  920         cons t actual =  instance. isUserSele cted();
  921         cons t expected  = false;
  922  
  923         expe ct(actual) .toEqual(e xpected);
  924       });
  925  
  926       it('sh ould retur n true if  the select ed user is  not the c urrent use r', () =>  {
  927         inst ance.setSt ate({ sele cted: '1'  });
  928  
  929         cons t actual =  instance. isUserSele cted();
  930         cons t expected  = true;
  931  
  932         expe ct(actual) .toEqual(e xpected);
  933       });
  934     });
  935  
  936     describe ('deleteUs er', () =>  {
  937       let re questOptio ns;
  938  
  939       before Each(() =>  {
  940         inst ance.setSt ate({
  941           co ntent: '',
  942           se lected: '5 '
  943         });
  944         
  945         requ est.mockRe set();
  946  
  947         inst ance.delet eUser();
  948  
  949         requ estOptions  = request .mock.call s[0][0];
  950       });
  951  
  952       it('sh ould make  a DELETE r equest wit h the corr ect data',  () => {
  953         expe ct(request Options.ty pe).toEqua l('DELETE' );
  954         expe ct(request Options.en dpoint).to Equal('del eteUser');
  955         expe ct(request Options.su ffix).toEq ual(users[ 4].vaNetwo rkId);
  956       });
  957  
  958       descri be('succes sful reque st', () =>  {
  959         befo reEach(()  => {
  960           re quest.mock Reset();
  961  
  962           in stance.foc usHeading  = jest.fn( );
  963  
  964           st ore.dispat ch(showMod al({}));
  965  
  966           re questOptio ns.success ();
  967         });
  968  
  969         it(' should not  show an a lert', ()  => {
  970           co nst actual  = instanc e.state.co ntent;
  971           co nst expect ed = '';
  972  
  973           ex pect(actua l).toEqual (expected) ;
  974         });
  975         
  976         it(' should re- fetch the  list of us ers', () = > {
  977           ex pect(reque st).toBeCa lled();
  978           ex pect(reque st.mock.ca lls[0][0]. type).toEq ual('GET') ;
  979           ex pect(reque st.mock.ca lls[0][0]. endpoint). toEqual('u sers');
  980         });
  981         
  982         it(' should cal l closeMod al', () =>  {
  983           co nst actual  = store.g etState(). modal;
  984           co nst expect ed = null;
  985  
  986           ex pect(actua l).toEqual (expected) ;
  987         });
  988  
  989         it(' should foc us on the  heading',  () => {
  990           ex pect(insta nce.focusH eading).to BeCalled() ;
  991         });
  992  
  993         it(' should upd ate select ed on the  store', ()  => {
  994           co nst actual  = instanc e.state.se lected;
  995           co nst expect ed = null;
  996  
  997           ex pect(actua l).toEqual (expected) ;
  998         });
  999       });
  1000  
  1001       descri be('unsucc essful req uest', ()  => {
  1002         befo reEach(()  => {
  1003           re quest.mock Reset();
  1004  
  1005           in stance.foc usHeading  = jest.fn( );
  1006  
  1007           st ore.dispat ch(showMod al({}));
  1008  
  1009           re questOptio ns.error() ;
  1010         });
  1011  
  1012         it(' should not  re-fetch  the list o f users',  () => {
  1013           ex pect(reque st).not.to BeCalled() ;
  1014         });
  1015  
  1016         it(' should not  focus on  the headin g', () =>  {
  1017           ex pect(insta nce.focusH eading).no t.toBeCall ed();
  1018         });
  1019  
  1020         it(' should not  update se lected on  the store' , () => {
  1021           co nst actual  = instanc e.state.se lected;
  1022           co nst expect ed = null;
  1023  
  1024           ex pect(actua l).not.toE qual(expec ted);
  1025         });
  1026  
  1027         it(' should cal l closeMod al', () =>  {
  1028           co nst actual  = store.g etState(). modal;
  1029           co nst expect ed = null;
  1030  
  1031           ex pect(actua l).toEqual (expected) ;
  1032         });
  1033  
  1034         desc ribe('Aler t message' , () => {
  1035           it ('should s how a defa ult Alert  if there i s no respo nse from t he request ', () => {
  1036              requestOpt ions.error ();
  1037  
  1038              const actu al = insta nce.state. content;
  1039              const expe cted = <Al ert alert= { generate AlertData( 'Unable to  delete th e user', ' Please try  again lat er', 'erro r') } />;
  1040  
  1041              expect(act ual).toEqu al(expecte d);
  1042           }) ;
  1043  
  1044           it ('should s how a defa ult Alert  if there i s no apier ror object  in the re sponse', ( ) => {
  1045              requestOpt ions.error (JSON.stri ngify({})) ;
  1046  
  1047              const actu al = insta nce.state. content;
  1048              const expe cted = <Al ert alert= { generate AlertData( 'Unable to  delete th e user', ' Please try  again lat er', 'erro r') } />;
  1049  
  1050              expect(act ual).toEqu al(expecte d);
  1051           }) ;
  1052  
  1053           it ('should s how a defa ult Alert  if the api error obje ct in the  response h as no subE rrors and  no message ', () => {
  1054              requestOpt ions.error (JSON.stri ngify({ ap ierror: {} }));
  1055  
  1056              const actu al = insta nce.state. content;
  1057              const expe cted = <Al ert alert= { generate AlertData( 'Unable to  delete th e user', ' Please try  again lat er', 'erro r') } />;
  1058  
  1059              expect(act ual).toEqu al(expecte d);
  1060           }) ;
  1061  
  1062           it ('should s how an ale rt with th e message  from the a pierror ob ject in th e response  if there  are no sub errors', ( ) => {
  1063              requestOpt ions.error (JSON.stri ngify({ ap ierror: {  message: ' Message wi th no sube rrors' }}) );
  1064  
  1065              const erro rs = ['Mes sage with  no suberro rs'];
  1066  
  1067              const actu al = insta nce.state. content;
  1068              const expe cted = <Al ert alert= { generate AlertData( undefined,  errors, ' error') }  />;
  1069  
  1070              expect(act ual).toEqu al(expecte d);
  1071           }) ;
  1072  
  1073           it ('should s how an ale rt with th e suberror s from the  apierror  object in  the respon se', () =>  {
  1074              requestOpt ions.error (JSON.stri ngify({
  1075                apierror : {
  1076                  subErr ors: [
  1077                    { me ssage: 'Me ssage with out a fiel d' },
  1078                    {
  1079                      fi eld: 'fiel d',
  1080                      me ssage: 'Me ssage with  a field'
  1081                    }
  1082                  ]
  1083                }
  1084              }));
  1085  
  1086              const erro rs = [
  1087                'Message  without a  field',
  1088                'field:  Message wi th a field '
  1089              ];
  1090  
  1091              const actu al = insta nce.state. content;
  1092              const expe cted = <Al ert alert= { generate AlertData( undefined,  errors, ' error') }  />;
  1093  
  1094              expect(act ual).toEqu al(expecte d);
  1095           }) ;
  1096         });
  1097       });
  1098     });
  1099  
  1100     describe ('renderDe leteUserMo dal', () = > {
  1101       let mo dal;
  1102  
  1103       before Each(() =>  {
  1104         inst ance.delet eUser = je st.fn();
  1105  
  1106         inst ance.rende rDeleteUse rModal();
  1107  
  1108         moda l = mount(
  1109           <P rovider st ore={store }>
  1110              { store.ge tState().m odal.compo nent }
  1111           </ Provider>
  1112         ).fi nd('Delete UserModal' );
  1113       });
  1114  
  1115       it('sh ould displ ay a Delet eUserModal ', () => {
  1116         cons t actual =  modal.len gth;
  1117         cons t expected  = 1;
  1118  
  1119         expe ct(actual) .toEqual(e xpected);
  1120       });
  1121  
  1122       it('sh ould pass  the delete User funct ion', () = > {
  1123         moda l.prop('de leteUser') ();
  1124  
  1125         expe ct(instanc e.deleteUs er).toBeCa lled();
  1126       });
  1127     });
  1128  
  1129     describe ('renderRe quiredTag' , () => {
  1130       it('sh ould retur n an empty  string if  showEdit  is false',  () => {
  1131         inst ance.setSt ate({ show Edit: fals e });
  1132  
  1133         cons t actual =  instance. renderRequ iredTag();
  1134         cons t expected  = '';
  1135  
  1136         expe ct(actual) .toEqual(e xpected);
  1137       });
  1138  
  1139       it('sh ould retur n the requ ired-tag e lement if  showEdit i s true', ( ) => {
  1140         inst ance.setSt ate({
  1141           us er: instan ce.getEmpt yUser(),
  1142           sh owEdit: tr ue
  1143         });
  1144  
  1145         cons t actual =  instance. renderRequ iredTag();
  1146         cons t expected  = <p clas sName="req uired-tag"  tabIndex= "0">*All f ields are  required</ p>;
  1147  
  1148         expe ct(actual) .toEqual(e xpected);
  1149       });
  1150     });
  1151  
  1152     describe ('elements ', () => {
  1153       descri be('Layout ', () => {
  1154         befo reEach(()  => {
  1155           st ore = conf igureStore ({
  1156              session: {
  1157                role: AD MINISTRATO R,
  1158                user: cu rrentUser
  1159              },
  1160              users
  1161           }) ;
  1162  
  1163           mo untWrapper ();
  1164         });
  1165  
  1166         it(' should hav e a Layout  component ', () => {
  1167           co nst actual  = layout. length;
  1168           co nst expect ed = 1;
  1169  
  1170           ex pect(actua l).toEqual (expected) ;
  1171         });
  1172  
  1173         desc ribe('head er', () =>  {
  1174           le t header;
  1175           
  1176           be foreEach(( ) => {
  1177              header = m ount(
  1178                <Provide r store={  store }>
  1179                  { layo ut.prop('h eader') }
  1180                </Provid er>
  1181              ).find('Ta bleSearch' );
  1182           }) ;
  1183  
  1184           it ('should u se a Table Search com ponent', ( ) => {
  1185              const actu al = heade r.length;
  1186              const expe cted = 1;
  1187  
  1188              expect(act ual).toEqu al(expecte d);
  1189           }) ;
  1190  
  1191           it ('should p ass the co rrect titl e', () =>  {
  1192              const actu al = heade r.prop('ti tle');
  1193              const expe cted = 'Us er Managem ent';
  1194  
  1195              expect(act ual).toEqu al(expecte d);
  1196           }) ;
  1197  
  1198           de scribe('fi lterOption s', () =>  {
  1199              let filter Options;
  1200             
  1201              beforeEach (() => {
  1202                filterOp tions = he ader.prop( 'filterOpt ions');
  1203              });
  1204  
  1205              it('should  pass the  correct fi lters', ()  => {
  1206                const ac tual = fil terOptions .filters;
  1207                const ex pected = [ 'ALL'].con cat(roleFi lterTypes) ;
  1208  
  1209                expect(a ctual).toE qual(expec ted);
  1210              });
  1211  
  1212              it('should  pass the  correct fi lterLabel' , () => {
  1213                const ac tual = fil terOptions .filterLab el;
  1214                const ex pected = ' Filter by  Role';
  1215  
  1216                expect(a ctual).toE qual(expec ted);
  1217              });
  1218  
  1219              it('should  pass the  correct fi lterBy', ( ) => {
  1220                const ac tual = fil terOptions .filterBy;
  1221                const ex pected = i nstance.st ate.filter By;
  1222  
  1223                expect(a ctual).toE qual(expec ted);
  1224              });
  1225  
  1226              it('should  pass the  updateFilt erBy funct ion', () = > {
  1227                filterOp tions.upda teFilterBy ('VIEWER') ;
  1228  
  1229                const ac tual = ins tance.stat e.filterBy ;
  1230                const ex pected = ' VIEWER';
  1231  
  1232                expect(a ctual).toE qual(expec ted);
  1233              });
  1234           }) ;
  1235  
  1236           de scribe('se archOption s', () =>  {
  1237              let search Options;
  1238  
  1239              beforeEach (() => {
  1240                searchOp tions = he ader.prop( 'searchOpt ions');
  1241              });
  1242  
  1243              it('should  pass the  correct se archPlaceh older', ()  => {
  1244                const ac tual = sea rchOptions .searchPla ceholder;
  1245                const ex pected = ' Filter by  Name';
  1246     
  1247                expect(a ctual).toE qual(expec ted);
  1248              });
  1249     
  1250              it('should  pass the  correct se archLabel' , () => {
  1251                const ac tual = sea rchOptions .searchLab el;
  1252                const ex pected = ' Filter by  Name (cont ains)';
  1253     
  1254                expect(a ctual).toE qual(expec ted);
  1255              });
  1256     
  1257              it('should  pass the  correct se archBy', ( ) => {
  1258                const ac tual = sea rchOptions .searchBy;
  1259                const ex pected = i nstance.st ate.search By;
  1260     
  1261                expect(a ctual).toE qual(expec ted);
  1262              });
  1263     
  1264              it('should  pass the  updateSear chBy funct ion', () = > {
  1265                searchOp tions.upda teSearchBy ('Search T erm');
  1266     
  1267                const ac tual = ins tance.stat e.searchBy ;
  1268                const ex pected = ' Search Ter m';
  1269     
  1270                expect(a ctual).toE qual(expec ted);
  1271              });
  1272           }) ;
  1273  
  1274           it ('should p ass the co rrect disa bled prop' , () => {
  1275              const actu al = heade r.prop('di sabled');
  1276              const expe cted = ins tance.stat e.showEdit ;
  1277  
  1278              expect(act ual).toEqu al(expecte d);
  1279           }) ;
  1280         });
  1281  
  1282         desc ribe('foot er', () =>  {
  1283           le t footer;
  1284           
  1285           be foreEach(( ) => {
  1286              footer = m ount(
  1287                <Provide r store={  store }>
  1288                  <Conne ctedRouter  history={  history } >
  1289                    { la yout.prop( 'footer')  }
  1290                  </Conn ectedRoute r>
  1291                </Provid er>
  1292              ).find('Us erTableFoo ter');
  1293           }) ;
  1294  
  1295           it ('should u se a UserT ableFooter  component ', () => {
  1296              const actu al = foote r.length;
  1297              const expe cted = 1;
  1298  
  1299              expect(act ual).toEqu al(expecte d);
  1300           }) ;
  1301  
  1302           it ('should p ass select ed from th e state',  () => {
  1303              const actu al = foote r.prop('is Selected') ;
  1304              const expe cted = ins tance.isUs erSelected ();
  1305  
  1306              expect(act ual).toEqu al(expecte d);
  1307           }) ;
  1308  
  1309           it ('should p ass showEd it from th e state',  () => {
  1310              const actu al = foote r.prop('sh owEdit');
  1311              const expe cted = ins tance.stat e.showEdit ;
  1312  
  1313              expect(act ual).toEqu al(expecte d);
  1314           }) ;
  1315  
  1316           it ('should p ass the sh owEditForm  function' , () => {
  1317              layoutInst ance.setup GetStyles  = jest.fn( );
  1318              window.onr esize = je st.fn();
  1319  
  1320              footer.pro p('showEdi tForm')();
  1321  
  1322              expect(ins tance.stat e.content) .toEqual(' ');
  1323              expect(ins tance.stat e.showEdit ).toEqual( true);
  1324  
  1325              expect(win dow.onresi ze).toBeCa lled();
  1326           }) ;
  1327  
  1328           it ('should p ass the cl oseEditFor m function ', () => {
  1329              layoutInst ance.setup GetStyles  = jest.fn( );
  1330              window.onr esize = je st.fn();
  1331  
  1332              footer.pro p('closeEd itForm')() ;
  1333  
  1334              expect(ins tance.stat e.content) .toEqual(' ');
  1335              expect(ins tance.stat e.showEdit ).toEqual( false);
  1336  
  1337              expect(win dow.onresi ze).toBeCa lled();
  1338           }) ;
  1339  
  1340           it ('should p ass the sa veUser fun ction', ()  => {
  1341              request.mo ckReset();
  1342  
  1343              instance.s etState({
  1344                user: {
  1345                    userName:  AI      User',
  1346                  role:  'VIEWER',
  1347                  vaNetw orkId: 'NE WUSERID',
  1348                  domain : 'DEV'
  1349                }
  1350              });
  1351  
  1352              footer.pro p('saveUse r')();
  1353  
  1354              const requ estOptions  = request .mock.call s[0][0];
  1355  
  1356              expect(req uest).toBe Called();
  1357              expect(req uestOption s.type).to Equal('PUT ');
  1358              expect(req uestOption s.endpoint ).toEqual( 'saveUser' );
  1359              expect(req uestOption s.data).to Equal(inst ance.state .user);
  1360           }) ;
  1361         });
  1362  
  1363         desc ribe('cont ent', () = > {
  1364           le t content;
  1365           
  1366           be foreEach(( ) => {
  1367              content =  layout.chi ldren().fi nd('UserSc rollTable' );
  1368           }) ;
  1369  
  1370           it ('should u se a UserS crollTable  component ', () => {
  1371              const actu al = conte nt.length;
  1372              const expe cted = 1;
  1373  
  1374              expect(act ual).toEqu al(expecte d);
  1375           }) ;
  1376  
  1377           it ('should p ass showEd it from th e state',  () => {
  1378              const actu al = conte nt.prop('s howEdit');
  1379              const expe cted = ins tance.stat e.showEdit ;
  1380  
  1381              expect(act ual).toEqu al(expecte d);
  1382           }) ;
  1383  
  1384           it ('should p ass the re sults of g etUsersLis t as the u sers prop' , () => {
  1385              const actu al = conte nt.prop('u sers');
  1386              const expe cted = ins tance.getU sersList() ;
  1387  
  1388              expect(act ual).toEqu al(expecte d);
  1389           }) ;
  1390  
  1391           it ('should p ass user f rom the st ate', () = > {
  1392              const actu al = conte nt.prop('u ser');
  1393              const expe cted = ins tance.stat e.user;
  1394  
  1395              expect(act ual).toEqu al(expecte d);
  1396           }) ;
  1397  
  1398           it ('should p ass the up dateUser f unction',  () => {
  1399              content.pr op('update User')({
  1400                  userName:  ' REDACTED ',
  1401                role: 'V IEWER',
  1402                  vaNetworkI d: ' R E DACT E
D',
  1403                  domain: ' RE D ACT E D '
  1404              });
  1405  
  1406              const actu al = insta nce.state. user;
  1407              const expe cted = {
  1408                  userName:  ' REDACTED ',
  1409                role: 'V IEWER',
  1410                  vaNetworkI d: ' R E DACT E
D',
  1411                  domain: ' RE D ACT E D '
  1412              };
  1413  
  1414              expect(act ual).toEqu al(expecte d);
  1415           }) ;
  1416  
  1417           it ('should p ass select ed from th e state',  () => {
  1418              const actu al = conte nt.prop('s elected');
  1419              const expe cted = ins tance.stat e.selected ;
  1420  
  1421              expect(act ual).toEqu al(expecte d);
  1422           }) ;
  1423  
  1424           it ('should p ass the up dateSelect ed functio n', () =>  {
  1425              content.pr op('update Selected') ('1');
  1426  
  1427              const actu al = insta nce.state. selected;
  1428              const expe cted = '1' ;
  1429  
  1430              expect(act ual).toEqu al(expecte d);
  1431           }) ;
  1432         });
  1433       });
  1434     });
  1435   });