Skip to content

Commit 7c6656a

Browse files
committed
feat(lib): upgrade to RxJs 7.5.x
- adjust RxJs imports, adjust tests, adjuts peer deps
1 parent b2ccb9a commit 7c6656a

File tree

10 files changed

+316
-94
lines changed

10 files changed

+316
-94
lines changed

package-lock.json

+273-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"highlight.js": "^11.3.1",
5858
"ngx-highlightjs": "^7.0.0",
5959
"ngx-markdown": "^14.0.1",
60-
"rxjs": "^6.6.3",
60+
"rxjs": "^7.5.0",
6161
"tslib": "^2.3.1",
6262
"zone.js": "~0.11.4"
6363
},

projects/elements-demo/src/app/app.component.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { MatDrawerMode, MatSidenav } from '@angular/material/sidenav';
22
import { SwUpdate } from '@angular/service-worker';
33
import { Component, OnInit, ViewChild, HostBinding } from '@angular/core';
4-
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
5-
import { delay, map, tap } from 'rxjs/operators';
4+
import {
5+
BehaviorSubject,
6+
combineLatest,
7+
Observable,
8+
delay,
9+
map,
10+
tap,
11+
} from 'rxjs';
612

713
import { ResponsiveLayoutService } from './core/layout/responsive-layout.service';
814
import { RefreshService } from './core/refresh.service';

projects/elements-demo/src/app/core/layout/responsive-layout.service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Injectable } from '@angular/core';
22
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
3-
import { combineLatest, Observable } from 'rxjs';
4-
import { map } from 'rxjs/operators';
3+
import { combineLatest, Observable, map } from 'rxjs';
54

65
@Injectable({
76
providedIn: 'root',

projects/elements-demo/src/app/core/refresh.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { MatSnackBar } from '@angular/material/snack-bar';
33
import { SwUpdate } from '@angular/service-worker';
4-
import { take } from 'rxjs/operators';
4+
import { take } from 'rxjs';
55

66
@Injectable({
77
providedIn: 'root',

projects/elements/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "@angular-extensions/elements",
33
"version": "14.0.0",
44
"peerDependencies": {
5-
"@angular/common": ">=12",
6-
"@angular/core": ">=12"
5+
"@angular/common": ">=14",
6+
"@angular/core": ">=14",
7+
"rxjs": ">=7.5.0"
78
},
89
"dependencies": {
910
"tslib": "^2.1.0"

projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2+
import { ComponentFixture, TestBed } from '@angular/core/testing';
33

44
import { LazyElementDynamicDirective } from './lazy-element-dynamic.directive';
55

@@ -36,12 +36,12 @@ describe('LazyElementDirectiveDynamic', () => {
3636
let fixture: ComponentFixture<TestHostComponent>;
3737
let appendChildSpy: jest.SpyInstance;
3838

39-
beforeEach(waitForAsync(() => {
40-
TestBed.configureTestingModule({
39+
beforeEach(async () => {
40+
await TestBed.configureTestingModule({
4141
schemas: [CUSTOM_ELEMENTS_SCHEMA],
4242
declarations: [TestHostComponent, LazyElementDynamicDirective],
4343
}).compileComponents();
44-
}));
44+
});
4545

4646
beforeEach(() => {
4747
fixture = TestBed.createComponent(TestHostComponent);

projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {
1313
ViewContainerRef,
1414
} from '@angular/core';
1515
import { DOCUMENT, isPlatformServer } from '@angular/common';
16-
import { from, Subscription } from 'rxjs';
17-
import { mergeMap } from 'rxjs/operators';
16+
import { from, Subscription, mergeMap } from 'rxjs';
1817

1918
import {
2019
ElementConfig,

projects/elements/src/lib/lazy-elements/lazy-element/lazy-element.directive.spec.ts

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
2-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2+
import { ComponentFixture, TestBed } from '@angular/core/testing';
33

44
import { LazyElementsModule } from '../lazy-elements.module';
55
import { LazyElementsLoaderService } from '../lazy-elements-loader.service';
@@ -92,7 +92,6 @@ describe('LazyElementDirective', () => {
9292
let fixture: ComponentFixture<TestHostComponent>;
9393
let appendChildSpy: jest.SpyInstance;
9494
let whenDefinedSpy: jest.SpyInstance;
95-
let requestAnimationFrameSpy: jest.SpyInstance;
9695

9796
function getAppendChildFirstScript(): HTMLScriptElement {
9897
return appendChildSpy.mock.calls[0][0];
@@ -102,8 +101,8 @@ describe('LazyElementDirective', () => {
102101
return appendChildSpy.mock.calls[1][0];
103102
}
104103

105-
beforeEach(waitForAsync(() => {
106-
TestBed.configureTestingModule({
104+
beforeEach(async () => {
105+
await TestBed.configureTestingModule({
107106
imports: [
108107
TestModule,
109108
LazyElementsModule.forRoot({
@@ -119,9 +118,9 @@ describe('LazyElementDirective', () => {
119118
schemas: [CUSTOM_ELEMENTS_SCHEMA],
120119
declarations: [TestHostComponent],
121120
}).compileComponents();
122-
}));
121+
});
123122

124-
beforeEach(() => {
123+
beforeEach(async () => {
125124
fixture = TestBed.createComponent(TestHostComponent);
126125
testHostComponent = fixture.componentInstance;
127126
appendChildSpy = jest.spyOn(document.body, 'appendChild');
@@ -130,20 +129,13 @@ describe('LazyElementDirective', () => {
130129
.mockReturnValue(
131130
Promise.resolve(class DummyElement extends HTMLElement {})
132131
);
133-
requestAnimationFrameSpy = jest
134-
.spyOn(window, 'requestAnimationFrame')
135-
.mockImplementation((callback) => {
136-
const time = 0;
137-
callback(time);
138-
return time;
139-
});
140132
fixture.detectChanges();
133+
await fixture.whenRenderingDone();
141134
});
142135

143136
afterEach(() => {
144137
appendChildSpy.mockRestore();
145138
whenDefinedSpy.mockRestore();
146-
requestAnimationFrameSpy.mockRestore();
147139
});
148140

149141
it('should create', () => {
@@ -167,10 +159,12 @@ describe('LazyElementDirective', () => {
167159
);
168160
});
169161

170-
it('adds multiple script tags if elements have different bundle url', () => {
162+
it('adds multiple script tags if elements have different bundle url', async () => {
171163
testHostComponent.addOtherElement = true;
172164
fixture.detectChanges();
173165

166+
await fixture.whenStable();
167+
174168
expect(appendChildSpy).toHaveBeenCalledTimes(2);
175169
expect(getAppendChildFirstScript().src).toBe(
176170
'http://elements.com/some-element'
@@ -180,11 +174,12 @@ describe('LazyElementDirective', () => {
180174
);
181175
});
182176

183-
it('renders loading template', () => {
177+
it('renders loading template', async () => {
184178
expect(document.querySelector('.loading')).toBe(null);
185179

186180
testHostComponent.useLoadingTemplate = true;
187181
fixture.detectChanges();
182+
await fixture.whenStable();
188183

189184
expect(document.querySelector('.loading').textContent).toBe('Loading...');
190185
});
@@ -194,6 +189,7 @@ describe('LazyElementDirective', () => {
194189

195190
testHostComponent.useLoadingTemplate = true;
196191
fixture.detectChanges();
192+
await fixture.whenStable();
197193

198194
expect(document.querySelector('.loading').textContent).toBe('Loading...');
199195

@@ -212,6 +208,7 @@ describe('LazyElementDirective', () => {
212208

213209
testHostComponent.useErrorTemplate = true;
214210
fixture.detectChanges();
211+
await fixture.whenStable();
215212

216213
expect(document.querySelector('.loading').textContent).toBe('Loading...');
217214
expect(document.querySelector('.error')).toBe(null);
@@ -231,7 +228,7 @@ describe('LazyElementDirective', () => {
231228
consoleErrorSpy.mockRestore();
232229
});
233230

234-
it('uses type module on script tag when specified', () => {
231+
it('uses type module on script tag when specified', async () => {
235232
fixture.detectChanges();
236233

237234
expect(appendChildSpy).toHaveBeenCalledTimes(1);
@@ -242,6 +239,7 @@ describe('LazyElementDirective', () => {
242239

243240
testHostComponent.useModule = true;
244241
fixture.detectChanges();
242+
await fixture.whenStable();
245243

246244
expect(appendChildSpy).toHaveBeenCalledTimes(2);
247245
expect(getAppendChildSecondScript().src).toBe(
@@ -273,14 +271,15 @@ describe('LazyElementDirective', () => {
273271
);
274272
});
275273

276-
it('uses elementConfig for the tag', () => {
274+
it('uses elementConfig for the tag', async () => {
277275
testHostComponent.useElementConfig = true;
278276
fixture.detectChanges();
277+
await fixture.whenStable();
279278

280279
expect(document.querySelector('.loading').textContent).toBe('Spinner...');
281280
});
282281

283-
it('should load another element when the `url` binding changes', () => {
282+
it('should load another element when the `url` binding changes', async () => {
284283
// Arrange
285284
const elementsLoaderService = TestBed.inject(LazyElementsLoaderService);
286285
const loadElementSpy = jest.spyOn(elementsLoaderService, 'loadElement');
@@ -290,10 +289,12 @@ describe('LazyElementDirective', () => {
290289
testHostComponent.url =
291290
'http://elements.com/some-configured-element-module';
292291
fixture.detectChanges();
292+
await fixture.whenStable();
293293

294294
testHostComponent.url =
295295
'http://elements.com/some-configured-element-module-es2015';
296296
fixture.detectChanges();
297+
await fixture.whenStable();
297298

298299
// Assert
299300
expect(loadElementSpy).toHaveBeenCalledTimes(2);

projects/elements/src/lib/lazy-elements/lazy-element/lazy-element.directive.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ import {
2020
EMPTY,
2121
from,
2222
Subscription,
23+
catchError,
24+
debounceTime,
25+
mergeMap,
26+
switchMap,
2327
} from 'rxjs';
24-
import { catchError, debounceTime, mergeMap, switchMap } from 'rxjs/operators';
2528

2629
import {
2730
ElementConfig,

0 commit comments

Comments
 (0)