Skip to content

Commit

Permalink
Avoid lowercasing store names in global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed May 23, 2023
1 parent 6c66d4b commit 5706e8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ describe('config - console access', () => {
new Todo();

expect(window.store).toBeTruthy();
expect(window.store).toHaveProperty('counter');
expect(window.store).toHaveProperty('todo');
expect(typeof window.store!['todo'] === 'object').toBeTruthy();
expect(window.store).toHaveProperty('Counter');
expect(window.store).toHaveProperty('Todo');
expect(typeof window.store!['Todo'] === 'object').toBeTruthy();
expect(Object.keys(window.store!)).toHaveLength(2);

new Todo();

expect(Object.keys(window.store!)).toHaveLength(2);
expect(typeof window.store!['todo'] === 'object').toBeTruthy();
expect(Object.keys(window.store!['todo'])).toHaveLength(1);
expect(typeof window.store!['Todo'] === 'object').toBeTruthy();
expect(Object.keys(window.store!['Todo'])).toHaveLength(1);
});
});
7 changes: 1 addition & 6 deletions src/make-loggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ declare global {

let browserConsoleSpy: BrowserConsoleSpy;

const firstLetterLowerCase = (word: string) => {
return word.charAt(0).toLowerCase() + word.slice(1);
};

type PerStoreFilters = {
filters: { events: StoreEventFilters };
};
Expand Down Expand Up @@ -97,8 +93,7 @@ export const makeLoggable = <T extends {}>(

if (config.storeConsoleAccess) {
window.store = window.store || {};
const storeKey = firstLetterLowerCase(storeName);
window.store[storeKey] = store;
window.store[storeName] = store;
}

return store;
Expand Down

0 comments on commit 5706e8b

Please sign in to comment.