Skip to content

Commit f2b263f

Browse files
committed
Improve unit tests
Current unit tests would not fail even if we wouldn't use optional flag when injecting the token. We should properly test case when not having any value injected or the ICONS_PATH token.
1 parent e78edcd commit f2b263f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

projects/cps-ui-kit/src/lib/components/cps-icon/cps-icon.component.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ describe('CpsIconComponent', () => {
1414

1515
beforeEach(async () => {
1616
await TestBed.configureTestingModule({
17-
imports: [CommonModule, CpsIconComponent],
18-
providers: [{ provide: ICONS_PATH, useValue: 'test-assets' }]
17+
imports: [CommonModule, CpsIconComponent]
1918
}).compileComponents();
2019
});
2120

@@ -25,17 +24,17 @@ describe('CpsIconComponent', () => {
2524
});
2625

2726
describe('Test assets path injection', () => {
28-
it('should use injected ICONS_PATH value', () => {
27+
it('should use default path when no ICONS_PATH is provided', () => {
2928
createComponent();
30-
expect(component.url).toBe('test-assets');
29+
expect(component.url).toBe('assets/');
3130
});
3231

33-
it('should default to "assets/" if no ICONS_PATH is provided', () => {
32+
it('should use injected ICONS_PATH value', () => {
3433
TestBed.overrideProvider(ICONS_PATH, {
35-
useValue: null
34+
useValue: 'test-assets/'
3635
});
3736
createComponent();
38-
expect(component.url).toBe('assets/');
37+
expect(component.url).toBe('test-assets/');
3938
});
4039
});
4140
});

0 commit comments

Comments
 (0)