From 265b4c407ae1f75d03914ec7851d325747e79fbc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 14 May 2018 16:05:37 +0200 Subject: [PATCH] More tests --- .../app/shared/state/schemas.state.spec.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Squidex/app/shared/state/schemas.state.spec.ts b/src/Squidex/app/shared/state/schemas.state.spec.ts index 195e870e9..05abe8a8f 100644 --- a/src/Squidex/app/shared/state/schemas.state.spec.ts +++ b/src/Squidex/app/shared/state/schemas.state.spec.ts @@ -91,6 +91,18 @@ describe('SchemasState', () => { it('should load schemas', () => { expect(schemasState.snapshot.schemas.values).toEqual(oldSchemas); expect(schemasState.snapshot.isLoaded).toBeTruthy(); + expect(schemasState.snapshot.categories).toEqual({ 'category1': false, 'category2': false }); + + schemasService.verifyAll(); + }); + + it('should not remove custom category when loading schemas', () => { + schemasState.addCategory('category3'); + schemasState.load(true).subscribe(); + + expect(schemasState.snapshot.schemas.values).toEqual(oldSchemas); + expect(schemasState.snapshot.isLoaded).toBeTruthy(); + expect(schemasState.snapshot.categories).toEqual({ 'category1': false, 'category2': false, 'category3': true }); schemasService.verifyAll(); }); @@ -101,6 +113,18 @@ describe('SchemasState', () => { dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once()); }); + it('should add category', () => { + schemasState.addCategory('category3'); + + expect(schemasState.snapshot.categories).toEqual({ 'category1': false, 'category2': false, 'category3': true }); + }); + + it('should remove category', () => { + schemasState.removeCategory('category1'); + + expect(schemasState.snapshot.categories).toEqual({ 'category2': false }); + }); + it('should return schema on select and reload when already loaded', () => { schemasState.select('name2').subscribe(); schemasState.select('name2').subscribe();