mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-20 06:29:32 +02:00
fix: misc
This commit is contained in:
124
.idea/workspace.xml
generated
124
.idea/workspace.xml
generated
@@ -6,10 +6,12 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="style: lint">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/components/ToolInputAndResult.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/ToolInputAndResult.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/components/options/ToolOptions.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/options/ToolOptions.tsx" 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/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/number/generate/service.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/sort/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/sort/index.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/sort/meta.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/sort/meta.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/sort/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/sort/service.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/sort/sort.service.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/sort/sort.service.test.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/utils/string.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/string.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -25,7 +27,7 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="chesterking" />
|
||||
<entry key="$PROJECT_DIR$" value="main" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
@@ -46,43 +48,43 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"Playwright.JoinText Component.executor": "Run",
|
||||
"Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
|
||||
"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",
|
||||
"npm.test:e2e.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 name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"Playwright.JoinText Component.executor": "Run",
|
||||
"Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
|
||||
"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": "chesterkxng",
|
||||
"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",
|
||||
"npm.test:e2e.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>
|
||||
@@ -107,19 +109,7 @@
|
||||
<recent name="C:\Users\HP\IdeaProjects\omni-tools\src\tools" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="npm.dev">
|
||||
<configuration name="JoinText Component" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true">
|
||||
<node-interpreter value="project" />
|
||||
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
|
||||
<working-dir value="$PROJECT_DIR$" />
|
||||
<envs />
|
||||
<scope-kind value="SUITE" />
|
||||
<test-file value="$PROJECT_DIR$/src/pages/string/join/string-join.e2e.spec.ts" />
|
||||
<test-names>
|
||||
<test-name value="JoinText Component" />
|
||||
</test-names>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<component name="RunManager" selected="npm.test">
|
||||
<configuration name="JoinText Component.should merge text pieces with specified join character" type="JavaScriptTestRunnerPlaywright" temporary="true" nameIsGenerated="true">
|
||||
<node-interpreter value="project" />
|
||||
<playwright-package value="$PROJECT_DIR$/node_modules/@playwright/test" />
|
||||
@@ -153,6 +143,16 @@
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="test" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
||||
<package-json value="$PROJECT_DIR$/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
<script value="test" />
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="test:e2e" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
|
||||
<package-json value="$PROJECT_DIR$/package.json" />
|
||||
<command value="run" />
|
||||
@@ -165,11 +165,11 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="npm.test" />
|
||||
<item itemvalue="npm.dev" />
|
||||
<item itemvalue="npm.lint" />
|
||||
<item itemvalue="npm.test:e2e" />
|
||||
<item itemvalue="Playwright.JoinText Component.should merge text pieces with specified join character" />
|
||||
<item itemvalue="Playwright.JoinText Component" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@@ -609,7 +609,19 @@
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
<State>
|
||||
<option name="FILTERS">
|
||||
<map>
|
||||
<entry key="branch">
|
||||
<value>
|
||||
<list>
|
||||
<option value="origin/chesterkxng" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
|
@@ -21,7 +21,7 @@
|
||||
"test:e2e:run": "playwright test",
|
||||
"test:ui": "vitest --ui",
|
||||
"script:create:tool": "node scripts/create-tool.mjs",
|
||||
"lint": "eslint src --max-warnings=0",
|
||||
"lint": "eslint src --max-warnings=0 --fix",
|
||||
"typecheck": "tsc --project tsconfig.json --noEmit",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
|
@@ -1,15 +1,14 @@
|
||||
import { isNumber } from "utils/string";
|
||||
import { isNumber } from 'utils/string';
|
||||
|
||||
export type SortingMethod = 'numeric' | 'alphabetic' | 'length';
|
||||
export type SplitOperatorType = 'symbol' | 'regex';
|
||||
|
||||
// utils function that choose the way of numeric sorting mixed types of array
|
||||
function customNumericSort(a: string, b: string, increasing: boolean): number {
|
||||
|
||||
const formattedA = isNumber(a) ? Number(a) : a;
|
||||
const formattedB = isNumber(b) ? Number(b) : b;
|
||||
if (typeof formattedA === 'number' && typeof formattedB === 'number') {
|
||||
let result: number = increasing ? (formattedA - formattedB) : (formattedB - formattedA);
|
||||
return result;
|
||||
return increasing ? formattedA - formattedB : formattedB - formattedA;
|
||||
} else if (typeof formattedA === 'string' && typeof formattedB === 'string') {
|
||||
return formattedA.localeCompare(formattedB); // Lexicographical comparison for strings
|
||||
} else if (typeof formattedA === 'number' && typeof formattedB === 'string') {
|
||||
@@ -34,8 +33,7 @@ export function numericSort(
|
||||
|
||||
// utils function that choose the way of numeric sorting mixed types of array
|
||||
function customLengthSort(a: string, b: string, increasing: boolean): number {
|
||||
let result: number = increasing ? (a.length - b.length) : (b.length - a.length);
|
||||
return result;
|
||||
return increasing ? a.length - b.length : b.length - a.length;
|
||||
}
|
||||
|
||||
export function lengthSort(
|
||||
@@ -52,7 +50,11 @@ export function lengthSort(
|
||||
}
|
||||
|
||||
// Utils function that chooses the way of alphabetic sorting mixed types of array
|
||||
function customAlphabeticSort(a: string, b: string, caseSensitive: boolean): number {
|
||||
function customAlphabeticSort(
|
||||
a: string,
|
||||
b: string,
|
||||
caseSensitive: boolean
|
||||
): number {
|
||||
if (!caseSensitive) {
|
||||
// Case-insensitive comparison
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
@@ -68,10 +70,9 @@ export function alphabeticSort(
|
||||
joinSeparator: string,
|
||||
removeDuplicated: boolean, // the value if the checkbox has been selected 1 else 0
|
||||
caseSensitive: boolean // the value if the checkbox has been selected 1 else 0
|
||||
)
|
||||
{
|
||||
) {
|
||||
array.sort((a, b) => customAlphabeticSort(a, b, caseSensitive));
|
||||
if (!increasing){
|
||||
if (!increasing) {
|
||||
array.reverse();
|
||||
}
|
||||
if (removeDuplicated) {
|
||||
@@ -92,7 +93,7 @@ export function Sort(
|
||||
caseSensitive: boolean
|
||||
) {
|
||||
let array: string[];
|
||||
switch(splitOperatorType) {
|
||||
switch (splitOperatorType) {
|
||||
case 'symbol':
|
||||
array = input.split(splitSeparator);
|
||||
break;
|
||||
@@ -100,8 +101,8 @@ export function Sort(
|
||||
array = input.split(new RegExp(splitSeparator));
|
||||
break;
|
||||
}
|
||||
let result : string;
|
||||
switch(sortingMethod) {
|
||||
let result: string;
|
||||
switch (sortingMethod) {
|
||||
case 'numeric':
|
||||
result = numericSort(array, increasing, joinSeparator, removeDuplicated);
|
||||
break;
|
||||
@@ -109,9 +110,14 @@ export function Sort(
|
||||
result = lengthSort(array, increasing, joinSeparator, removeDuplicated);
|
||||
break;
|
||||
case 'alphabetic':
|
||||
result = alphabeticSort(array, increasing, joinSeparator, removeDuplicated, caseSensitive);
|
||||
result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
joinSeparator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,12 @@
|
||||
// Import necessary modules and functions
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import {
|
||||
alphabeticSort, lengthSort, numericSort, Sort,
|
||||
SplitOperatorType, SortingMethod
|
||||
alphabeticSort,
|
||||
lengthSort,
|
||||
numericSort,
|
||||
Sort,
|
||||
SplitOperatorType,
|
||||
SortingMethod
|
||||
} from './service';
|
||||
|
||||
// Define test cases for the numericSort function
|
||||
@@ -23,8 +27,8 @@ describe('numericSort function', () => {
|
||||
const separator = ' - ';
|
||||
const removeDuplicated: boolean = true;
|
||||
|
||||
const result = lengthSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('3, 12, 126, 1523, 415689521');
|
||||
const result = numericSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('9 - 7 - 6 - 4 - 2');
|
||||
});
|
||||
|
||||
it('should sort a list with numbers and characters and remove duplicated elements', () => {
|
||||
@@ -33,31 +37,8 @@ describe('numericSort function', () => {
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
|
||||
|
||||
|
||||
const result = lengthSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('d p h 9 7 ddd nfg 6555 5556');
|
||||
});
|
||||
});
|
||||
|
||||
// Define test cases for the alphabeticSort function
|
||||
describe('alphabeticSort function', () => {
|
||||
// NON CASE SENSITIVE TEST
|
||||
it('should sort a list of string in increasing order with comma separator ', () => {
|
||||
const array: any[] = ['apple', 'pineaple', 'lemon', 'orange'];
|
||||
const increasing: boolean = true;
|
||||
const separator = ', ';
|
||||
const removeDuplicated: boolean = false;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('apple, lemon, orange, pineaple');
|
||||
const result = numericSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('5 6 7 9 d h n p');
|
||||
});
|
||||
|
||||
// Define test cases for the lengthSort function
|
||||
@@ -73,7 +54,15 @@ describe('numericSort function', () => {
|
||||
});
|
||||
|
||||
it('should sort a list of number by length in increasing order and remove duplicated elements ', () => {
|
||||
const array: string[] = ['415689521', '3', '3', '126', '12', '12', '1523'];
|
||||
const array: string[] = [
|
||||
'415689521',
|
||||
'3',
|
||||
'3',
|
||||
'126',
|
||||
'12',
|
||||
'12',
|
||||
'1523'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ', ';
|
||||
const removeDuplicated: boolean = true;
|
||||
@@ -83,7 +72,18 @@ describe('numericSort function', () => {
|
||||
});
|
||||
|
||||
it('should sort a mixed array by length in increasing order ', () => {
|
||||
const array: string[] = ['ddd', 'd', 'nfg', 'p', 'h', 'h', '6555', '9', '7', '5556'];
|
||||
const array: string[] = [
|
||||
'ddd',
|
||||
'd',
|
||||
'nfg',
|
||||
'p',
|
||||
'h',
|
||||
'h',
|
||||
'6555',
|
||||
'9',
|
||||
'7',
|
||||
'5556'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
@@ -91,58 +91,6 @@ describe('numericSort function', () => {
|
||||
const result = lengthSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('d p h 9 7 ddd nfg 6555 5556');
|
||||
});
|
||||
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in increasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('@ + 1 9 Apple lemon Orange pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple Orange lemon Apple 9 1 + @');
|
||||
});
|
||||
|
||||
// Define test cases for the alphabeticSort function
|
||||
@@ -155,7 +103,13 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = false;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('apple, lemon, orange, pineaple');
|
||||
});
|
||||
|
||||
@@ -166,33 +120,68 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = false;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple, orange, lemon, apple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in increasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9', '@', '+'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9',
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('@ + 1 9 Apple lemon Orange pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9', '@', '+'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9',
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple Orange lemon Apple 9 1 + @');
|
||||
});
|
||||
|
||||
|
||||
// CASE SENSITIVE TEST
|
||||
it('should sort a list of string (uppercase) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'Pineaple', 'Lemon', 'Orange'];
|
||||
@@ -201,51 +190,113 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = false;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('Pineaple Orange Lemon Apple');
|
||||
});
|
||||
|
||||
it('should sort a list of string (uppercase and lowercase) in increasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('1 9 Apple Orange lemon pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple lemon Orange Apple 9 1');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9', '@', '+'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9',
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('+ 1 9 @ Apple Orange lemon pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'pineaple', 'lemon', 'Orange', '1', '9', '@', '+'];
|
||||
const array: string[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
'1',
|
||||
'9',
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(array, increasing, separator, removeDuplicated, caseSensitive);
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple lemon Orange Apple @ 9 1 +');
|
||||
});
|
||||
});
|
||||
@@ -254,7 +305,7 @@ describe('numericSort function', () => {
|
||||
describe('main function', () => {
|
||||
it('should do everything alph', () => {
|
||||
const sortingMethod: SortingMethod = 'alphabetic';
|
||||
const splitOperatorType : SplitOperatorType = 'symbol';
|
||||
const splitOperatorType: SplitOperatorType = 'symbol';
|
||||
const input: string = 'Apple pineaple lemon Orange 1 9 @ +';
|
||||
const increasing: boolean = true;
|
||||
const splitSeparator: string = ' ';
|
||||
@@ -262,13 +313,22 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = Sort(sortingMethod, splitOperatorType, input, increasing, splitSeparator, joinSeparator, removeDuplicated, caseSensitive);
|
||||
const result = Sort(
|
||||
sortingMethod,
|
||||
splitOperatorType,
|
||||
input,
|
||||
increasing,
|
||||
splitSeparator,
|
||||
joinSeparator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('+ 1 9 @ Apple Orange lemon pineaple');
|
||||
});
|
||||
|
||||
it('should do everything numeric', () => {
|
||||
const sortingMethod: SortingMethod = 'numeric';
|
||||
const splitOperatorType : SplitOperatorType = 'symbol';
|
||||
const splitOperatorType: SplitOperatorType = 'symbol';
|
||||
const input: string = '1 6 9 4 6 7 3 5 8';
|
||||
const increasing: boolean = true;
|
||||
const splitSeparator: string = ' ';
|
||||
@@ -276,61 +336,17 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = Sort(sortingMethod, splitOperatorType, input, increasing, splitSeparator, joinSeparator, removeDuplicated, caseSensitive);
|
||||
const result = Sort(
|
||||
sortingMethod,
|
||||
splitOperatorType,
|
||||
input,
|
||||
increasing,
|
||||
splitSeparator,
|
||||
joinSeparator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('1 3 4 5 6 7 8 9');
|
||||
});
|
||||
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('+ 1 9 @ Apple Orange lemon pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple lemon Orange Apple @ 9 1 +');
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user