]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: tests for food component
authorBastian Dehn <hhaalo@arcor.de>
Sat, 2 Jul 2022 21:07:37 +0000 (23:07 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 2 Jul 2022 21:07:37 +0000 (23:07 +0200)
src/app/food/food.component.spec.ts

index c4aa61d8d4e2f5c687ab87ab447b62879f09ae65..5cef7ad27a2c58a603ceba3b365597b61944d771 100644 (file)
@@ -23,4 +23,27 @@ describe('FoodComponent', () => {
   it('should create', () => {
     expect(component).toBeTruthy();
   });
+
+  it('form is visible by init', () => {
+    expect(component.formFoodVisible).toBeTruthy();
+  });
+
+  it('edit forms visible for edit', () => {
+    component.formFoodVisible = false;
+    component.editFood();
+    expect(component.formFoodVisible).toBeTruthy();
+  });
+
+  it('edit forms not visible after save', () => {
+    component.formFoodVisible = true;
+    component.saveFood();
+    expect(component.formFoodVisible).toBeFalsy();
+  });
+
+  it('edit forms not visible after save with enter', () => {
+    component.formFoodVisible = true;
+    let key = { keyCode: 13 };
+    component.onKeypressEnter(key);
+    expect(component.formFoodVisible).toBeFalsy();
+  });
 });