8. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/26/2019 10:01:15 AM 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\CCCC\CCCC\seoc-ui1.8\cc_seoc_ui\src\components\user-management UserManagement.spec.js Tue Apr 9 17:46:26 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\CCCC\CCCC\seoc-ui1.8\cc_seoc_ui\src\components\user-management UserManagement.spec.js Wed Apr 24 19:59:52 2019 UTC

8.2 Comparison summary

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