From 0c58ec92603ae3f07ac55edfbefa01bbdf8c581c Mon Sep 17 00:00:00 2001 From: ziajka Date: Thu, 5 Jul 2018 09:42:48 +0200 Subject: [PATCH] Project - readonly tests --- src/app/services/project.service.spec.ts | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/app/services/project.service.spec.ts b/src/app/services/project.service.spec.ts index ee38db72..2c5c7225 100644 --- a/src/app/services/project.service.spec.ts +++ b/src/app/services/project.service.spec.ts @@ -44,6 +44,7 @@ describe('ProjectService', () => { let httpServer: HttpServer; let service: ProjectService; let server: Server; + let settingsService: SettingsService; beforeEach(() => { TestBed.configureTestingModule({ @@ -62,6 +63,8 @@ describe('ProjectService', () => { httpTestingController = TestBed.get(HttpTestingController); httpServer = TestBed.get(HttpServer); service = TestBed.get(ProjectService); + settingsService = TestBed.get(SettingsService); + server = getTestServer(); }); @@ -142,7 +145,29 @@ describe('ProjectService', () => { it('should get notifications path of project', () => { const path = service.notificationsPath(server, "myproject"); - expect(path).toEqual('ws://127.0.0.1:3080/v2/projects/myproject/notifications/ws') + expect(path).toEqual('ws://127.0.0.1:3080/v2/projects/myproject/notifications/ws'); }); + it('project should be readonly when defined as readonly ', () => { + const project = new Project(); + project.readonly = true; + + expect(service.isReadOnly(project)).toEqual(true); + }); + + it('project should be readonly when experimentalFeatures disabled ', () => { + const project = new Project(); + project.readonly = false; + spyOn(settingsService, 'isExperimentalEnabled').and.returnValue(false); + + expect(service.isReadOnly(project)).toEqual(true); + }); + + it('project should not be readonly when experimentalFeatures enabled ', () => { + const project = new Project(); + project.readonly = false; + spyOn(settingsService, 'isExperimentalEnabled').and.returnValue(true); + + expect(service.isReadOnly(project)).toEqual(false); + }); });