Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions react/ecmascript/01 - spread/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { isArray } from './utils';

export function min() {
isArray();
return Math.min();
if (arguments === 1) {
return arguments[0];
} else if (arguments.length === 0) {
return undefined;
}
let [args] = arguments;
if (isArray(args) === true) {
return Math.min(...args);
} else {
return Math.min(...arguments);
}
}

export function copy() {
Expand Down
8 changes: 4 additions & 4 deletions react/ecmascript/01 - spread/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { min, copy, reverseMerge, filterAttribs } from '.';

describe('Spread operator', () => {
xit('min returns the param if is the only argument', () => {
it('min returns the param if is the only argument', () => {
expect(min(1)).toBe(1);
expect(min(2)).toBe(2);
});
xit('min can return the minimum based on a list', () => {
it('min can return the minimum based on a list', () => {
expect(min([1, 2])).toBe(1);
expect(min([2, 1])).toBe(1);
});
xit('min can return the minimum based on many parameters', () => {
it('min can return the minimum based on many parameters', () => {
expect(min(1, 2, 3, 4, 5, 0)).toBe(0);
expect(min(1, 2, 3, 4, -1, 0)).toBe(-1);
});
xit('min returns undefined on no args', () => {
it('min returns undefined on no args', () => {
expect(min()).toBe(undefined);
});
xit('copy can copy objects', () => {
Expand Down