Skip to content

Commit

Permalink
Update naming logic
Browse files Browse the repository at this point in the history
  • Loading branch information
usulpro committed Mar 15, 2020
1 parent ebd76dd commit d524193
Show file tree
Hide file tree
Showing 6 changed files with 494 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 2,
"bracketSpacing": true,
"trailingComma": "all",
"singleQuote": true
}
5 changes: 5 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"watch": ["./src/"],
"ext": "js",
"ignore": ["__tests__/**/"]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"repository": "https://github.com/UsulPro/theme-name.git",
"scripts": {
"start": "start-storybook -p 6006 --ci",
"dev": "nodemon --exec yarn prepare",
"prepare": "package-prepare",
"lintfix": "eslint --fix src",
"test": "jest",
Expand All @@ -27,6 +28,7 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.13.0",
"jest": "^24.8.0",
"nodemon": "^2.0.2",
"prettier": "^1.17.1"
},
"author": "Oleg Proskurin <[email protected]>",
Expand Down
20 changes: 20 additions & 0 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,24 @@ describe(__filename, () => {
};
expect(themeName(theme)).toMatchInlineSnapshot(`"Light Theme"`);
});

it('should return theme ind', () => {
const theme = {
colors: {
main: BigTheme.pink,
red: BigTheme.badgeBackgroundColor,
},
};
expect(themeName(theme, 0)).toBe('theme 1');
});

it('should return undefined', () => {
const theme = {
colors: {
main: BigTheme.pink,
red: BigTheme.badgeBackgroundColor,
},
};
expect(themeName(theme)).toBe(undefined);
});
});
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export const themeName = (theme, ind) => {
.trim();
if (generatedName) return generatedName;

return `theme ${ind}`;
return ind !== undefined ? `theme ${ind + 1}` : undefined;
};
Loading

0 comments on commit d524193

Please sign in to comment.