Skip to content

Commit

Permalink
improved action prefix unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml committed Jul 5, 2024
1 parent 21a720e commit 69df215
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions platform/src/kernel/registry/__tests__/store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ describe("store registry", () => {
expect(typeof store.wrap).toEqual("function");
expect(store.wrap("x")).toEqual("x");
});

it(".unwrap", () => {
const store = getStore();

expect(typeof store.unwrap).toEqual("function");
expect(store.unwrap("x")).toEqual("x");
});
});

describe("namespace", () => {
Expand Down Expand Up @@ -213,5 +220,18 @@ describe("store registry", () => {
expect(store.wrap("@@agenda/THING")).toEqual("@@agenda/THING");
expect(store.wrap("THING")).toEqual("$my-feature$THING");
});

it(".unwrap", () => {
const storeRef = configureStore([])({});
setStore(storeRef);

const store = getStore().namespace("my-feature");
expect(typeof store.unwrap).toEqual("function");

expect(store.unwrap()).toEqual();
expect(store.unwrap("$other-feature$THING")).toEqual("$other-feature$THING");
expect(store.unwrap("@@agenda/THING")).toEqual("@@agenda/THING");
expect(store.unwrap("$my-feature$THING")).toEqual("THING");
});
});
});
3 changes: 3 additions & 0 deletions platform/src/kernel/registry/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const handler = {
const prefix = RUNE + name + RUNE;
return {
unwrap(type) {
if (!type || type[0] !== RUNE) {
return type;
}
if (type.startsWith(prefix)) {
return type.slice(prefix.length);
}
Expand Down

0 comments on commit 69df215

Please sign in to comment.