]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: StatefulTabDirective unit test fails 36010/head
authorVolker Theile <vtheile@suse.com>
Fri, 10 Jul 2020 11:42:53 +0000 (13:42 +0200)
committerVolker Theile <vtheile@suse.com>
Fri, 10 Jul 2020 11:50:42 +0000 (13:50 +0200)
Fixes: https://tracker.ceph.com/issues/46450
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/directives/stateful-tab.directive.spec.ts

index 70ecb1adb88c960ab866e247955a35717cd5f804..bbac89aa4466ee8b71de316a342e7c6a4cef9708 100644 (file)
@@ -11,19 +11,18 @@ describe('StatefulTabDirective', () => {
   it('should get and select active tab', () => {
     const nav = new NgbNav('tablist', new NgbNavConfig(), <any>null, null);
     spyOn(nav, 'select');
-    spyOn(window.localStorage, 'getItem').and.returnValue('foo');
     const directive = new StatefulTabDirective(nav);
+    directive.cdStatefulTab = 'bar';
+    window.localStorage.setItem('tabset_bar', 'foo');
     directive.ngOnInit();
-    expect(window.localStorage.getItem).toHaveBeenCalled();
     expect(nav.select).toHaveBeenCalledWith('foo');
   });
 
   it('should store active tab', () => {
-    spyOn(window.localStorage, 'setItem');
     const directive = new StatefulTabDirective(null);
     directive.cdStatefulTab = 'bar';
     const event: NgbNavChangeEvent<string> = { activeId: '', nextId: 'xyz', preventDefault: null };
     directive.onNavChange(event);
-    expect(window.localStorage.setItem).toHaveBeenCalledWith('tabset_bar', 'xyz');
+    expect(window.localStorage.getItem('tabset_bar')).toBe('xyz');
   });
 });