Commits
Nicolai Olsen authored 8f014b079a6
93 93 | }); |
94 94 | }); |
95 95 | |
96 96 | it('sets patientContext when valid cpr is searched', () => { |
97 97 | spyOn(patientContextServiceStub, 'setCpr'); |
98 98 | component.search(cprStringStub); |
99 99 | expect(patientContextServiceStub.setCpr).toHaveBeenCalledTimes(1); |
100 100 | expect(patientContextServiceStub.setCpr).toHaveBeenCalledWith(cprStringStub); |
101 101 | }); |
102 102 | |
103 - | // TODO: Fix this test, it somehow does not throw an error - validateCpr spy is not used/doesn't return false??? |
104 - | // it('throws an error and does not set patientContext when invalid cpr is searched', () => { |
105 - | // spyOn(patientContextServiceStub, 'setCpr'); |
106 - | // spyOn(component, 'validateCpr').and.returnValue(false); // Mock failed validate |
107 - | // expect(() => component.search(cprStringStub)).toThrow(new CprDoesNotExistError()); |
108 - | // expect(component.validateCpr).toHaveBeenCalledWith(cprStringStub); |
109 - | // expect(component.validateCpr).toHaveBeenCalledTimes(1); |
110 - | // expect(patientContextServiceStub.setCpr).toHaveBeenCalledTimes(0); |
111 - | // }); |
112 - | |
113 103 | it('aborts search if search string is empty', () => { |
114 104 | spyOn(patientContextServiceStub, 'setCpr'); |
115 - | spyOn(component, 'validateCpr'); |
116 105 | component.search(''); |
117 - | expect(component.validateCpr).toHaveBeenCalledTimes(0); |
118 106 | expect(patientContextServiceStub.setCpr).toHaveBeenCalledTimes(0); |
119 107 | }); |
120 108 | |
121 109 | describe('when handleEnterPressed is called', () => { |
122 110 | beforeEach(() => { |
123 111 | // @ts-ignore |
124 112 | component.submitButton.ripple = rippleStub; |
125 113 | spyOn(component, 'search'); |
126 114 | spyOn(rippleStub, 'launch'); |
127 115 | component.handleEnterPressed(); |