1515 * along with ndb-core. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
18- import { TestBed } from "@angular/core/testing" ;
18+ import { fakeAsync , TestBed , tick } from "@angular/core/testing" ;
1919
2020import { LatestChangesService } from "./latest-changes.service" ;
21- import { MatDialog } from "@angular/material/dialog" ;
21+ import { MatDialog , MatDialogRef } from "@angular/material/dialog" ;
2222import { LatestChangesDialogService } from "./latest-changes-dialog.service" ;
2323import { environment } from "../../../../environments/environment" ;
24+ import { NEVER , of } from "rxjs" ;
2425
2526describe ( "LatestChangesDialogService" , ( ) => {
2627 let service : LatestChangesDialogService ;
@@ -34,6 +35,9 @@ describe("LatestChangesDialogService", () => {
3435 ] ) ;
3536
3637 mockDialog = jasmine . createSpyObj ( "mockDialog" , [ "open" ] ) ;
38+ mockDialog . open . and . returnValue ( {
39+ afterClosed : ( ) => of ( NEVER ) ,
40+ } as MatDialogRef < void > ) ;
3741
3842 TestBed . configureTestingModule ( {
3943 providers : [
@@ -79,4 +83,20 @@ describe("LatestChangesDialogService", () => {
7983
8084 expect ( mockDialog . open ) . not . toHaveBeenCalled ( ) ;
8185 } ) ;
86+
87+ it ( "should update stored version after user closes dialog" , fakeAsync ( ( ) => {
88+ spyOn ( Storage . prototype , "setItem" ) ;
89+
90+ mockDialog . open . and . returnValue ( {
91+ afterClosed : ( ) => of ( true ) ,
92+ } as MatDialogRef < boolean > ) ;
93+
94+ service . showLatestChanges ( ) ;
95+ tick ( ) ;
96+
97+ expect ( Storage . prototype . setItem ) . toHaveBeenCalledWith (
98+ LatestChangesDialogService . VERSION_KEY ,
99+ environment . appVersion ,
100+ ) ;
101+ } ) ) ;
82102} ) ;
0 commit comments