Skip to content

Commit

Permalink
fix: add tslib as dependancy and update typing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonyw4 committed Aug 17, 2020
1 parent bc2f2f6 commit 4452894
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
},
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/lib/',
'<rootDir>/__tests__/.eslintrc.js'
],
testEnvironmentOptions: { resources: 'usable' }
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"prop-types": "15.7.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"tslib": "2.0.1",
"use-current-effect": "2.1.0"
},
"devDependencies": {
Expand Down
15 changes: 5 additions & 10 deletions src/Color/Color.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ describe('Color', () => {
test(
'should be a children with default format',
async () => {
const children = jest.fn(() => null);

const children = jest.fn(() => <></>);
await act(async () => {
render(<Color src={src} children={children} crossOrigin="Anonymous" />);
});
Expand Down Expand Up @@ -38,8 +37,7 @@ describe('Color', () => {
'should be a children with rgb array',
async () => {
const format = 'rgbArray';
const children = jest.fn(() => null);

const children = jest.fn(() => <></>);
await act(async () => {
render(
<Color
Expand Down Expand Up @@ -74,8 +72,7 @@ describe('Color', () => {
'should be a children with rgb string',
async () => {
const format = 'rgbString';
const children = jest.fn(() => null);

const children = jest.fn(() => <></>);
await act(async () => {
render(
<Color
Expand Down Expand Up @@ -110,8 +107,7 @@ describe('Color', () => {
'should be a children with hex',
async () => {
const format = 'hex';
const children = jest.fn(() => null);

const children = jest.fn(() => <></>);
await act(async () => {
render(
<Color
Expand Down Expand Up @@ -144,8 +140,7 @@ describe('Color', () => {
test(
'should try to get color from a inexistent image and return error',
async () => {
const children = jest.fn(() => null);

const children = jest.fn(() => <></>);
await act(async () => {
render(
<Color src="error.jpg" children={children} crossOrigin="Anonymous" />
Expand Down
4 changes: 2 additions & 2 deletions src/Color/useColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
reducer,
initialReducerState
} from '../utils';
import { ColorFormats, ReducerState } from '../types';
import { ColorFormats, ReducerState, UnwrapPromise } from '../types';

export type UseColorState = ReducerState<
ReturnType<typeof getPredominantColorFromImgURL>
UnwrapPromise<ReturnType<typeof getPredominantColorFromImgURL>>
>;

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Palette/Palette.component.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, waitFor, act } from '@testing-library/react';
import Palette from './Pallete.component';
import Palette from './Palette.component';

describe('Palette', () => {
const src = 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png';
Expand All @@ -9,7 +9,7 @@ describe('Palette', () => {
test(
'should be a children with default format',
async () => {
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('Palette', () => {
'should be a children with rgb array',
async () => {
const format = 'rgbArray';
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Palette', () => {
'should be a children with rgb string',
async () => {
const format = 'rgbString';
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Palette', () => {
'should be a children with hex',
async () => {
const format = 'hex';
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('Palette', () => {
'should be a children with hex with 4 colors',
async () => {
const format = 'hex';
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('Palette', () => {
test(
'should try to get color from a inexistent image and return error',
async () => {
const children = jest.fn(() => null);
const children = jest.fn(() => <></>);

await act(async () => {
render(
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Palette/usePalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
reducer,
initialReducerState
} from '../utils';
import { ColorFormats, ReducerState } from '../types';
import { ColorFormats, ReducerState, UnwrapPromise } from '../types';

export type UsePaletteState = ReducerState<
ReturnType<typeof getColorsPaletteFromImgUrl>
UnwrapPromise<ReturnType<typeof getColorsPaletteFromImgUrl>>
>;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Color from './Color/Color.component';
import useColor from './Color/useColor';
import getPalette from './utils/getColorsPaletteFromImgUrl';
import Palette from './Palette/Pallete.component';
import Palette from './Palette/Palette.component';
import usePalette from './Palette/usePalette';
import getColor from './utils/getPredominantColorFromImgURL';

Expand Down
1 change: 1 addition & 0 deletions src/types/UnwrapPromise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type UnwrapPromise<T> = T extends PromiseLike<infer U> ? U : T;
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './ColorFormats';
export * from './ReducerAction';
export * from './ReducerState';
export * from './ArrayRGB';
export * from './UnwrapPromise';
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7843,6 +7843,11 @@ tslib@^1.8.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==

tslib@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==

tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"
Expand Down

0 comments on commit 4452894

Please sign in to comment.