mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* refactor: introduce @bitwarden/serialization * refactor: introduce @bitwarden/guid * refactor: introduce @bitwaren/client-type * refactor: introduce @bitwarden/core-test-utils * refactor: introduce @bitwarden/state and @bitwarden/state-test-utils Creates initial project structure for centralized application state management. Part of modularization effort to extract state code from common. * Added state provider documentation to README. * Changed callouts to Github format. * Fixed linting on file name. * Forced git to accept rename --------- Co-authored-by: Todd Martin <tmartin@bitwarden.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { DeriveDefinition } from "./derive-definition";
|
|
import { KeyDefinition } from "./key-definition";
|
|
import { StateDefinition } from "./state-definition";
|
|
|
|
const derive: () => any = () => null;
|
|
const deserializer: any = (obj: any) => obj;
|
|
|
|
const STATE_DEFINITION = new StateDefinition("test", "disk");
|
|
const TEST_KEY = new KeyDefinition(STATE_DEFINITION, "test", {
|
|
deserializer,
|
|
});
|
|
const TEST_DERIVE = new DeriveDefinition(STATE_DEFINITION, "test", {
|
|
derive,
|
|
deserializer,
|
|
});
|
|
|
|
describe("DeriveDefinition", () => {
|
|
describe("from", () => {
|
|
it("should create a new DeriveDefinition from a KeyDefinition", () => {
|
|
const result = DeriveDefinition.from(TEST_KEY, {
|
|
derive,
|
|
deserializer,
|
|
});
|
|
|
|
expect(result).toEqual(TEST_DERIVE);
|
|
});
|
|
|
|
it("should create a new DeriveDefinition from a DeriveDefinition", () => {
|
|
const result = DeriveDefinition.from([TEST_DERIVE, "newDerive"], {
|
|
derive,
|
|
deserializer,
|
|
});
|
|
|
|
expect(result).toEqual(
|
|
new DeriveDefinition(STATE_DEFINITION, "newDerive", {
|
|
derive,
|
|
deserializer,
|
|
}),
|
|
);
|
|
});
|
|
});
|
|
});
|