fix: generate numbers

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-25 22:09:17 +01:00
parent fe305581e8
commit c015425838
6 changed files with 120 additions and 113 deletions

87
.idea/workspace.xml generated
View File

@@ -5,11 +5,12 @@
</component>
<component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: ToolFileInput.tsx">
<change afterPath="$PROJECT_DIR$/src/components/ToolBreadcrumb.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/ToolHeader.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolHeader.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/ToolLayout.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolLayout.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tools/defineTool.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/tools/defineTool.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/Loading.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/Loading.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/number/generate/generate.service.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/number/generate/generate.service.test.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/number/generate/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/number/generate/index.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/number/generate/meta.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/number/generate/meta.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/number/generate/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/number/generate/service.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -19,10 +20,13 @@
<component name="FormatOnSaveOptions">
<option name="myRunOnSave" value="true" />
</component>
<component name="Git.Merge.Settings">
<option name="BRANCH" value="origin/chesterking" />
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="string-join" />
<entry key="$PROJECT_DIR$" value="chesterking" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -43,39 +47,40 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;Vitest.compute function (1).executor&quot;: &quot;Run&quot;,
&quot;Vitest.compute function.executor&quot;: &quot;Run&quot;,
&quot;Vitest.mergeText.executor&quot;: &quot;Run&quot;,
&quot;Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor&quot;: &quot;Run&quot;,
&quot;Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor&quot;: &quot;Run&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/HP/IdeaProjects/omni-tools/src/assets&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;npm.dev.executor&quot;: &quot;Run&quot;,
&quot;npm.prebuild.executor&quot;: &quot;Run&quot;,
&quot;npm.script:create:tool.executor&quot;: &quot;Run&quot;,
&quot;npm.test.executor&quot;: &quot;Run&quot;,
&quot;prettierjs.PrettierConfiguration.Package&quot;: &quot;C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\prettier&quot;,
&quot;project.structure.last.edited&quot;: &quot;Problems&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;settings.typescriptcompiler&quot;,
&quot;ts.external.directory.path&quot;: &quot;C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"Vitest.compute function (1).executor": "Run",
"Vitest.compute function.executor": "Run",
"Vitest.mergeText.executor": "Run",
"Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
"Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/HP/IdeaProjects/omni-tools/src/assets",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"npm.dev.executor": "Run",
"npm.lint.executor": "Run",
"npm.prebuild.executor": "Run",
"npm.script:create:tool.executor": "Run",
"npm.test.executor": "Run",
"prettierjs.PrettierConfiguration.Package": "C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\prettier",
"project.structure.last.edited": "Problems",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "settings.typescriptcompiler",
"ts.external.directory.path": "C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
"vue.rearranger.settings.migration": "true"
}
}</component>
}]]></component>
<component name="ReactDesignerToolWindowState">
<option name="myId2Visible">
<map>
@@ -136,11 +141,11 @@
<envs />
<method v="2" />
</configuration>
<configuration name="script:create:tool" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<configuration name="lint" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="script:create:tool" />
<script value="lint" />
</scripts>
<node-interpreter value="project" />
<envs />
@@ -159,10 +164,10 @@
<recent_temporary>
<list>
<item itemvalue="npm.dev" />
<item itemvalue="npm.test" />
<item itemvalue="npm.lint" />
<item itemvalue="Vitest.compute function (1)" />
<item itemvalue="Vitest.compute function" />
<item itemvalue="npm.test" />
<item itemvalue="npm.script:create:tool" />
</list>
</recent_temporary>
</component>

View File

@@ -22,7 +22,7 @@ function FuseLoading(props: FuseLoadingProps) {
return (
<div>
<Typography
className="-mb-16 text-13 font-medium sm:text-20"
className="text-13 sm:text-20 -mb-16 font-medium"
color="text.secondary"
>
Loading

View File

@@ -1,76 +1,76 @@
// Import necessary modules and functions
import { describe, it, expect } from 'vitest';
import { listOfIntegers} from './service';
import { listOfIntegers } from './service';
// Define test cases for the listOfIntegers function
describe('listOfIntegers function', () => {
it('should generate a list of integers with comma separator', () => {
const initialValue = 1;
const step = 2;
const count = 5;
const separator = ', ';
it('should generate a list of integers with comma separator', () => {
const initialValue = 1;
const step = 2;
const count = 5;
const separator = ', ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1, 3, 5, 7, 9');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1, 3, 5, 7, 9');
});
it('should generate a list of integers with dash separator', () => {
const initialValue = 0;
const step = 3;
const count = 4;
const separator = ' - ';
it('should generate a list of integers with dash separator', () => {
const initialValue = 0;
const step = 3;
const count = 4;
const separator = ' - ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('0 - 3 - 6 - 9');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('0 - 3 - 6 - 9');
});
it('should handle negative initial value and step', () => {
const initialValue = -10;
const step = -2;
const count = 5;
const separator = ' ';
it('should handle negative initial value and step', () => {
const initialValue = -10;
const step = -2;
const count = 5;
const separator = ' ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -12 -14 -16 -18');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -12 -14 -16 -18');
});
it('should handle negative initial value and positive step', () => {
const initialValue = -10;
const step = 2;
const count = 5;
const separator = ' ';
it('should handle negative initial value and positive step', () => {
const initialValue = -10;
const step = 2;
const count = 5;
const separator = ' ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -8 -6 -4 -2');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -8 -6 -4 -2');
});
it('should float value', () => {
const initialValue = -10;
const step = 2.5;
const count = 5;
const separator = ' ';
it('should float value', () => {
const initialValue = -10;
const step = 2.5;
const count = 5;
const separator = ' ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -7.5 -5 -2.5 0');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('-10 -7.5 -5 -2.5 0');
});
it('should generate a constant sequence if the step is 0', () => {
const initialValue = 1;
const step = 0;
const count = 5;
const separator = ' ';
it('should generate a constant sequence if the step is 0', () => {
const initialValue = 1;
const step = 0;
const count = 5;
const separator = ' ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1 1 1 1 1');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1 1 1 1 1');
});
it('should generate a constant sequence if the step is 0', () => {
const initialValue = 1;
const step = 0;
const count = 5;
const separator = ' ';
it('should generate a constant sequence if the step is 0', () => {
const initialValue = 1;
const step = 0;
const count = 5;
const separator = ' ';
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1 1 1 1 1');
});
const result = listOfIntegers(initialValue, count, step, separator);
expect(result).toBe('1 1 1 1 1');
});
});

View File

@@ -6,7 +6,8 @@ export const tool = defineTool('number', {
name: 'Generate',
path: 'generate',
// image,
description: '',
description:
'Quickly calculate a list of integers in your browser. To get your list, just specify the first integer, change value and total count in the options below, and this utility will generate that many integers',
keywords: ['generate'],
component: lazy(() => import('./index'))
});

View File

@@ -1,12 +1,13 @@
export function listOfIntegers(
first_value: number,
number_of_numbers: number,
step: number,
separator: string) {
const result: number[] = [];
for (let i: number = 0; i < number_of_numbers; i++) {
const value: number = first_value + i * step;
result.push(value);
}
return result.join(separator);
}
first_value: number,
number_of_numbers: number,
step: number,
separator: string
) {
const result: number[] = [];
for (let i: number = 0; i < number_of_numbers; i++) {
const value: number = first_value + i * step;
result.push(value);
}
return result.join(separator);
}