2022-08-16 14:05:03 +02:00
|
|
|
import { BehaviorSubject } from "rxjs";
|
|
|
|
|
|
|
|
import { sessionSync } from "./session-sync.decorator";
|
|
|
|
|
|
|
|
describe("sessionSync decorator", () => {
|
|
|
|
const initializer = (s: string) => "test";
|
|
|
|
const ctor = String;
|
|
|
|
class TestClass {
|
|
|
|
@sessionSync({ ctor: ctor, initializer: initializer })
|
|
|
|
testProperty = new BehaviorSubject("");
|
|
|
|
}
|
|
|
|
|
|
|
|
it("should add __syncedItemKeys to prototype", () => {
|
|
|
|
const testClass = new TestClass();
|
|
|
|
expect((testClass as any).__syncedItemMetadata).toEqual([
|
|
|
|
expect.objectContaining({
|
2022-08-16 17:59:50 +02:00
|
|
|
propertyKey: "testProperty",
|
|
|
|
sessionKey: "TestClass_testProperty",
|
2022-08-16 14:05:03 +02:00
|
|
|
ctor: ctor,
|
|
|
|
initializer: initializer,
|
|
|
|
}),
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|