Skip to content

Commit

Permalink
test: use compat/map for test (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon authored Dec 7, 2024
1 parent 2e3e2be commit ceb7513
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 28 deletions.
12 changes: 6 additions & 6 deletions src/compat/function/curry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bind } from './bind';
import { curry } from './curry';
import { partial } from '../../function/partial';
import { partialRight } from '../../function/partialRight';
import { map } from '../array/map';

describe('curry', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -151,14 +152,13 @@ describe('curry', () => {
return Array.from(arguments);
}
const array = [fn, fn, fn];
// TODO test object like this
// const object = { 'a': fn, 'b': fn, 'c': fn };
const object = { a: fn, b: fn, c: fn };

[array].forEach(collection => {
const curries = collection.map(curry),
expected = collection.map(() => ['a', 'b']);
[array, object].forEach(collection => {
const curries = map(collection, curry as (...args: any[]) => any),
expected = map(collection, () => ['a', 'b']);

const actual = curries.map(curried => curried('a')('b'));
const actual = map(curries, curried => curried('a')('b'));

expect(actual).toEqual(expected);
});
Expand Down
12 changes: 6 additions & 6 deletions src/compat/function/curryRight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bind } from './bind';
import { curryRight } from './curryRight';
import { partial } from '../../function/partial';
import { partialRight } from '../../function/partialRight';
import { map } from '../array/map';

describe('curryRight', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -151,14 +152,13 @@ describe('curryRight', () => {
return Array.from(arguments);
}
const array = [fn, fn, fn];
// TODO test object like this
// const object = { 'a': fn, 'b': fn, 'c': fn };
const object = { a: fn, b: fn, c: fn };

[array].forEach(collection => {
const curries = collection.map(curryRight),
expected = collection.map(() => ['a', 'b']);
[array, object].forEach(collection => {
const curries = map(collection, curryRight as (...args: any[]) => any),
expected = map(collection, () => ['a', 'b']);

const actual = curries.map(curried => curried('b')('a'));
const actual = map(curries, curried => curried('b')('a'));

expect(actual).toEqual(expected);
});
Expand Down
5 changes: 1 addition & 4 deletions src/compat/function/flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ary } from './ary';
import { flow } from './flow';
import { head } from '../../array/head';
import { uniq } from '../../array/uniq';
import { map } from '../array/map';
import { curry } from '../function/curry';

const add = function (x: number, y: number) {
Expand Down Expand Up @@ -38,10 +39,6 @@ describe('flow', () => {
});

it(`\`flow\` should work with curried functions with placeholders`, () => {
// TODO change to es-toolkit/compat - map
const map = (array: any[], func: (...args: any[]) => any) => {
return array.map(func);
};
const curried = curry(ary(map, 2), 2);
const getProp = curried(curried.placeholder, (value: { a: any }) => value.a);
const objects = [{ a: 1 }, { a: 2 }, { a: 1 }];
Expand Down
5 changes: 1 addition & 4 deletions src/compat/function/flowRight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ary } from './ary';
import { flowRight } from './flowRight';
import { head } from '../../array/head';
import { uniq } from '../../array/uniq';
import { map } from '../array/map';
import { curry } from '../function/curry';

const add = function (x: number, y: number) {
Expand Down Expand Up @@ -38,10 +39,6 @@ describe('flowRight', () => {
});

it(`\`flowRight\` should work with curried functions with placeholders`, () => {
// TODO change to es-toolkit/compat - map
const map = (array: any[], func: (...args: any[]) => any) => {
return array.map(func);
};
const curried = curry(ary(map, 2), 2);
const getProp = curried(curried.placeholder, (value: { a: any }) => value.a);
const objects = [{ a: 1 }, { a: 2 }, { a: 1 }];
Expand Down
5 changes: 1 addition & 4 deletions src/function/flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ary } from './ary';
import { flow } from './flow';
import { head } from '../array';
import { uniq } from '../array';
import { map } from '../compat';
import { curry } from '../compat/function/curry';

const add = function (x: number, y: number) {
Expand Down Expand Up @@ -38,10 +39,6 @@ describe('flow', () => {
});

it(`\`flow\` should work with curried functions with placeholders`, () => {
// TODO change to es-toolkit/compat - map
const map = (array: any[], func: (...args: any[]) => any) => {
return array.map(func);
};
const curried = curry(ary(map, 2), 2);
const getProp = curried(curried.placeholder, (value: { a: any }) => value.a);
const objects = [{ a: 1 }, { a: 2 }, { a: 1 }];
Expand Down
5 changes: 1 addition & 4 deletions src/function/flowRight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ary } from './ary';
import { flowRight } from './flowRight';
import { head } from '../array';
import { uniq } from '../array';
import { map } from '../compat';
import { curry } from '../compat/function/curry';

const add = function (x: number, y: number) {
Expand Down Expand Up @@ -38,10 +39,6 @@ describe('flowRight', () => {
});

it(`\`flowRight\` should work with curried functions with placeholders`, () => {
// TODO change to es-toolkit/compat - map
const map = (array: any[], func: (...args: any[]) => any) => {
return array.map(func);
};
const curried = curry(ary(map, 2), 2);
const getProp = curried(curried.placeholder, (value: { a: any }) => value.a);
const objects = [{ a: 1 }, { a: 2 }, { a: 1 }];
Expand Down

0 comments on commit ceb7513

Please sign in to comment.