311. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/2/2019 1:08:02 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.

311.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\ARS_Frontend\ars-app\src\app\shared\attachment-viewer attachment-viewer.component.spec.ts Wed Mar 27 19:18:31 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\ARS_Frontend\ars-app\src\app\shared\attachment-viewer attachment-viewer.component.spec.ts Fri Mar 29 18:19:21 2019 UTC

311.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 7 2886
Changed 6 12
Inserted 0 0
Removed 0 0

311.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

311.4 Active regular expressions

No regular expressions were active.

311.5 Comparison detail

  1   import { F ormBuilder  } from '@ angular/fo rms';
  2   import { A ttachmentV iewerCompo nent } fro m './attac hment-view er.compone nt';
  3   import { S earch275Se rvice } fr om '../../ ars/search 275/search 275.servic e';
  4   import { A ttachmentV iewerServi ce } from  './attachm ent-viewer .service';
  5   import { A uthenticat ionService  } from '. ./../auth/ auth.servi ce';
  6   import { W indowRefSe rvice } fr om '../../ window-ref .service';
  7  
  8   import { O bservable  } from 'rx js/Observa ble';
  9   import { O bserver }  from 'rxjs /Observer' ;
  10  
  11   const logd bg = conso le.log; //  do loggin g
  12   // const l ogdbg = (. ..args) =>  {};  // d o nothing
  13  
  14   describe(' Attachment ViewerComp onent', ()  => {
  15     let comp onent: Att achmentVie werCompone nt;
  16     // let f ixture: Co mponentFix ture<Attac hmentViewe rComponent >;
  17  
  18     let sear ch275Servi ce: Search 275Service ;
  19     let atta chmentView erService:  Attachmen tViewerSer vice;
  20     let auth entication Service: A uthenticat ionService ;
  21     let form Builder: F ormBuilder ;
  22     let sani tizer;
  23     let loca tion;
  24     let _win dow: Windo wRefServic e;
  25     let docu ment;
  26     let rout e;
  27  
  28     beforeEa ch(() => {
  29       search 275Service  = new Sea rch275Serv ice(null);
  30       attach mentViewer Service =  new Attach mentViewer Service(nu ll);
  31       formBu ilder = ne w FormBuil der();
  32       authen ticationSe rvice = ne w Authenti cationServ ice(null,  null, null , null);
  33       saniti zer = { by passSecuri tyTrustRes ourceUrl:  () => true  };
  34       locati on = new O bservable( (observer:  Observer< {}>) => ob server.nex t({}));
  35       // _wi ndow = new  WindowRef Service();
  36       _windo w = {
  37         nati veWindow:  {
  38           pr int: () =>  true,
  39           sc rollTo: ()  => true,
  40           op en: () =>  true,
  41           //  more fake ry
  42           hi story: {pu shState: ( ) => true} ,
  43           na vigator: { msSaveOrOp enBlob: ()  => true},
  44           UR L: {
  45              createObje ctURL: ()  => true
  46           }
  47         }
  48       };
  49  
  50       docume nt = {
  51         body : {
  52           st yle: { ove rflow: ''  },
  53           ex ecCommand:  command = > {
  54              return tru e;
  55           }
  56         },
  57         exec Command: ( ) => true
  58       };
  59  
  60       route  = {
  61         snap shot: {
  62           qu eryParams:  () => tru e
  63         }
  64       };
  65  
  66       compon ent = new  Attachment ViewerComp onent(
  67         sani tizer,
  68         docu ment,
  69         form Builder,
  70         atta chmentView erService,
  71         auth entication Service,
  72         loca tion,
  73         _win dow,
  74         rout e
  75       );
  76  
  77       jasmin e.clock(). install();
  78     });
  79  
  80     afterEac h(() => {
  81       jasmin e.clock(). uninstall( );
  82     });
  83  
  84     it('shou ld be crea ted', () = > {
  85       expect (component ).toBeTrut hy();
  86     });
  87  
  88     it('test  ngOnInit  method: ex portPermis sion, edit Permission , roleAdmi n  with us erInfoRetu rned = und efined', ( ) => {
  89       const  userInfoRe turned = u ndefined;
  90  
  91       spyOn( component,  'formInit ');
  92       spyOn( component,  'setLocat ion');
  93  
  94       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  95         () = > userInfo Returned
  96       );
  97  
  98       expect (component .userInfo) .toEqual(u ndefined);
  99       expect (component .exportPer mission).t oEqual(fal se);
  100       expect (component .editPermi ssion).toE qual(false );
  101       expect (component .roleAdmin ).toEqual( false);
  102  
  103       compon ent.export Permission  = true;
  104       compon ent.editPe rmission =  true;
  105       compon ent.roleAd min = true ;
  106  
  107       route. snapshot.q ueryParams  = undefin ed;
  108  
  109       compon ent.ngOnIn it();
  110  
  111       expect (component .userInfo) .toEqual(u serInfoRet urned);
  112       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  113       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  114       expect (component .exportPer mission).t oEqual(tru e);
  115       expect (component .editPermi ssion).toE qual(true) ;
  116       expect (component .roleAdmin ).toEqual( true);
  117     });
  118  
  119     it('test  ngOnInit  method: ex portPermis sion, edit Permission , roleAdmi n  with us erInfoRetu rned = {}' , () => {
  120       spyOn( component,  'formInit ');
  121       spyOn( component,  'setLocat ion');
  122  
  123       const  userInfoRe turned = { };
  124       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  125         () = > userInfo Returned
  126       );
  127  
  128       expect (component .userInfo) .toEqual(u ndefined);
  129       expect (component .exportPer mission).t oEqual(fal se);
  130       expect (component .editPermi ssion).toE qual(false );
  131       expect (component .roleAdmin ).toEqual( false);
  132  
  133       compon ent.export Permission  = true;
  134       compon ent.editPe rmission =  true;
  135       compon ent.roleAd min = true ;
  136  
  137       route. snapshot.q ueryParams  = undefin ed;
  138  
  139       compon ent.ngOnIn it();
  140  
  141       expect (component .userInfo) .toEqual(u serInfoRet urned);
  142       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  143       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  144       expect (component .exportPer mission).t oEqual(tru e);
  145       expect (component .editPermi ssion).toE qual(true) ;
  146  
  147       expect (component .userInfo. userRoles) .toBeUndef ined(); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  148       expect (component .roleAdmin ).toEqual( false); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  149     });
  150  
  151     it('test  ngOnInit  method: ex portPermis sion, edit Permission , roleAdmi n  with us erInfoRetu rned.permi ssions: {} ', () => {
  152       spyOn( component,  'formInit ');
  153       spyOn( component,  'setLocat ion');
  154  
  155       const  userInfoRe turned = {
  156         perm issions: { }
  157       };
  158       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  159         () = > userInfo Returned
  160       );
  161  
  162       expect (component .userInfo) .toEqual(u ndefined);
  163       // exp ect(compon ent.export Permission ).toEqual( false);
  164       // exp ect(compon ent.editPe rmission). toEqual(fa lse);
  165       expect (component .roleAdmin ).toEqual( false);
  166  
  167       compon ent.export Permission  = true;
  168       compon ent.editPe rmission =  true;
  169       compon ent.roleAd min = true ;
  170  
  171       route. snapshot.q ueryParams  = undefin ed;
  172  
  173       compon ent.ngOnIn it(); // d on't die!
  174  
  175       expect (component .userInfo) .toEqual(u serInfoRet urned);
  176       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  177       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  178       // exp ect(compon ent.export Permission ).toEqual(
  179       //   u serInfoRet urned.perm issions['v iewAttachm ent']['exp ortPermiss ion']
  180       // );  // Actuall y, undefin ed
  181       // exp ect(compon ent.export Permission ).toBeUnde fined();
  182       // exp ect(compon ent.editPe rmission). toEqual(un defined);  // another  way
  183  
  184       expect (component .userInfo. userRoles) .toBeUndef ined(); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  185       expect (component .roleAdmin ).toEqual( false); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  186     });
  187  
  188     it('test  ngOnInit  method: {e xportPermi ssion, edi tPermissio n} = {fals e, true}',  () => {
  189       spyOn( component,  'formInit ');
  190       spyOn( component,  'setLocat ion');
  191  
  192       const  userInfoRe turned = {
  193         perm issions: {
  194           vi ewAttachme nt: {
  195              exportPerm ission: fa lse,
  196              editPermis sion: true
  197           }
  198         }
  199       };
  200       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  201         () = > userInfo Returned
  202       );
  203  
  204       expect (component .userInfo) .toEqual(u ndefined);
  205       expect (component .exportPer mission).t oEqual(fal se);
  206       expect (component .editPermi ssion).toE qual(false );
  207       expect (component .roleAdmin ).toEqual( false);
  208  
  209       compon ent.export Permission  = true;
  210       compon ent.editPe rmission =  false;
  211       compon ent.roleAd min = fals e;
  212  
  213       route. snapshot.q ueryParams  = undefin ed;
  214  
  215       compon ent.ngOnIn it(); // d on't die!
  216  
  217       expect (component .userInfo) .toEqual(u serInfoRet urned);
  218       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  219       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  220       expect (component .exportPer mission).t oEqual(fal se);
  221       expect (component .editPermi ssion).toE qual(true) ;
  222  
  223       expect (component .userInfo. userRoles) .toBeUndef ined(); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  224       expect (component .roleAdmin ).toEqual( false); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  225     });
  226  
  227     it('test  ngOnInit  method: {e xportPermi ssion, edi tPermissio n} = {true , false}',  () => {
  228       spyOn( component,  'formInit ');
  229       spyOn( component,  'setLocat ion');
  230  
  231       const  userInfoRe turned = {
  232         perm issions: {
  233           vi ewAttachme nt: {
  234              exportPerm ission: tr ue,
  235              editPermis sion: fals e
  236           }
  237         }
  238       };
  239       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  240         () = > userInfo Returned
  241       );
  242  
  243       expect (component .userInfo) .toEqual(u ndefined);
  244       expect (component .exportPer mission).t oEqual(fal se);
  245       expect (component .editPermi ssion).toE qual(false );
  246       expect (component .roleAdmin ).toEqual( false);
  247  
  248       compon ent.export Permission  = false;
  249       compon ent.editPe rmission =  true;
  250       compon ent.roleAd min = fals e;
  251  
  252       route. snapshot.q ueryParams  = undefin ed;
  253  
  254       compon ent.ngOnIn it(); // d on't die!
  255  
  256       expect (component .userInfo) .toEqual(u serInfoRet urned);
  257       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  258       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  259       expect (component .exportPer mission).t oEqual(tru e);
  260       expect (component .editPermi ssion).toE qual(false );
  261  
  262       expect (component .userInfo. userRoles) .toBeUndef ined(); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  263       expect (component .roleAdmin ).toEqual( false); //  roleAdmin  is set fa lse if com ponent.use rInfo exis ts but com ponent.use rInfo.user Roles is f alsy
  264     });
  265  
  266     it('test  ngOnInit  method:  u serRoles:  no ADMIN',  () => {
  267       spyOn( component,  'formInit ');
  268       spyOn( component,  'setLocat ion');
  269  
  270       const  userInfoRe turned = {
  271         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  272         perm issions: {
  273           vi ewAttachme nt: {
  274              exportPerm ission: tr ue,
  275              editPermis sion: fals e
  276           }
  277         }
  278       };
  279       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  280         () = > userInfo Returned
  281       );
  282  
  283       expect (component .userInfo) .toEqual(u ndefined);
  284       expect (component .exportPer mission).t oEqual(fal se);
  285       expect (component .editPermi ssion).toE qual(false );
  286       expect (component .roleAdmin ).toEqual( false);
  287  
  288       compon ent.export Permission  = false;
  289       compon ent.editPe rmission =  true;
  290       compon ent.roleAd min = true ;
  291  
  292       route. snapshot.q ueryParams  = undefin ed;
  293  
  294       compon ent.ngOnIn it(); // d on't die!
  295  
  296       expect (component .userInfo) .toEqual(u serInfoRet urned);
  297       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  298       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  299       expect (component .exportPer mission).t oEqual(tru e);
  300       expect (component .editPermi ssion).toE qual(false );
  301  
  302       expect (component .roleAdmin ).toEqual( false); //  roleAdmin  is set fa lse if no  "ADMIN" ro le
  303     });
  304  
  305     it('test  ngOnInit  method: us erRoles: A DMIN', ()  => {
  306       spyOn( component,  'formInit ');
  307       spyOn( component,  'setLocat ion');
  308  
  309       const  userInfoRe turned = {
  310         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 ', 'ARS_AD MIN'],
  311         perm issions: {
  312           vi ewAttachme nt: {
  313              exportPerm ission: tr ue,
  314              editPermis sion: fals e
  315           }
  316         }
  317       };
  318       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  319         () = > userInfo Returned
  320       );
  321  
  322       expect (component .userInfo) .toEqual(u ndefined);
  323       expect (component .exportPer mission).t oEqual(fal se);
  324       expect (component .editPermi ssion).toE qual(false );
  325       expect (component .roleAdmin ).toEqual( false);
  326  
  327       compon ent.export Permission  = false;
  328       compon ent.editPe rmission =  true;
  329       compon ent.roleAd min = true ;
  330  
  331       route. snapshot.q ueryParams  = undefin ed;
  332  
  333       compon ent.ngOnIn it(); // d on't die!
  334  
  335       expect (component .userInfo) .toEqual(u serInfoRet urned);
  336       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  337       // sin ce compone nt.userInf o was unde fined, exp ect no cha nge to per missions a nd roles.
  338       expect (component .exportPer mission).t oEqual(tru e);
  339       expect (component .editPermi ssion).toE qual(false );
  340  
  341       expect (component .roleAdmin ).toEqual( true); //  roleAdmin  is set tru e if "ADMI N" role
  342     });
  343  
  344     it('test  ngOnInit  method: wi th authent icationSer vice.getDe codedUserI nfo return ing no "pe rmissions. additional Informatio n" propert y', () =>  {
  345       spyOn( component,  'formInit ');
  346       spyOn( component,  'setLocat ion');
  347  
  348       const  userInfoRe turned = {
  349         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  350         perm issions: { }
  351       };
  352       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  353         () = > userInfo Returned
  354       );
  355  
  356       expect (component .userInfo) .toEqual(u ndefined);
  357       expect (component .exportPer mission).t oEqual(fal se);
  358       expect (component .editPermi ssion).toE qual(false );
  359       expect (component .roleAdmin ).toEqual( false);
  360  
  361       route. snapshot.q ueryParams  = undefin ed;
  362  
  363       compon ent.ngOnIn it();
  364  
  365       expect (component .formInit) .toHaveBee nCalled();
  366       expect (authentic ationServi ce.getDeco dedUserInf o).toHaveB eenCalled( );
  367       expect (component .setLocati on).toHave BeenCalled ();
  368  
  369       expect (component .userInfo) .toEqual(u serInfoRet urned);
  370       expect (component .exportPer mission).t oEqual(fal se);
  371       expect (component .editPermi ssion).toE qual(false );
  372       expect (component .roleAdmin ).toEqual( false);
  373     });
  374  
  375     it('test  ngOnInit  method: "p ermissions .additiona lInformati on" is {}' , () => {
  376       spyOn( component,  'formInit ');
  377       spyOn( component,  'setLocat ion');
  378  
  379       const  userInfoRe turned = {
  380         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  381         perm issions: {
  382           ad ditionalIn formation:  {}
  383         }
  384       };
  385       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  386         () = > userInfo Returned
  387       );
  388  
  389       expect (component .userInfo) .toEqual(u ndefined);
  390       expect (component .exportPer mission).t oEqual(fal se);
  391       expect (component .editPermi ssion).toE qual(false );
  392       expect (component .roleAdmin ).toEqual( false);
  393  
  394       route. snapshot.q ueryParams  = undefin ed;
  395  
  396       compon ent.ngOnIn it();
  397  
  398       expect (component .formInit) .toHaveBee nCalled();
  399       expect (authentic ationServi ce.getDeco dedUserInf o).toHaveB eenCalled( );
  400       expect (component .setLocati on).toHave BeenCalled ();
  401  
  402       expect (component .userInfo) .toEqual(u serInfoRet urned);
  403       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  404       expect (component .exportPer mission).t oEqual(fal se);
  405       expect (component .editPermi ssion).toE qual(false );
  406       expect (component .roleAdmin ).toEqual( false);
  407     });
  408  
  409     it('test  ngOnInit  method: ex portPermis sion, edit Permission , roleAdmi n  with us erInfoRetu rned.permi ssions mis sing ', ()  => {
  410       spyOn( component,  'formInit ');
  411       spyOn( component,  'setLocat ion');
  412  
  413       const  userInfoRe turned = {
  414         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 ']
  415         // D o not incl ude permis sions:, th at's what  is being t ested.
  416         // p ermissions : {
  417         //    additiona lInformati on: { }
  418         // }
  419       };
  420       spyOn( authentica tionServic e, 'getDec odedUserIn fo').and.c allFake(
  421         () = > userInfo Returned
  422       );
  423  
  424       expect (component .userInfo) .toEqual(u ndefined);
  425       expect (component .exportPer mission).t oEqual(fal se);
  426       expect (component .editPermi ssion).toE qual(false );
  427       expect (component .roleAdmin ).toEqual( false);
  428  
  429       compon ent.export Permission  = false;
  430       compon ent.editPe rmission =  false;
  431       compon ent.roleAd min = fals e;
  432  
  433       route. snapshot.q ueryParams  = undefin ed;
  434  
  435       compon ent.ngOnIn it();
  436  
  437       expect (component .userInfo) .toEqual(u serInfoRet urned);
  438       // exp ect(compon ent.permis sions).toE qual(userI nfoReturne d.permissi ons); // n o longer u sed
  439       expect (component .exportPer mission).t oEqual(fal se);
  440       expect (component .editPermi ssion).toE qual(false );
  441       expect (component .roleAdmin ).toEqual( false);
  442     });
  443  
  444     it('test  ngOnChang es method:  input "ch ange" para meter has  "selectAtt achment" a nd "select edAttachme nt.current Value" pro perties on ly', () =>  {
  445       expect (component .cleanSele ctedAttach ment).toEq ual(null);
  446       compon ent.select edAttachme nt = 'Some SelectedAt tachment';
  447       expect (component .selectedA ttachmentN ame).toEqu al(null);
  448       expect (document. body.style .overflow) .toEqual(' ');
  449  
  450       spyOn( _window.na tiveWindow .history,  'pushState ');
  451       spyOn( component,  'closeVie wer');
  452  
  453       // let  bypassSec urityTrust ResourceUr lReturnVal ue = 'bypa ssSecurity TrustResou rceUrlRetu rnValue';
  454       // spy On(sanitiz er, 'bypas sSecurityT rustResour ceUrl').an d.callFake (
  455       //   ( ) => bypas sSecurityT rustResour ceUrlRetur nValue
  456       // );
  457  
  458       let ch ange;
  459       change  = {
  460         sele ctedAttach ment: {
  461           cu rrentValue : '/first/ second/thi rd/fourth/ last'
  462         }
  463       };
  464       compon ent['locat ion'].path  = (includ eHash?: bo olean) =>  '/ewv';
  465       compon ent.ngOnCh anges(chan ge);
  466  
  467       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(byp assSecurit yTrustReso urceUrlRet urnValue);
  468       expect (component .selectedA ttachment) .toEqual(' SomeSelect edAttachme nt');
  469       // exp ect(compon ent.select edAttachme ntName).to Equal('las t');
  470       expect (document. body.style .overflow) .toEqual(' ');
  471  
  472       expect (_window.n ativeWindo w.history. pushState) .not.toHav eBeenCalle d();
  473       expect (component .closeView er).not.to HaveBeenCa lled();
  474       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).toHa veBeenCall ed();
  475       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).toHa veBeenCall edWith('So meSelected Attachment ');
  476     });
  477  
  478     it('test  ngOnChang es method:  input "ch ange" para meter has  "open" and  "open.cur rentValue"  propertie s only', ( ) => {
  479       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(nul l);
  480       compon ent.select edAttachme nt = 'Some SelectedAt tachment';
  481       expect (component .selectedA ttachmentN ame).toEqu al(null);
  482       expect (document. body.style .overflow) .toEqual(' ');
  483  
  484       // spy On(_window .nativeWin dow.histor y, 'pushSt ate');
  485       // spy On(compone nt, 'close Viewer');
  486       spyOn( component,  'onViewAt tachment') ;
  487       spyOn( component,  'setLocat ion');
  488  
  489       // let  bypassSec urityTrust ResourceUr lReturnVal ue = 'bypa ssSecurity TrustResou rceUrlRetu rnValue';
  490       // spy On(sanitiz er, 'bypas sSecurityT rustResour ceUrl').an d.callFake (
  491       //   ( ) => bypas sSecurityT rustResour ceUrlRetur nValue
  492       // );
  493  
  494       let ch ange;
  495       change  = {
  496         open : {
  497           cu rrentValue : '/first/ second/thi rd/fourth/ last'
  498         }
  499       };
  500       compon ent['locat ion'].path  = (includ eHash?: bo olean) =>  '/ewv';
  501       compon ent.ngOnCh anges(chan ge);
  502  
  503       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(und efined);
  504       expect (component .selectedA ttachment) .toEqual(' SomeSelect edAttachme nt');
  505       // exp ect(compon ent.select edAttachme ntName).to Equal(null );
  506       expect (document. body.style .overflow) .toEqual(' hidden');
  507  
  508       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).toHave BeenCalled ();
  509       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).toHave BeenCalled With({},'e wv', '/ewv ');
  510       // exp ect(compon ent.closeV iewer).toH aveBeenCal led();
  511       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).not. toHaveBeen Called();
  512       expect (component .onViewAtt achment).t oHaveBeenC alled();
  513       expect (component .setLocati on).toHave BeenCalled ();
  514     });
  515  
  516     it('test  ngOnChang es method:  input "ch ange" para meter has  "open", "o pen.curren tValue", " selectAtta chment", a nd "select edAttachme nt.current Value" pro perties',  () => {
  517       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(nul l);
  518       compon ent.select edAttachme nt = 'Some SelectedAt tachment';
  519       expect (component .selectedA ttachmentN ame).toEqu al(null);
  520       expect (document. body.style .overflow) .toEqual(' ');
  521  
  522       // spy On(_window .nativeWin dow.histor y, 'pushSt ate');
  523       // spy On(compone nt, 'close Viewer');
  524  
  525       spyOn( component,  'setLocat ion');
  526       spyOn( component,  'onViewAt tachment') ;
  527  
  528       // let  bypassSec urityTrust ResourceUr lReturnVal ue = 'bypa ssSecurity TrustResou rceUrlRetu rnValue';
  529       // spy On(sanitiz er, 'bypas sSecurityT rustResour ceUrl').an d.callFake (
  530       //   ( ) => bypas sSecurityT rustResour ceUrlRetur nValue
  531       // );
  532  
  533       let ch ange;
  534       change  = {
  535         open : {
  536           cu rrentValue : '/first/ second/thi rd/fourth/ last'
  537         },
  538         sele ctedAttach ment: {
  539           cu rrentValue : '/first/ second/thi rd/fourth/ last'
  540         }
  541       };
  542       compon ent['locat ion'].path  = (includ eHash?: bo olean) =>  '/search27 5';
  543       compon ent.ngOnCh anges(chan ge);
  544  
  545       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(byp assSecurit yTrustReso urceUrlRet urnValue);
  546       expect (component .selectedA ttachment) .toEqual(' SomeSelect edAttachme nt');
  547       // exp ect(compon ent.select edAttachme ntName).to Equal('las t');
  548       expect (document. body.style .overflow) .toEqual(' hidden');
  549  
  550       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).toHave BeenCalled ();
  551       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).toHave BeenCalled With({},'s earch275',  '/search2 75');
  552       // exp ect(compon ent.closeV iewer).toH aveBeenCal led();
  553       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).toHa veBeenCall ed();
  554       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).toHa veBeenCall edWith('So meSelected Attachment ');
  555       expect (component .setLocati on).toHave BeenCalled ();
  556       expect (component .onViewAtt achment).t oHaveBeenC alled();
  557     });
  558  
  559     it('test  ngOnChang es method:  input "ch ange" para meter has  no "open"  nor "selec tedAttachm ent" prope rties', ()  => {
  560       expect (component .cleanSele ctedAttach ment).toEq ual(null);
  561       compon ent.select edAttachme nt = 'Some SelectedAt tachment';
  562       expect (component .selectedA ttachmentN ame).toEqu al(null);
  563       expect (document. body.style .overflow) .toEqual(' ');
  564  
  565       spyOn( component,  'setLocat ion');
  566       spyOn( component,  'onViewAt tachment') ;
  567  
  568       // spy On(_window .nativeWin dow.histor y, 'pushSt ate');
  569       // spy On(compone nt, 'close Viewer');
  570  
  571       // let  bypassSec urityTrust ResourceUr lReturnVal ue = 'bypa ssSecurity TrustResou rceUrlRetu rnValue';
  572       // spy On(sanitiz er, 'bypas sSecurityT rustResour ceUrl').an d.callFake (
  573       //   ( ) => bypas sSecurityT rustResour ceUrlRetur nValue
  574       // );
  575  
  576       let ch ange;
  577       change  = {};
  578       compon ent['locat ion'].path  = (includ eHash?: bo olean) =>  '/ewv';
  579       compon ent.ngOnCh anges(chan ge);
  580  
  581       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(und efined);
  582       expect (component .selectedA ttachment) .toEqual(' SomeSelect edAttachme nt');
  583       expect (component .selectedA ttachmentN ame).toEqu al(null);
  584       expect (document. body.style .overflow) .toEqual(' ');
  585  
  586       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).not.to HaveBeenCa lled();
  587       // exp ect(compon ent.closeV iewer).not .toHaveBee nCalled();
  588       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).not. toHaveBeen Called();
  589  
  590       expect (component .setLocati on).not.to HaveBeenCa lled();
  591       expect (component .onViewAtt achment).n ot.toHaveB eenCalled( );
  592     });
  593  
  594     it('test  ngOnChang es method:  input "ch ange" para meter has  "open" and  "selected Attachment " properti es, but th ese proper ties have  no "curren tValue" pr operty ',  () => {
  595       expect (component .cleanSele ctedAttach ment).toEq ual(null);
  596       compon ent.select edAttachme nt = 'Some SelectedAt tachment';
  597       expect (component .selectedA ttachmentN ame).toEqu al(null);
  598       expect (document. body.style .overflow) .toEqual(' ');
  599  
  600       // spy On(_window .nativeWin dow.histor y, 'pushSt ate');
  601       // spy On(compone nt, 'close Viewer');
  602  
  603       spyOn( component,  'setLocat ion');
  604       spyOn( component,  'onViewAt tachment') ;
  605  
  606       // let  bypassSec urityTrust ResourceUr lReturnVal ue = 'bypa ssSecurity TrustResou rceUrlRetu rnValue';
  607       // spy On(sanitiz er, 'bypas sSecurityT rustResour ceUrl').an d.callFake (
  608       //   ( ) => bypas sSecurityT rustResour ceUrlRetur nValue
  609       // );
  610  
  611       let ch ange;
  612       change  = {
  613         clea nSelectedA ttachment:  {},
  614         open : {}
  615       };
  616       compon ent.ngOnCh anges(chan ge);
  617  
  618       // exp ect(compon ent.cleanS electedAtt achment).t oEqual(und efined);
  619       // exp ect(compon ent.select edAttachme nt).toEqua l('SomeSel ectedAttac hment');
  620       // exp ect(compon ent.select edAttachme ntName).to Equal(null );
  621       expect (document. body.style .overflow) .toEqual(' ');
  622  
  623       // exp ect(_windo w.nativeWi ndow.histo ry.pushSta te).not.to HaveBeenCa lled();
  624       // exp ect(compon ent.closeV iewer).not .toHaveBee nCalled();
  625       // exp ect(saniti zer.bypass SecurityTr ustResourc eUrl).not. toHaveBeen Called();
  626  
  627       expect (component .setLocati on).not.to HaveBeenCa lled();
  628       expect (component .onViewAtt achment).n ot.toHaveB eenCalled( );
  629     });
  630  
  631     it('test  closeView er method' , () => {
  632       compon ent.formIn it();
  633  
  634       compon ent.fileEx tension =  'extension ';
  635       compon ent.cleanS electedAtt achment =  'CleanSele ctedAttach gment';
  636       docume nt.body.st yle.overfl ow = '';
  637       compon ent.attach mentModifi ed = true;
  638       compon ent.associ ateView =  true;
  639  
  640       spyOn( component. form, 'res et');
  641       spyOn( component,  'reset');
  642       spyOn( component. notify, 'e mit');
  643  
  644       const  viewerNoti fy = {
  645         open : false,
  646         upda teTable: c omponent.a ttachmentM odified
  647       };
  648  
  649       compon ent.closeV iewer();
  650  
  651       expect (component .fileExten sion).toEq ual(null);
  652       expect (component .cleanSele ctedAttach ment).toEq ual(null);
  653       expect (document. body.style .overflow) .toEqual(' visible');
  654       expect (component .attachmen tModified) .toEqual(f alse);
  655       expect (component .associate View).toEq ual(false) ;
  656  
  657       expect (component .form.rese t).toHaveB eenCalled( );
  658       expect (component .reset).to HaveBeenCa lled();
  659       expect (component .notify.em it).toHave BeenCalled ();
  660       expect (component .notify.em it).toHave BeenCalled With(viewe rNotify);
  661     });
  662  
  663     it('test  viewAssoc iateForm m ethod: "co mponent.as sociateVie w" is bool ean false' , () => {
  664       compon ent.formIn it();
  665       compon ent.associ ateView =  false;
  666       compon ent.form.c ontrols['u nmatched83 7Id'].setV alue('1234 ');
  667  
  668       compon ent.viewAs sociateFor m();
  669  
  670       expect (component .associate View).toBe (true);
  671       expect (component .failed).t oEqual(fal se);
  672       expect (component .form.get( 'unmatched 837Id').va lue).toEqu al('1234') ;
  673     });
  674  
  675     it('test  viewAssoc iateForm m ethod: "co mponent.as sociateVie w" is bool ean true',  () => {
  676       compon ent.formIn it();
  677       compon ent.associ ateView =  true;
  678       compon ent.form.c ontrols['u nmatched83 7Id'].setV alue('1234 ');
  679  
  680       compon ent.viewAs sociateFor m();
  681  
  682       expect (component .associate View).toBe (false);
  683       expect (component .failed).t oEqual(fal se);
  684       expect (component .form.get( 'unmatched 837Id').va lue).toEqu al(null);
  685     });
  686  
  687     it('test  onArchive View metho d', () =>  {
  688       compon ent.modalV iew = fals e;
  689       compon ent.onArch iveView();
  690       expect (component .modalView ).toBe(tru e);
  691     });
  692  
  693     it('test  onModalCl ose method ', () => {
  694       compon ent.modalV iew = true ;
  695       compon ent.onModa lClose();
  696       expect (component .modalView ).toBe(fal se);
  697     });
  698  
  699     it('test  onArchive  method --  skip', ()  => {
  700       // com ponent.onA rchive();
  701     });
  702  
  703     it('test  reActivat e method - - skip', ( ) => {
  704       // com ponent.reA ctivate();
  705     });
  706  
  707     it('test  formInit  method: fo rm should  be initial ized', ()  => {
  708       expect (component .form).toE qual(undef ined);
  709  
  710       compon ent.formIn it();
  711  
  712       expect (component .form).toB eDefined() ;
  713       expect (component .form).not .toBeNull( );
  714     });
  715  
  716     it('test  formInit  method: ve rify that  initially  the form i s in the i nvalid sta te', () =>  {
  717       compon ent.formIn it();
  718  
  719       expect (component .form.get( 'unmatched 837Id').va lid).toEqu al(false);
  720       expect (component .form.vali d).toEqual (false);
  721     });
  722  
  723     it('test  formInit  method: in valid form  if "unmat ched837Id"  value is  an empty s tring', ()  => {
  724       compon ent.formIn it();
  725  
  726       compon ent.form.g et('unmatc hed837Id') .setValue( '');
  727  
  728       expect (component .form.get( 'unmatched 837Id').va lid).toEqu al(false);
  729       expect (component .form.vali d).toEqual (false);
  730     });
  731  
  732     it('test  formInit  method: in valid form  if "unmat ched837Id"  value has  any chara cters that  are not n umbers', ( ) => {
  733       compon ent.formIn it();
  734  
  735       compon ent.form.g et('unmatc hed837Id') .setValue( '6789iop') ;
  736  
  737       expect (component .form.get( 'unmatched 837Id').va lid).toEqu al(false);
  738       expect (component .form.vali d).toEqual (false);
  739     });
  740  
  741     it('test  formInit  method: va lid form i f "unmatch ed837Id" v alue has a ll numbers ', () => {
  742       compon ent.formIn it();
  743  
  744       compon ent.form.g et('unmatc hed837Id') .setValue( '6789');
  745  
  746       expect (component .form.get( 'unmatched 837Id').va lid).toEqu al(true);
  747       expect (component .form.vali d).toEqual (true);
  748     });
  749  
  750     it('test  reset met hod', () = > {
  751       expect (component .downloadD oc).toEqua l(false);
  752       expect (component .downloadR tf).toEqua l(false);
  753  
  754       compon ent.reset( );
  755  
  756       expect (component .downloadD oc).toEqua l(false);
  757       expect (component .downloadR tf).toEqua l(false);
  758  
  759       compon ent.reset( );
  760  
  761       expect (component .downloadD oc).toEqua l(false);
  762       expect (component .downloadR tf).toEqua l(false);
  763     });
  764  
  765     it('test  ngOnDestr oy method  viewedXml  = true', ( ) => {
  766       spyOn( component. subscripti on, 'unsub scribe');
  767       spyOn( attachment ViewerServ ice, 'clea nXmlTempFo lder').and .returnVal ue(
  768         Obse rvable.of( { message:  'MESSAGE'  })
  769       );
  770       compon ent.viewed Xml = true ;
  771       compon ent.ngOnDe stroy();
  772  
  773       expect (document. body.style .overflow) .toEqual(' visible');
  774       expect (component .subscript ion.unsubs cribe).toH aveBeenCal led();
  775       expect (attachmen tViewerSer vice.clean XmlTempFol der).toHav eBeenCalle d();
  776     });
  777  
  778     it('test  ngOnDestr oy method  viewedXml  = false',  () => {
  779       spyOn( component. subscripti on, 'unsub scribe');
  780       spyOn( attachment ViewerServ ice, 'clea nXmlTempFo lder').and .returnVal ue(
  781         Obse rvable.of( { message:  'MESSAGE'  })
  782       );
  783  
  784       compon ent.viewed Xml = fals e;
  785       compon ent.ngOnDe stroy();
  786  
  787       expect (document. body.style .overflow) .toEqual(' visible');
  788       expect (component .subscript ion.unsubs cribe).toH aveBeenCal ledTimes(0 );
  789       expect (attachmen tViewerSer vice.clean XmlTempFol der).toHav eBeenCalle dTimes(0);
  790     });
  791  
  792     it('test  onSubmit  method: "a ttachmentS ervice.mat ch" return s back dat a that has  a "respon se" proper ty', () =>  {
  793       compon ent.formIn it();
  794  
  795       compon ent.attach Key = {
  796         atta chIdLx: '' ,
  797         stat us: ''
  798       };
  799  
  800       expect (component .attachmen tModified) .toEqual(f alse);
  801       expect (component .success). toEqual(un defined);
  802       expect (component .associate View).toEq ual(false) ;
  803  
  804       expect (component .failed).t oEqual(und efined);
  805       expect (component .errorDesc ription).t oEqual(nul l);
  806  
  807       spyOn( component. subscripti on, 'add') ;
  808  
  809       const  returnedMa tchData =  { response : {} };
  810       spyOn( attachment ViewerServ ice, 'matc h').and.ca llFake(
  811         () = >
  812           ne w Observab le((observ er: Observ er<{}>) =>
  813              observer.n ext(return edMatchDat a)
  814           )
  815       );
  816  
  817       compon ent.onSubm it();
  818  
  819       jasmin e.clock(). tick(500);
  820       expect (component .success). toEqual(tr ue);
  821  
  822       jasmin e.clock(). tick(7001) ;
  823       expect (component .success). toEqual(fa lse);
  824  
  825       expect (component .attachmen tModified) .toEqual(t rue);
  826       expect (component .associate View).toEq ual(false) ;
  827  
  828       expect (component .failed).t oEqual(und efined);
  829       expect (component .errorDesc ription).t oEqual(nul l);
  830  
  831       expect (component .subscript ion.add).t oHaveBeenC alled();
  832       expect (attachmen tViewerSer vice.match ).toHaveBe enCalled() ;
  833     });
  834  
  835     it('test  onSubmit  method: "a ttachmentS ervice.mat ch" return s back dat a that has  no "respo nse" prope rty', () = > {
  836       compon ent.formIn it();
  837  
  838       compon ent.attach Key = {
  839         atta chIdLx: '' ,
  840         stat us: ''
  841       };
  842  
  843       expect (component .attachmen tModified) .toEqual(f alse);
  844       expect (component .success). toEqual(un defined);
  845       expect (component .associate View).toEq ual(false) ;
  846  
  847       expect (component .failed).t oEqual(und efined);
  848       expect (component .errorDesc ription).t oEqual(nul l);
  849  
  850       spyOn( component. subscripti on, 'add') ;
  851  
  852       const  returnedMa tchData =  {};
  853       spyOn( attachment ViewerServ ice, 'matc h').and.ca llFake(
  854         () = >
  855           ne w Observab le((observ er: Observ er<{}>) =>
  856              observer.n ext(return edMatchDat a)
  857           )
  858       );
  859  
  860       compon ent.onSubm it();
  861  
  862       jasmin e.clock(). tick(500);
  863       expect (component .success). toEqual(un defined);
  864  
  865       jasmin e.clock(). tick(7001) ;
  866       expect (component .success). toEqual(un defined);
  867  
  868       expect (component .attachmen tModified) .toEqual(t rue);
  869       expect (component .associate View).toEq ual(false) ;
  870  
  871       expect (component .failed).t oEqual(und efined);
  872       expect (component .errorDesc ription).t oEqual(nul l);
  873  
  874       expect (component .subscript ion.add).t oHaveBeenC alled();
  875       expect (attachmen tViewerSer vice.match ).toHaveBe enCalled() ;
  876     });
  877  
  878     it('test  onSubmit  method: "a ttachmentS ervice.mat ch" return s back err or respons e', () =>  {
  879       compon ent.formIn it();
  880  
  881       compon ent.attach Key = {
  882         atta chIdLx: '' ,
  883         stat us: ''
  884       };
  885  
  886       expect (component .attachmen tModified) .toEqual(f alse);
  887       expect (component .success). toEqual(un defined);
  888       expect (component .associate View).toEq ual(false) ;
  889  
  890       expect (component .failed).t oEqual(und efined);
  891       expect (component .errorDesc ription).t oEqual(nul l);
  892  
  893       spyOn( component. subscripti on, 'add') ;
  894  
  895       const  returnedMa tchErrorDa ta = {
  896         _bod y: JSON.st ringify({  message: ' ERROR MESS AGE' })
  897       };
  898       spyOn( attachment ViewerServ ice, 'matc h').and.re turnValue(
  899         Obse rvable.thr ow(returne dMatchErro rData)
  900       );
  901  
  902       compon ent.onSubm it();
  903  
  904       expect (component .success). toEqual(un defined);
  905  
  906       expect (component .attachmen tModified) .toEqual(f alse);
  907       expect (component .associate View).toEq ual(false) ;
  908  
  909       expect (component .failed).t oEqual(tru e);
  910       expect (component .errorDesc ription).t oEqual('ER ROR MESSAG E');
  911  
  912       expect (component .subscript ion.add).t oHaveBeenC alled();
  913       expect (attachmen tViewerSer vice.match ).toHaveBe enCalled() ;
  914     });
  915  
  916     // Curre ntly unuse d, but it  may return , do not D ELETE
  917     it('atta chmentFile Name', ()  => {
  918       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  919  
  920       expect (component .attachmen tFileName( undefined) ).toEqual( fake);
  921       expect (component .attachmen tFileName( '')).toEqu al(fake);
  922  
  923       'this; that.foo;a ny.thing.y ou.want'.s plit(';'). forEach(fi l => {
  924         expe ct(
  925           co mponent.at tachmentFi leName('at tachment;  filename='  + fil)
  926         ).to Equal(fil) ;
  927       });
  928     });
  929  
  930     // Curre ntly unuse d
  931     it(`test  attachmen tFileName  on [undefi ned, '']`,  () => {
  932       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  933       expect (component .attachmen tFileName( undefined) ).toEqual( fake);
  934       expect (component .attachmen tFileName( '')).toEqu al(fake);
  935     });
  936  
  937     // check  on attach mentFileNa me;
  938     it('test  attachmen tFileName' , () => {
  939       // pur e function , doesn't  need to be  re-starte d
  940       const  files = [
  941         'foo .bar',
  942         'a',
  943         'ave rylongfile name.with. lots. of d ots and []  odd chara cters!@#$% ^&*()',
  944         'eve n/a/path/n ame.pdf',
  945         // ' even\a\rea lly\big\na me.pdf', / / escapes?  \n  fails  to match
  946         'eve n\\a\\real ly\\big\\n ame.pdf'
  947       ];
  948       files. forEach(fi le => {
  949         // S imple file names are  returned u nchanged
  950         expe ct(compone nt.attachm entFileNam e(file)).t oEqual(fil e);
  951         // m atching "a ttachment; filename=$ {file}" re turns the  file
  952         expe ct(
  953           co mponent.at tachmentFi leName(`at tachment;f ilename=${ file}`)
  954         ).to Equal(file );
  955         expe ct(
  956           co mponent.at tachmentFi leName(`at tachment;  filename=$ {file}`)
  957         ).to Equal(file );
  958         expe ct(
  959           co mponent.at tachmentFi leName(`at tachment;   filename= ${file}`)
  960         ).to Equal(file );
  961         expe ct(
  962           co mponent.at tachmentFi leName(`at tachment;    filename =${file}`)
  963         ).to Equal(file );
  964  
  965         // e rroneous v ersions re turn the w hole strin g
  966         cons t shouldFa il = [
  967           `f ile=${file }`,
  968           `f ilename=${ file}`,
  969           `t achment; f ilename=${ file}`,
  970           `t he attachm ent; filen ame=${file }`,
  971           `a ttachment;  Filename= ${file}`,  // it's ca se-sensiti ve
  972           `A ttachment;  Filename= ${file}`,
  973           `a ttachment;  file=${fi le}`,
  974           `a ttachment;  name=${fi le}`
  975         ];
  976         shou ldFail.for Each(mess  => {
  977           ex pect(compo nent.attac hmentFileN ame(mess)) .toEqual(m ess);
  978         });
  979       });
  980     });
  981  
  982     it(`test  fileTYP s hould extr act extens ion, toUpp erCase()`,  () => {
  983       // fil eTYP is no t intended  to handle  "path/nam es.uhoh/fo o"
  984       // It  won't real ly matter  to us, sin ce we're o nly intere sted in fi le.EXT any way.
  985       const  cases = 'f oo=FOO,fis hy.gif=GIF ,far.far.a way=AWAY';
  986       cases. split(',') .forEach(t est => {
  987         cons t [arg, re s] = test. split('=') ;
  988         expe ct(res.toU pperCase() ).toEqual( res); // q uod custod iet custod iens // Ch eck res to  be upper  case, just  in case.
  989         expe ct(compone nt.fileTYP (arg)).toE qual(res);
  990       });
  991     });
  992  
  993     //////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ///
  994     // Thing s to test,  extracted  from atta chment-vie wer.compon ent.ts
  995     //////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ///
  996  
  997  
  998     it(`test  tabbable  => tabInde x`, () =>  {
  999       const  cases = 't tfft'; //  all transi tions from  bool to b ool
  1000       // let  prev = tr ue;
  1001       // exp ect(compon ent.tabInd ex).toEqua l('0');
  1002       cases. split(''). forEach(te st => {
  1003         cons t tabb = t est === 't ';
  1004         cons t tabI = t abb ? '0'  : '-1';
  1005         comp onent.tabI dx = tabI;
  1006         // c onsole.log (
  1007         //    `tabb= ${ tabb}, tab I= ${tabI} , componen t.tabbable = ${compon ent.tabIdx }`
  1008         // ) ;
  1009         expe ct(compone nt.tabIdx) .toEqual(t abI);
  1010       });
  1011     });
  1012  
  1013     //   con structor(
  1014     //   ngO nInit() {
  1015     //   ngO nChanges(c hange: Sim pleChanges ) {
  1016     //   set Location()  {
  1017     //   for mInit() {
  1018     //   onS ubmit() {
  1019     //   clo seViewer() : void {
  1020     //   vie wAssociate Form(): vo id {
  1021     //   onA rchiveView (): void {
  1022     //   onA rchive() {
  1023     //   reA ctivate()  {
  1024     //   onM odalClose( ): void {
  1025     //   res et() {
  1026  
  1027     // done   attachmen tFileName( contentDis position:  string) {
  1028  
  1029     // done   fileTYP(f ileName: s tring) {
  1030  
  1031     // ///// ////////// ////////// ////////// ////////// ////
  1032     // The f ollowing c alls all i nvolve bro wser actio ns that mu st be mock ed
  1033     // ///// ////////// ////////// ////////// ////////// ////
  1034  
  1035     // todo  onViewAtta chment() S pyOn(attac hmentViewe rService.v iewAttachm ent)
  1036     it('onVi ewAttachme nt attachK ey', () =>  {
  1037       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1038       spyOn( attachment ViewerServ ice, 'view Attachment '); // not  the viewe r, but the  file gett er
  1039  
  1040       const  blob = new  Blob(['te sting 1,2, 3']);
  1041       const  attContent Type = 'im age/gif';
  1042       const  attName =  'foo.gif';
  1043  
  1044       // TES T This cod e
  1045       // con st attachm entRequest : Attachme ntRequest  = {
  1046       //   v haName: th is.userInf o.userName ,
  1047       //   a ttachIdLx:  this.atta chIdLx, //  naming co nflict
  1048       //   a pplication Level: thi s.applicat ionLevel,
  1049       //   i sDownload:  true
  1050       // };
  1051       // thi s.attachme ntViewerSe rvice.expo rtAttachme nt(attachm entRequest ).subscrib e(
  1052       //   ( data: Resp onse) => { }, (error)  => {});
  1053       const  userInfoRe turned = {
  1054           userName:  ' AI ',
  1055         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1056         perm issions: {
  1057           vi ewAttachme nt: {
  1058              exportPerm ission: tr ue,
  1059              editPermis sion: fals e
  1060           }
  1061         }
  1062       };
  1063       compon ent.userIn fo = userI nfoReturne d;
  1064  
  1065       // com ponent.att achIdLx =  'MockId';  // a get f unction!
  1066       compon ent.attach Key = {
  1067         atta chIdLx: 'M ockId',
  1068         stat us: ''
  1069       };
  1070       compon ent.attach mentViewer Location =  'ATTACHME NT_VIEWER' ;
  1071     });
  1072  
  1073     it('onVi ewAttachme nt imgUrl' , () => {
  1074       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1075       const  blobType =  'applicat ion/octet- stream';
  1076       const  attContent Type = 'im age/gif';
  1077       const  attName =  'foo.gif';
  1078       const  attTYP = ' GIF'; // i n a forEac h, use att Name.split ('.').pop( ).toUpperC ase();
  1079       // Byp ass reques t: it is t ested abov e
  1080       const  _headers =  {
  1081         'con tent-type' : attConte ntType,
  1082         'x-a ttachment- name': att Name // no de expects  lower cas e!
  1083       };
  1084       const  getHeader  = (key: st ring) => _ headers[ke y.toLowerC ase()];
  1085       const  testBlob =  new Blob( ['testing  1,2,3'], {  type: blo bType });
  1086       logdbg ('testBlob =', testBl ob);
  1087       logdbg ('testBlob .type=', t estBlob.ty pe);
  1088       const  response =  {
  1089         blob : () => re sponse._bl ob, // kin da circula r
  1090         // _ blob: {...  testBlob} ,
  1091         _blo b: testBlo b,
  1092         head ers: {
  1093           ge t: (key: s tring) =>  _headers[k ey.toLower Case()],
  1094           ge tAll: (key : string)  => [_heade rs[key.toL owerCase() ]] // In t his case r eturn a si ngle item
  1095         }
  1096       };
  1097       ////// ////////// //////////
  1098       // Byp ass this c ode:  TEST ED ON ITS  OWN above.
  1099  
  1100       // log dbg(
  1101       //   ' onViewAtta chment at  attachment ViewerLoca tion',
  1102       //   t his.attach mentViewer Location
  1103       // );
  1104       // con st attachm entRequest : Attachme ntRequest  = {
  1105       //   v haName: th is.userInf o.userName ,
  1106       //   a ttachIdLx:  this.atta chIdLx,
  1107       //   a pplication Level: thi s.applicat ionLevel,
  1108       //   i sDownload:  false
  1109       // };
  1110  
  1111       // log dbg('attac hmentReque st', attac hmentReque st);
  1112       spyOn( attachment ViewerServ ice, 'view Attachment ').and.ret urnValue(
  1113         Obse rvable.of( response)
  1114       );
  1115  
  1116       compon ent.export Permission  = true;
  1117       compon ent.arsVie wer = true ;
  1118       const  userInfoRe turned = {
  1119           userName:  ' AI ',
  1120         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1121         perm issions: {
  1122           vi ewAttachme nt: {
  1123              exportPerm ission: tr ue,
  1124              editPermis sion: fals e
  1125           }
  1126         }
  1127       };
  1128       compon ent.userIn fo = userI nfoReturne d;
  1129       compon ent.attach Key = {
  1130         atta chIdLx: 'M ockId',
  1131         stat us: ''
  1132       };
  1133  
  1134       spyOn( _window.na tiveWindow .URL, 'cre ateObjectU RL').and.c allThrough ();
  1135  
  1136       //// T EST
  1137       compon ent.onView Attachment ();
  1138  
  1139       // thi s.attachme ntViewerSe rvice // n ot the vie wer, but t he file ge tter
  1140       //   . viewAttach ment(attac hmentReque st) // not  the view,  but the f ile get
  1141       //   . subscribe( (data: Res ponse) =>  {
  1142       //      // tslint :disable-n ext-line:n o-console
  1143       //      // logdbg ('onViewAt tachment d ata.header s=', data. headers);
  1144       //      // respon seType: Re sponseCont entType.Bl ob
  1145  
  1146       //      const con tentType =  data.head ers.get('c ontent-typ e').toStri ng();
  1147       //      const fil ename = th is.dataGet Attachment Name(data) ;
  1148       //      const nam e = filena me.split(' /').pop();  // drop a ny path pa rt
  1149       //      this.file Extension  = this.fil eTYP(name) ;
  1150       expect (component .fileExten sion).toBe (attTYP);
  1151       //      this.sele ctedAttach mentName =  name;
  1152       expect (component .selectedA ttachmentN ame).toBe( attName);
  1153       //      const isI mage = isI mageExt(th is.fileExt ension);
  1154       //      // Now th ey want to  exportAsP DF the XML , too! ref actor.
  1155       //      this.expo rtAsPDFSho w =
  1156       //        isImage  &&
  1157       //        this.ex portPermis sion &&
  1158       //        (this.a rsViewer | | this.fpp sViewer);
  1159  
  1160       expect (component .exportAsP DFShow).to Be(true);
  1161  
  1162  
  1163       const  fakeURL =  'fake://ur l';
  1164       expect (_window.n ativeWindo w.URL.crea teObjectUR L).toHaveB eenCalled( );
  1165       expect (component .selectedA ttachment) .toBeNull( );
  1166       expect (component .cleanSele ctedAttach ment).toBe Null();
  1167       expect (component .xmlSrc).t oBeNull();
  1168       expect (component .imgSrc).t oBe(true);  // true?  that's str ange
  1169       // exp ect(compon ent.imgSrc ).toBe(fak eURL); //  What I rea lly expect ed
  1170       //      }
  1171       //   } );
  1172     });
  1173  
  1174     // // to do    nonI E_saveAs(b lob: Blob,  fileName:  string)
  1175  
  1176     // todo   onExportA ttachment( )
  1177     it('test  onExportA ttachment  unauthoriz ed', () =>  {
  1178       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1179       const  blobType =  'applicat ion/octet- stream';
  1180       const  attContent Type = 'im age/gif';
  1181       const  attName =  'foo.gif';
  1182       const  attTYP = ' GIF'; // i n a forEac h, use att Name.split ('.').pop( ).toUpperC ase();
  1183  
  1184       const  _headers =  {
  1185         'con tent-type' : attConte ntType,
  1186         'x-a ttachment- name': att Name // no de expects  lower cas e!
  1187       };
  1188       const  getHeader  = (key: st ring) => _ headers[ke y.toLowerC ase()];
  1189       const  testBlob =  new Blob( ['testing  1,2,3'], {  type: blo bType });
  1190       logdbg ('testBlob =', testBl ob);
  1191       logdbg ('testBlob .type=', t estBlob.ty pe);
  1192       const  response =  {
  1193         blob : () => re sponse._bl ob, // kin da circula r
  1194         // _ blob: {...  testBlob} ,
  1195         _blo b: testBlo b,
  1196         head ers: {
  1197           ge t: (key: s tring) =>  _headers[k ey.toLower Case()],
  1198           ge tAll: (key : string)  => [_heade rs[key.toL owerCase() ]] // In t his case r eturn a si ngle item
  1199         }
  1200       };
  1201  
  1202       spyOn( attachment ViewerServ ice, 'expo rtAttachme nt').and.r eturnValue (
  1203         Obse rvable.of( response)
  1204       );
  1205  
  1206       spyOn( _window.na tiveWindow .navigator , 'msSaveO rOpenBlob' ); // .and .callFake( blob, attN ame);
  1207  
  1208       //   c onst fileN ame = this .dataGetAt tachmentNa me(data);
  1209       //   t his.fileEx tension =  this.fileT YP(fileNam e);
  1210  
  1211       const  userInfoRe turned = {
  1212           userName:  ' AI ',
  1213         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1214         perm issions: {
  1215           vi ewAttachme nt: {
  1216              exportPerm ission: fa lse,
  1217              editPermis sion: fals e
  1218           }
  1219         }
  1220       };
  1221  
  1222       compon ent.userIn fo = userI nfoReturne d;
  1223       compon ent.export Permission  = false;   // overri de ngInit
  1224       spyOn( component,  'dataGetA ttachmentN ame').and. callFake(( data: Resp onse) => ' att-xxx.gi f.pdf');
  1225       spyOn( component,  'dataBlob AsType').a nd.callFak e((data: R esponse) = > testBlob );
  1226       spyOn( component,  'saveAs') ;
  1227  
  1228       //// T EST ////
  1229       compon ent.onExpo rtAttachme nt();
  1230  
  1231       // Abo rts becaus e componen t.exportPe rmission = == false;
  1232       expect (attachmen tViewerSer vice.expor tAttachmen t).not.toH aveBeenCal led();
  1233  
  1234       expect (component .dataGetAt tachmentNa me).not.to HaveBeenCa lled();
  1235       expect (component .dataBlobA sType).not .toHaveBee nCalled();
  1236       expect (component .saveAs).n ot.toHaveB eenCalled( );
  1237  
  1238       expect (_window.n ativeWindo w.navigato r.msSaveOr OpenBlob). not.toHave BeenCalled ();
  1239       // Sid e effects:
  1240       expect (component .selectedA ttachmentN ame).toEqu al(null);
  1241       expect (component .fileExten sion).toEq ual(null);
  1242  
  1243     });
  1244  
  1245     it('test  onExportA ttachment  authorized ', () => {
  1246       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1247       const  blobType =  'applicat ion/octet- stream';
  1248       const  attContent Type = 'im age/gif';
  1249       const  attName =  'foo.gif';
  1250       const  attTYP = ' GIF'; // i n a forEac h, use att Name.split ('.').pop( ).toUpperC ase();
  1251  
  1252       const  _headers =  {
  1253         'con tent-type' : attConte ntType,
  1254         'x-a ttachment- name': att Name // no de expects  lower cas e!
  1255       };
  1256       const  getHeader  = (key: st ring) => _ headers[ke y.toLowerC ase()];
  1257       const  testBlob =  new Blob( ['testing  1,2,3'], {  type: blo bType });
  1258       logdbg ('testBlob =', testBl ob);
  1259       logdbg ('testBlob .type=', t estBlob.ty pe);
  1260       const  response =  {
  1261         blob : () => re sponse._bl ob, // kin da circula r
  1262         // _ blob: {...  testBlob} ,
  1263         _blo b: testBlo b,
  1264         head ers: {
  1265           ge t: (key: s tring) =>  _headers[k ey.toLower Case()],
  1266           ge tAll: (key : string)  => [_heade rs[key.toL owerCase() ]] // In t his case r eturn a si ngle item
  1267         }
  1268       };
  1269  
  1270       spyOn( attachment ViewerServ ice, 'expo rtAttachme nt').and.r eturnValue (
  1271         Obse rvable.of( response)
  1272       );
  1273  
  1274       spyOn( _window.na tiveWindow .navigator , 'msSaveO rOpenBlob' ); // .and .callFake( blob, attN ame);
  1275  
  1276       const  userInfoRe turned = {
  1277           userName:  ' AI ',
  1278         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1279         perm issions: {
  1280           vi ewAttachme nt: {
  1281              exportPerm ission: tr ue,
  1282              editPermis sion: fals e
  1283           }
  1284         }
  1285       };
  1286       compon ent.attach Key = {
  1287         atta chIdLx: 'M ockId',
  1288         stat us: ''
  1289       };
  1290       compon ent.userIn fo = userI nfoReturne d;  // byp ass ngInit
  1291       compon ent.export Permission  = true;   // overrid e ngInit
  1292       spyOn( component,  'dataGetA ttachmentN ame').and. callFake(( data: Resp onse) => a ttName);
  1293       spyOn( component,  'dataBlob AsType').a nd.callFak e((data: R esponse) = > testBlob );
  1294       spyOn( component,  'saveAs') ;
  1295  
  1296       //// T EST ////
  1297       compon ent.onExpo rtAttachme nt();
  1298  
  1299       // Bec ause ent.e xportPermi ssion = tr ue
  1300       expect (attachmen tViewerSer vice.expor tAttachmen t).toHaveB eenCalled( );
  1301  
  1302       expect (component .dataGetAt tachmentNa me).toHave BeenCalled ();
  1303       expect (component .dataBlobA sType).toH aveBeenCal led();
  1304       expect (component .saveAs).t oHaveBeenC alled();
  1305  
  1306       expect (component .saveAs).t oHaveBeenC alledWith( testBlob,  component. attachKey. attachIdLx  + '-' + a ttName);
  1307       // No  callThroug h
  1308       expect (_window.n ativeWindo w.navigato r.msSaveOr OpenBlob). not.toHave BeenCalled ();
  1309  
  1310       // non  Side effe cts, these  belong to  viewAttac hment, and  should no t be chang ed:
  1311       expect (component .selectedA ttachmentN ame).toEqu al(null);
  1312       expect (component .fileExten sion).toEq ual(null);
  1313  
  1314     });
  1315  
  1316     // todo   onExportA sPDF() {
  1317     it('test  onExportA sPDF unaut horized',  () => {
  1318       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1319       const  blobType =  'applicat ion/octet- stream';
  1320       const  attContent Type = 'im age/gif';
  1321       const  attName =  'foo.gif';
  1322       const  attTYP = ' GIF'; // i n a forEac h, use att Name.split ('.').pop( ).toUpperC ase();
  1323       const  _headers =  {
  1324         'con tent-type' : attConte ntType,
  1325         'x-a ttachment- name': att Name // no de expects  lower cas e!
  1326       };
  1327       const  getHeader  = (key: st ring) => _ headers[ke y.toLowerC ase()];
  1328       const  testBlob =  new Blob( ['testing  1,2,3'], {  type: blo bType });
  1329       logdbg ('testBlob =', testBl ob);
  1330       logdbg ('testBlob .type=', t estBlob.ty pe);
  1331       const  response =  {
  1332         blob : () => re sponse._bl ob, // kin da circula r
  1333         // _ blob: {...  testBlob} ,
  1334         _blo b: testBlo b,
  1335         head ers: {
  1336           ge t: (key: s tring) =>  _headers[k ey.toLower Case()],
  1337           ge tAll: (key : string)  => [_heade rs[key.toL owerCase() ]] // In t his case r eturn a si ngle item
  1338         }
  1339       };
  1340  
  1341  
  1342       spyOn( attachment ViewerServ ice, 'expo rtAsPDF'). and.return Value(
  1343         Obse rvable.of( response)
  1344       );
  1345  
  1346       spyOn( _window.na tiveWindow .navigator , 'msSaveO rOpenBlob' ); // .and .callFake( blob, attN ame);
  1347       const  userInfoRe turned = {
  1348           userName:  ' AI ',
  1349         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1350         perm issions: {
  1351           vi ewAttachme nt: {
  1352              exportPerm ission: fa lse,
  1353              editPermis sion: fals e
  1354           }
  1355         }
  1356       };
  1357       compon ent.userIn fo = userI nfoReturne d;
  1358       compon ent.export Permission  = false;   // overri de ngInit
  1359       // Her e we are u sing inter nal detail s to suppl y values
  1360       // spy On(compone nt, 'dataG etAttachme ntName').a nd.callFak e((data: R esponse) = > 'att-xxx .gif.pdf') ;
  1361       // spy On(compone nt, 'dataB lobAsType' ).and.call Fake((data : Response ) => testB lob);
  1362       // We  can just r eturn some  values
  1363       spyOn( component,  'dataGetA ttachmentN ame').and. returnValu e('att-xxx .gif.pdf') ;
  1364       spyOn( component,  'dataBlob AsType').a nd.returnV alue(testB lob);
  1365       // wou ld it  be  better to  provide mo re realist ic data an d let data GetAttachm entName be  called?
  1366       spyOn( component,  'saveAs') ;
  1367  
  1368       //// T EST ////
  1369       compon ent.onExpo rtAsPDF();
  1370  
  1371       // Abo rts becaus e componen t.exportPe rmission = == false;
  1372       expect (component .dataGetAt tachmentNa me).not.to HaveBeenCa lled();
  1373       expect (component .dataBlobA sType).not .toHaveBee nCalled();
  1374       expect (component .saveAs).n ot.toHaveB eenCalled( );
  1375       expect (attachmen tViewerSer vice.expor tAsPDF).no t.toHaveBe enCalled() ;
  1376       expect (_window.n ativeWindo w.navigato r.msSaveOr OpenBlob). not.toHave BeenCalled ();
  1377       // non  Side effe cts:
  1378       expect (component .selectedA ttachmentN ame).toEqu al(null);
  1379       expect (component .fileExten sion).toEq ual(null);
  1380  
  1381     });
  1382  
  1383     it('test  onExportA sPDF autho rized', ()  => {
  1384       const  fake = 'fi shy.gif';  // current ly it fake s out a ba d value
  1385       const  blobType =  'applicat ion/octet- stream';
  1386       const  attContent Type = 'im age/gif';
  1387       const  attName =  'foo.gif';
  1388       const  attTYP = ' GIF'; // i n a forEac h, use att Name.split ('.').pop( ).toUpperC ase();
  1389       const  _headers =  {
  1390         'con tent-type' : attConte ntType,
  1391         'x-a ttachment- name': att Name // no de expects  lower cas e!
  1392       };
  1393       const  getHeader  = (key: st ring) => _ headers[ke y.toLowerC ase()];
  1394       const  testBlob =  new Blob( ['testing  1,2,3'], {  type: blo bType });
  1395       logdbg ('testBlob =', testBl ob);
  1396       logdbg ('testBlob .type=', t estBlob.ty pe);
  1397       const  response =  {
  1398         blob : () => re sponse._bl ob, // kin da circula r
  1399         // _ blob: {...  testBlob} ,
  1400         _blo b: testBlo b,
  1401         head ers: {
  1402           ge t: (key: s tring) =>  _headers[k ey.toLower Case()],
  1403           ge tAll: (key : string)  => [_heade rs[key.toL owerCase() ]] // In t his case r eturn a si ngle item
  1404         }
  1405       };
  1406  
  1407       spyOn( attachment ViewerServ ice, 'expo rtAsPDF'). and.return Value(
  1408         Obse rvable.of( response)
  1409       );
  1410  
  1411       spyOn( _window.na tiveWindow .navigator , 'msSaveO rOpenBlob' ); // .and .callFake( blob, attN ame);
  1412  
  1413       const  userInfoRe turned = {
  1414           userName:  ' AI ',
  1415         user Roles: ['U SER_ROLE_1 ', 'USER_R OLE_2', 'U SER_ROLE_3 '],
  1416         perm issions: {
  1417           vi ewAttachme nt: {
  1418              exportPerm ission: tr ue,
  1419              editPermis sion: fals e
  1420           }
  1421         }
  1422       };
  1423       compon ent.userIn fo = userI nfoReturne d;  // byp ass ngInit
  1424       compon ent.export Permission  = true;   // overrid e ngInit
  1425       spyOn( component,  'dataGetA ttachmentN ame').and. callFake(( data: Resp onse) => ' att-xxx.gi f.pdf');
  1426       spyOn( component,  'dataBlob AsType').a nd.callFak e((data: R esponse) = > testBlob );
  1427       spyOn( component,  'saveAs') ;
  1428  
  1429       //// T EST ////
  1430       compon ent.onExpo rtAsPDF();
  1431  
  1432       expect (component .dataGetAt tachmentNa me).toHave BeenCalled ();
  1433       expect (component .dataBlobA sType).toH aveBeenCal led();
  1434       expect (component .saveAs).t oHaveBeenC alledWith( testBlob,  'att-xxx.g if.pdf');
  1435       expect (attachmen tViewerSer vice.expor tAsPDF).to HaveBeenCa lled();
  1436       // Bec ause spyOn (component , 'saveAs' ); msSaveO rOpenBlob  is never c alled
  1437       expect (_window.n ativeWindo w.navigato r.msSaveOr OpenBlob). not.toHave BeenCalled ();
  1438       // non  Side effe cts:
  1439       expect (component .selectedA ttachmentN ame).toEqu al(null);
  1440       expect (component .fileExten sion).toEq ual(null);
  1441       // Sid e effects:
  1442  
  1443     });
  1444     //// TES T onExport AsPDF for  error=> // //
  1445  
  1446     // todo   onRightCl ick(ev) {
  1447  
  1448     // todo   ngOnDestr oy() {
  1449   });