Skip to content

Commit 89227f8

Browse files
committed
chore: Unused imports cleanup and injection context
1 parent 96f2b4d commit 89227f8

File tree

2 files changed

+78
-79
lines changed

2 files changed

+78
-79
lines changed
Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { ActionType, BroadcastIconsChangeMessage, IgxIconBroadcastService, SvgIcon, } from './icon.broadcast.service';
3-
import { Component, SecurityContext } from '@angular/core';
2+
import { ActionType, BroadcastIconsChangeMessage, IgxIconBroadcastService, SvgIcon, } from './icon.broadcast.service';
3+
import { Component, inject } from '@angular/core';
44
import { IconMeta, IgxIconService } from 'igniteui-angular';
55
import { wait } from 'igniteui-angular/test-utils/ui-interactions.spec';
66

@@ -9,107 +9,107 @@ describe('Icon broadcast service', () => {
99
let broadcastChannel: BroadcastChannel;
1010
let events: BroadcastIconsChangeMessage[] = [];
1111
const buildIcon =
12-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"/></svg>';
12+
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z"/></svg>';
1313

1414
beforeEach(async () => {
1515
await TestBed.configureTestingModule({
16-
imports: [],
17-
providers: [IgxIconBroadcastService]
16+
imports: [],
17+
providers: [IgxIconBroadcastService]
1818
})
19-
.compileComponents();
20-
});
19+
.compileComponents();
20+
});
2121

22-
beforeEach(() => {
22+
beforeEach(() => {
2323
broadcastChannel = new BroadcastChannel("ignite-ui-icon-channel");
2424
broadcastChannel.onmessage = (e: MessageEvent<BroadcastIconsChangeMessage>) => {
2525
events.push(e.data);
2626
}
2727
fixture = TestBed.createComponent(BroadcastServiceComponent);
28-
});
28+
});
2929

30-
afterEach(() => {
30+
afterEach(() => {
3131
events = [];
3232
broadcastChannel.close();
33-
});
33+
});
3434

3535
describe('Broadcast Events', () => {
36-
it('should correctly process event of icons registering on channel.', async() => {
37-
// simulate a new icon being registered on channel
38-
const icons: Map<string, Map<string, SvgIcon>> = new Map();
39-
const icon: Map<string, SvgIcon> = new Map()
40-
icon.set("customIcon", { svg: buildIcon });
41-
icons.set("customCollection", icon);
42-
const message: BroadcastIconsChangeMessage = {
43-
actionType: ActionType.RegisterIcon,
44-
collections: icons
45-
};
46-
broadcastChannel.postMessage(message);
47-
fixture.detectChanges();
48-
await wait(50);
49-
fixture.detectChanges();
50-
const iconService = fixture.componentInstance.iconService;
51-
const svg = iconService.getSvgIcon("customIcon", "customCollection");
52-
expect(svg).not.toBeUndefined();
53-
});
36+
it('should correctly process event of icons registering on channel.', async () => {
37+
// simulate a new icon being registered on channel
38+
const icons: Map<string, Map<string, SvgIcon>> = new Map();
39+
const icon: Map<string, SvgIcon> = new Map()
40+
icon.set("customIcon", { svg: buildIcon });
41+
icons.set("customCollection", icon);
42+
const message: BroadcastIconsChangeMessage = {
43+
actionType: ActionType.RegisterIcon,
44+
collections: icons
45+
};
46+
broadcastChannel.postMessage(message);
47+
fixture.detectChanges();
48+
await wait(50);
49+
fixture.detectChanges();
50+
const iconService = fixture.componentInstance.iconService;
51+
const svg = iconService.getSvgIcon("customIcon", "customCollection");
52+
expect(svg).not.toBeUndefined();
53+
});
5454

55-
it('should correctly process event of setting an icon reference on channel.', async() => {
56-
const refs: Map<string, Map<string, IconMeta>> = new Map();
57-
const ref: Map<string, IconMeta> = new Map()
58-
ref.set("customIcon", {name: "customNameOfIcon", collection: "customCollection" } as any);
59-
refs.set("customCollection", ref);
60-
const message: BroadcastIconsChangeMessage = {
61-
actionType: ActionType.UpdateIconReference,
62-
references: refs
63-
};
64-
broadcastChannel.postMessage(message);
65-
fixture.detectChanges();
66-
await wait(50);
67-
fixture.detectChanges();
55+
it('should correctly process event of setting an icon reference on channel.', async () => {
56+
const refs: Map<string, Map<string, IconMeta>> = new Map();
57+
const ref: Map<string, IconMeta> = new Map()
58+
ref.set("customIcon", { name: "customNameOfIcon", collection: "customCollection" } as any);
59+
refs.set("customCollection", ref);
60+
const message: BroadcastIconsChangeMessage = {
61+
actionType: ActionType.UpdateIconReference,
62+
references: refs
63+
};
64+
broadcastChannel.postMessage(message);
65+
fixture.detectChanges();
66+
await wait(50);
67+
fixture.detectChanges();
6868

69-
const iconService = fixture.componentInstance.iconService;
70-
const serviceRef = iconService.getIconRef("customIcon", "default");
71-
expect(serviceRef.family).toBe("customCollection");
72-
expect(serviceRef.name).toBe("customNameOfIcon");
73-
});
69+
const iconService = fixture.componentInstance.iconService;
70+
const serviceRef = iconService.getIconRef("customIcon", "default");
71+
expect(serviceRef.family).toBe("customCollection");
72+
expect(serviceRef.name).toBe("customNameOfIcon");
73+
});
7474

75-
it('should send a request to sync state from any peer already on the channel on init.', async() => {
76-
await wait(50);
77-
expect(events.length).toBe(1);
78-
expect(events[0].actionType).toBe(ActionType.SyncState);
79-
});
75+
it('should send a request to sync state from any peer already on the channel on init.', async () => {
76+
await wait(50);
77+
expect(events.length).toBe(1);
78+
expect(events[0].actionType).toBe(ActionType.SyncState);
79+
});
8080

81-
it('should correctly process event of synching full state of icons on channel.', async() => {
82-
const icons: Map<string, Map<string, SvgIcon>> = new Map();
83-
const icon: Map<string, SvgIcon> = new Map()
84-
icon.set("customIcon", { svg: buildIcon });
85-
icons.set("customCollection", icon);
86-
const refs: Map<string, Map<string, IconMeta>> = new Map();
87-
const ref: Map<string, IconMeta> = new Map()
88-
ref.set("customIcon", {name: "customIcon", family: "customCollection" });
89-
refs.set("customCollection", ref);
90-
const message: BroadcastIconsChangeMessage = {
91-
actionType: ActionType.SyncState,
92-
collections: icons,
93-
references: refs
94-
};
95-
broadcastChannel.postMessage(message);
96-
await wait(50);
97-
const iconService = fixture.componentInstance.iconService;
98-
const svg = iconService.getSvgIcon("customIcon", "customCollection");
99-
expect(svg).not.toBeUndefined();
100-
const serviceRef = iconService.getIconRef("customIcon", "customCollection");
101-
expect(serviceRef.family).toBe("customCollection");
102-
expect(serviceRef.name).toBe("customIcon");
103-
});
81+
it('should correctly process event of synching full state of icons on channel.', async () => {
82+
const icons: Map<string, Map<string, SvgIcon>> = new Map();
83+
const icon: Map<string, SvgIcon> = new Map()
84+
icon.set("customIcon", { svg: buildIcon });
85+
icons.set("customCollection", icon);
86+
const refs: Map<string, Map<string, IconMeta>> = new Map();
87+
const ref: Map<string, IconMeta> = new Map()
88+
ref.set("customIcon", { name: "customIcon", family: "customCollection" });
89+
refs.set("customCollection", ref);
90+
const message: BroadcastIconsChangeMessage = {
91+
actionType: ActionType.SyncState,
92+
collections: icons,
93+
references: refs
94+
};
95+
broadcastChannel.postMessage(message);
96+
await wait(50);
97+
const iconService = fixture.componentInstance.iconService;
98+
const svg = iconService.getSvgIcon("customIcon", "customCollection");
99+
expect(svg).not.toBeUndefined();
100+
const serviceRef = iconService.getIconRef("customIcon", "customCollection");
101+
expect(serviceRef.family).toBe("customCollection");
102+
expect(serviceRef.name).toBe("customIcon");
103+
});
104104
})
105105
});
106106

107107
@Component({
108-
template: `
109-
`,
108+
template: ``,
110109
standalone: true,
111110
providers: [IgxIconBroadcastService, IgxIconService]
112111
})
113112
export class BroadcastServiceComponent {
114-
constructor(public iconBroadcast: IgxIconBroadcastService, public iconService: IgxIconService) {}
113+
public iconBroadcast = inject(IgxIconBroadcastService);
114+
public iconService = inject(IgxIconService);
115115
}

projects/igniteui-angular/directives/src/directives/mask/mask.directive.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Replaced } from './mask-parsing.service';
88
import { By } from '@angular/platform-browser';
99
import { IgxInputGroupComponent } from '../../../../input-group/src/input-group/input-group.component';
1010
import { IgxInputDirective } from 'igniteui-angular/input-group';
11-
import { mock } from 'node:test';
1211

1312
describe('igxMask', () => {
1413
// TODO: Refactor tests to reuse components

0 commit comments

Comments
 (0)