summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts')
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts b/src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts
new file mode 100644
index 000000000..e21783860
--- /dev/null
+++ b/src/pybind/mgr/dashboard/frontend/src/testing/activated-route-stub.ts
@@ -0,0 +1,26 @@
+import { ActivatedRoute } from '@angular/router';
+
+import { ReplaySubject } from 'rxjs';
+
+/**
+ * An ActivateRoute test double with a `params` observable.
+ * Use the `setParams()` method to add the next `params` value.
+ */
+export class ActivatedRouteStub extends ActivatedRoute {
+ // Use a ReplaySubject to share previous values with subscribers
+ // and pump new values into the `params` observable
+ private subject = new ReplaySubject<object>();
+
+ constructor(initialParams?: object) {
+ super();
+ this.setParams(initialParams);
+ }
+
+ /** The mock params observable */
+ readonly params = this.subject.asObservable();
+
+ /** Set the params observables's next value */
+ setParams(params?: object) {
+ this.subject.next(params);
+ }
+}