Skip to content
Snippets Groups Projects
Commit 6d3d2a4d authored by Åsmund Hunderi Stemland's avatar Åsmund Hunderi Stemland
Browse files

Big shit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #91585 failed
Showing
with 1042 additions and 0 deletions
node_modules
config.js
bundle.js
bundle.js.map
coverage
image: node:latest # Use a docker image from https://hub.docker.com with latest Node.js already installed
variables:
# Configure server/src/mysql-pool.js
MYSQL_HOST: localhost
MYSQL_USER: root # Docker commands are run as root
MYSQL_PASSWORD: '' # Default root password is empty string
MYSQL_DATABASE: todo-test
stages:
- build # Jobs placed in build stage will run first
- test # Jobs placed in test stage will run after build jobs
install:
stage: build
script:
- npm install
artifacts: # Keep node_modules folder for the following stages
paths:
- node_modules
prettier:
stage: test # The prettier job will run in parallel with the flow and test jobs
script:
- ./node_modules/.bin/prettier --check src/* test/*
flow:
stage: test # The flow job will run in parallel with the prettier and test jobs
script:
- ./node_modules/.bin/flow check
test:
stage: test
script:
- apt-get update
- apt-get -y upgrade
- apt-get -y install mysql-server
- service mysql start
# Workaround from https://github.com/mysqljs/mysql/issues/1507#issuecomment-242885003
- echo "UPDATE user SET authentication_string=password(''), plugin='mysql_native_password' WHERE
user='root';" | mysql mysql
- mysqladmin create $MYSQL_DATABASE
# Create database table
- echo "CREATE TABLE Tasks (id INT NOT NULL AUTO_INCREMENT, title TEXT NOT NULL, done BOOL
DEFAULT false, PRIMARY KEY(id));" | mysql $MYSQL_DATABASE
- npm test
\ No newline at end of file
{
"printWidth": 100,
"proseWrap": always,
"singleQuote": true
}
{
"recommendations": ["flowtype.flow-for-vscode", "esbenp.prettier-vscode"]
}
{
"javascript.validate.enable": false,
"editor.formatOnSave": true,
"flow.showUncovered": true
}
LICENSE 0 → 100644
MIT License
Copyright (c) 2020 ntnu-dcst2002
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Client tests example
## Setup database connections
You need to create two configuration files that will contain the database connection details. These
files should not be uploaded to your git repository, and they have therefore been added to
`.gitignore`. The connection details may vary, but example content of the two configuration files
are as follows:
`server/src/config.js`:
```js
// @flow
process.env.MYSQL_HOST = 'mysql.stud.ntnu.no';
process.env.MYSQL_USER = 'username_todo';
process.env.MYSQL_PASSWORD = 'username_todo';
process.env.MYSQL_DATABASE = 'username_todo_dev';
```
`server/test/config.js`:
```js
// @flow
process.env.MYSQL_HOST = 'mysql.stud.ntnu.no';
process.env.MYSQL_USER = 'username_todo';
process.env.MYSQL_PASSWORD = 'username_todo';
process.env.MYSQL_DATABASE = 'username_todo_test';
```
These environment variables will be used in the `server/src/mysql-pool.js` file.
## Start server
Install dependencies and start server:
```sh
cd server
npm install
npm start
```
### Run server tests:
```sh
npm test
```
## Bundle client files to be served through server
Install dependencies and bundle client files:
```sh
cd client
npm install
npm start
```
### Run client tests:
```sh
npm test
```
{
"presets": ["@babel/preset-env", "@babel/preset-flow", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-nullish-coalescing-operator"]
}
[options]
types_first=false
package-lock=false
// flow-typed signature: fe7f00984c44d69833f19bc39895832f
// flow-typed version: a4cc3d5e98/axios_v0.19.x/flow_>=v0.104.x
declare module 'axios' {
import type { Agent as HttpAgent } from 'http';
import type { Agent as HttpsAgent } from 'https';
declare type AxiosTransformer<T> = (
data: T,
headers?: { [key: string]: mixed, ...},
) => mixed;
declare type ProxyConfig = {|
host: string,
port: number,
auth?: {|
username: string,
password: string,
|},
protocol?: string,
|};
declare class Cancel {
constructor(message?: string): Cancel;
message: string;
}
declare type Canceler = (message?: string) => void;
declare type CancelTokenSource = {|
token: CancelToken,
cancel: Canceler,
|};
declare class CancelToken {
constructor(executor: (cancel: Canceler) => void): void;
static source(): CancelTokenSource;
promise: Promise<Cancel>;
reason?: Cancel;
throwIfRequested(): void;
}
declare type Method =
| 'get'
| 'GET'
| 'delete'
| 'DELETE'
| 'head'
| 'HEAD'
| 'options'
| 'OPTIONS'
| 'post'
| 'POST'
| 'put'
| 'PUT'
| 'patch'
| 'PATCH';
declare type ResponseType =
| 'arraybuffer'
| 'blob'
| 'document'
| 'json'
| 'text'
| 'stream';
declare type AxiosAdapter = (
config: AxiosXHRConfig<mixed>
) => Promise<AxiosXHR<mixed>>;
declare type AxiosXHRConfigBase<T, R = T> = {
adapter?: AxiosAdapter,
auth?: {|
username: string,
password: string,
|},
baseURL?: string,
cancelToken?: CancelToken,
headers?: { [key: string]: mixed, ...},
httpAgent?: HttpAgent,
httpsAgent?: HttpsAgent,
maxContentLength?: number,
maxRedirects?: number,
socketPath?: string | null,
params?: { [key: string]: mixed, ...},
paramsSerializer?: (params: { [key: string]: mixed, ...}) => string,
onUploadProgress?: (progressEvent: ProgressEvent) => void,
onDownloadProgress?: (progressEvent: ProgressEvent) => void,
proxy?: ProxyConfig | false,
responseType?: ResponseType,
timeout?: number,
transformRequest?: AxiosTransformer<T> | Array<AxiosTransformer<T>>,
transformResponse?: AxiosTransformer<R> | Array<AxiosTransformer<R>>,
validateStatus?: (status: number) => boolean,
withCredentials?: boolean,
xsrfCookieName?: string,
xsrfHeaderName?: string,
...
};
declare type AxiosXHRConfig<T, R = T> = {
...$Exact<AxiosXHRConfigBase<T, R>>,
data?: T,
method?: Method,
url: string,
...
};
declare type AxiosXHRConfigShape<T, R = T> = $Shape<AxiosXHRConfig<T, R>>;
declare type AxiosXHR<T, R = T> = {|
config: AxiosXHRConfig<T, R>,
data: R,
headers: ?{[key: string]: mixed, ...},
status: number,
statusText: string,
request: http$ClientRequest<> | XMLHttpRequest | mixed,
|};
declare type AxiosInterceptorIdent = number;
declare type AxiosRequestInterceptor<T, R = T> = {|
use(
onFulfilled: ?(
response: AxiosXHRConfig<T, R>
) => Promise<AxiosXHRConfig<mixed>> | AxiosXHRConfig<mixed>,
onRejected: ?(error: mixed) => mixed
): AxiosInterceptorIdent,
eject(ident: AxiosInterceptorIdent): void,
|};
declare type AxiosResponseInterceptor<T, R = T> = {|
use(
onFulfilled: ?(response: AxiosXHR<T, R>) => mixed,
onRejected: ?(error: mixed) => mixed
): AxiosInterceptorIdent,
eject(ident: AxiosInterceptorIdent): void,
|};
declare type AxiosPromise<T, R = T> = Promise<AxiosXHR<T, R>>;
declare class Axios {
<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
constructor<T, R>(config?: AxiosXHRConfigBase<T, R>): void;
request<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
delete<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
get<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
head<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
options<R>(
url: string,
config?: AxiosXHRConfigBase<mixed, R>
): AxiosPromise<mixed, R>;
post<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
put<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
patch<T, R>(
url: string,
data?: T,
config?: AxiosXHRConfigBase<T, R>
): AxiosPromise<T, R>;
interceptors: {|
request: AxiosRequestInterceptor<mixed>,
response: AxiosResponseInterceptor<mixed>,
|};
defaults: {|
...$Exact<AxiosXHRConfigBase<mixed>>,
headers: { [key: string]: mixed, ...},
|};
getUri<T, R>(config?: AxiosXHRConfig<T, R>): string;
}
declare class AxiosError<T, R = T> extends Error {
config: AxiosXHRConfig<T, R>;
request?: http$ClientRequest<> | XMLHttpRequest;
response?: AxiosXHR<T, R>;
code?: string;
isAxiosError: boolean;
}
declare interface AxiosExport extends Axios {
<T, R>(
config: AxiosXHRConfig<T, R> | string,
config?: AxiosXHRConfigShape<T, R>
): AxiosPromise<T, R>;
Axios: typeof Axios;
Cancel: typeof Cancel;
CancelToken: typeof CancelToken;
isCancel(value: mixed): boolean;
create(config?: AxiosXHRConfigBase<T, R>): Axios;
all: typeof Promise.all;
spread<T, R>(callback: (...args: T) => R): (array: T) => R;
}
declare type $AxiosXHRConfigBase<T, R = T> = AxiosXHRConfigBase<T, R>;
declare type $AxiosXHRConfig<T, R = T> = AxiosXHRConfig<T, R>;
declare type $AxiosXHR<T, R = T> = AxiosXHR<T, R>;
declare type $AxiosError<T, R = T> = AxiosError<T, R>;
declare module.exports: AxiosExport;
}
// flow-typed signature: 20e2bb4e722c2a79e4e0f178491bf6cc
// flow-typed version: 1f669c8dd2/enzyme_v3.x.x/flow_>=v0.104.x
declare module "enzyme" {
declare type PredicateFunction<T: Wrapper<*>> = (
wrapper: T,
index: number
) => boolean;
declare type UntypedSelector = string | { [key: string]: number|string|boolean, ... };
declare type EnzymeSelector = UntypedSelector | React$ElementType;
// CheerioWrapper is a type alias for an actual cheerio instance
// TODO: Reference correct type from cheerio's type declarations
declare type CheerioWrapper = any;
declare class Wrapper<RootComponent> {
at(index: number): this,
childAt(index: number): this,
children(selector?: UntypedSelector): this,
children<T: React$ElementType>(selector: T): ReactWrapper<T>,
closest(selector: UntypedSelector): this,
closest<T: React$ElementType>(selector: T): ReactWrapper<T>,
contains(nodes: React$Element<any> | $ReadOnlyArray<React$Element<any>>): boolean,
containsAllMatchingElements(nodes: $ReadOnlyArray<React$Element<any>>): boolean,
containsAnyMatchingElements(nodes: $ReadOnlyArray<React$Element<any>>): boolean,
containsMatchingElement(node: React$Element<any>): boolean,
context(key?: string): any,
debug(options?: Object): string,
dive(option?: { context?: Object, ... }): this,
equals(node: React$Element<any>): boolean,
every(selector: EnzymeSelector): boolean,
everyWhere(predicate: PredicateFunction<this>): boolean,
exists(selector?: EnzymeSelector): boolean,
filter(selector: UntypedSelector): this,
filter<T: React$ElementType>(selector: T): ReactWrapper<T>,
filterWhere(predicate: PredicateFunction<this>): this,
find(selector: UntypedSelector): this,
find<T: React$ElementType>(selector: T): ReactWrapper<T>,
findWhere(predicate: PredicateFunction<this>): this,
first(): this,
forEach(fn: (node: this, index: number) => mixed): this,
get<T = any>(index: number): React$Element<T>,
getDOMNode(): HTMLElement | HTMLInputElement,
hasClass(className: string): boolean,
hostNodes(): this,
html(): string,
instance(): React$ElementRef<RootComponent>,
invoke(propName: string): (...args: $ReadOnlyArray<any>) => mixed,
is(selector: EnzymeSelector): boolean,
isEmpty(): boolean,
isEmptyRender(): boolean,
key(): string,
last(): this,
length: number,
map<T>(fn: (node: this, index: number) => T): Array<T>,
matchesElement(node: React$Element<any>): boolean,
name(): string,
not(selector: EnzymeSelector): this,
parent(): this,
parents(selector?: UntypedSelector): this,
parents<T: React$ElementType>(selector: T): ReactWrapper<T>,
prop(key: string): any,
props(): Object,
reduce<T>(
fn: (value: T, node: this, index: number) => T,
initialValue?: T
): Array<T>,
reduceRight<T>(
fn: (value: T, node: this, index: number) => T,
initialValue?: T
): Array<T>,
render(): CheerioWrapper,
renderProp(propName: string): (...args: Array<any>) => this,
setContext(context: Object): this,
setProps(props: {...}, callback?: () => void): this,
setState(state: {...}, callback?: () => void): this,
simulate(event: string, ...args: Array<any>): this,
simulateError(error: Error): this,
slice(begin?: number, end?: number): this,
some(selector: EnzymeSelector): boolean,
someWhere(predicate: PredicateFunction<this>): boolean,
state(key?: string): any,
text(): string,
type(): string | Function | null,
unmount(): this,
update(): this,
}
declare class ReactWrapper<T> extends Wrapper<T> {
constructor(nodes: React$Element<T>, root: any, options?: ?Object): ReactWrapper<T>,
mount(): this,
ref(refName: string): this,
detach(): void
}
declare class ShallowWrapper<T> extends Wrapper<T> {
constructor(
nodes: React$Element<T>,
root: any,
options?: ?Object
): ShallowWrapper<T>,
shallow(options?: { context?: Object, ... }): ShallowWrapper<T>,
getElement<T = any>(): React$Element<T>,
getElements<T = any>(): Array<React$Element<T>>
}
declare function shallow<T>(
node: React$Element<T>,
options?: {
context?: Object,
disableLifecycleMethods?: boolean,
...
}
): ShallowWrapper<T>;
declare function mount<T>(
node: React$Element<T>,
options?: {
context?: Object,
attachTo?: HTMLElement,
childContextTypes?: Object,
...
}
): ReactWrapper<T>;
declare function render(
node: React$Node,
options?: { context?: Object, ... }
): CheerioWrapper;
declare module.exports: {
configure(options: {
Adapter?: any,
disableLifecycleMethods?: boolean,
...
}): void,
render: typeof render,
mount: typeof mount,
shallow: typeof shallow,
ShallowWrapper: typeof ShallowWrapper,
ReactWrapper: typeof ReactWrapper,
...
};
}
// flow-typed signature: 90337b03d736e9bdaa68004c36c4d3ee
// flow-typed version: 51319746df/history_v4.10.x/flow_>=v0.104.x
declare module 'history' {
declare type Unregister = () => void;
declare export type Action = 'PUSH' | 'REPLACE' | 'POP';
declare export type Location = {|
pathname: string,
search: string,
hash: string,
state: { ... },
key: string,
|};
declare type History<HistoryLocation = Location> = {|
length: number,
location: HistoryLocation,
action: Action,
push: ((path: string, state?: { ... }) => void) &
((location: $Shape<HistoryLocation>) => void),
replace: ((path: string, state?: { ... }) => void) &
((location: $Shape<HistoryLocation>) => void),
go(n: number): void,
goBack(): void,
goForward(): void,
listen((location: HistoryLocation, action: Action) => void): Unregister,
block(
prompt:
| string
| boolean
| ((location: HistoryLocation, action: Action) => string | false | void)
): Unregister,
createHref(location: $Shape<HistoryLocation>): string,
|};
declare export type BrowserHistory = History<>;
declare type BrowserHistoryOpts = {|
basename?: string,
forceRefresh?: boolean,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
keyLength?: number,
|};
declare function createBrowserHistory(
opts?: BrowserHistoryOpts
): BrowserHistory;
declare export type MemoryHistory = {|
...History<>,
index: number,
entries: Array<string | Location>,
canGo(n: number): boolean,
|};
declare type MemoryHistoryOpts = {|
initialEntries?: Array<string>,
initialIndex?: number,
keyLength?: number,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
|};
declare function createMemoryHistory(opts?: MemoryHistoryOpts): MemoryHistory;
declare export type HashLocation = {|
...Location,
state: void,
key: void,
|};
declare export type HashHistory = History<HashLocation>;
declare type HashHistoryOpts = {|
basename?: string,
hashType: 'slash' | 'noslash' | 'hashbang',
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
|};
declare function createHashHistory(opts?: HashHistoryOpts): HashHistory;
// PathUtils
declare function parsePath(path: string): Location;
declare function createPath(location: $Shape<Location>): string;
// LocationUtils
declare function locationsAreEqual(
a: $Shape<Location>,
b: $Shape<Location>
): boolean;
declare function createLocation(
path: string | $Shape<Location>,
state?: { ... },
key?: string,
currentLocation?: Location
): Location;
}
This diff is collapsed.
// flow-typed signature: a333d1cdbb5a4103d0be63a412070e22
// flow-typed version: b2693c1879/react-dom_v16.x.x/flow_>=v0.117.x
declare module 'react-dom' {
declare function findDOMNode(
componentOrElement: Element | ?React$Component<any, any>,
): null | Element | Text;
declare function render<ElementType: React$ElementType>(
element: React$Element<ElementType>,
container: Element,
callback?: () => void,
): React$ElementRef<ElementType>;
declare function hydrate<ElementType: React$ElementType>(
element: React$Element<ElementType>,
container: Element,
callback?: () => void,
): React$ElementRef<ElementType>;
declare function createPortal(
node: React$Node,
container: Element,
): React$Portal;
declare function unmountComponentAtNode(container: any): boolean;
declare var version: string;
declare function unstable_batchedUpdates<A, B, C, D, E>(
callback: (a: A, b: B, c: C, d: D, e: E) => mixed,
a: A,
b: B,
c: C,
d: D,
e: E,
): void;
declare function unstable_renderSubtreeIntoContainer<
ElementType: React$ElementType,
>(
parentComponent: React$Component<any, any>,
nextElement: React$Element<ElementType>,
container: any,
callback?: () => void,
): React$ElementRef<ElementType>;
}
declare module 'react-dom/server' {
declare function renderToString(element: React$Node): string;
declare function renderToStaticMarkup(element: React$Node): string;
declare function renderToNodeStream(element: React$Node): stream$Readable;
declare function renderToStaticNodeStream(
element: React$Node,
): stream$Readable;
declare var version: string;
}
type Thenable = { then(resolve: () => mixed, reject?: () => mixed): mixed, ... };
declare module 'react-dom/test-utils' {
declare var Simulate: { [eventName: string]: (element: Element, eventData?: Object) => void, ... };
declare function renderIntoDocument(
instance: React$Element<any>,
): React$Component<any, any>;
declare function mockComponent(
componentClass: React$ElementType,
mockTagName?: string,
): Object;
declare function isElement(element: React$Element<any>): boolean;
declare function isElementOfType(
element: React$Element<any>,
componentClass: React$ElementType,
): boolean;
declare function isDOMComponent(instance: any): boolean;
declare function isCompositeComponent(
instance: React$Component<any, any>,
): boolean;
declare function isCompositeComponentWithType(
instance: React$Component<any, any>,
componentClass: React$ElementType,
): boolean;
declare function findAllInRenderedTree(
tree: React$Component<any, any>,
test: (child: React$Component<any, any>) => boolean,
): Array<React$Component<any, any>>;
declare function scryRenderedDOMComponentsWithClass(
tree: React$Component<any, any>,
className: string,
): Array<Element>;
declare function findRenderedDOMComponentWithClass(
tree: React$Component<any, any>,
className: string,
): ?Element;
declare function scryRenderedDOMComponentsWithTag(
tree: React$Component<any, any>,
tagName: string,
): Array<Element>;
declare function findRenderedDOMComponentWithTag(
tree: React$Component<any, any>,
tagName: string,
): ?Element;
declare function scryRenderedComponentsWithType(
tree: React$Component<any, any>,
componentClass: React$ElementType,
): Array<React$Component<any, any>>;
declare function findRenderedComponentWithType(
tree: React$Component<any, any>,
componentClass: React$ElementType,
): ?React$Component<any, any>;
declare function act(callback: () => void | Thenable): Thenable;
}
// flow-typed signature: 33bc320ebb5343629e228a9caa367310
// flow-typed version: c4f47bdda4/react-router-dom_v5.x.x/flow_>=v0.104.x
declare module "react-router-dom" {
declare export var BrowserRouter: React$ComponentType<{|
basename?: string,
forceRefresh?: boolean,
getUserConfirmation?: GetUserConfirmation,
keyLength?: number,
children?: React$Node
|}>
declare export var HashRouter: React$ComponentType<{|
basename?: string,
getUserConfirmation?: GetUserConfirmation,
hashType?: "slash" | "noslash" | "hashbang",
children?: React$Node
|}>
declare export var Link: React$ComponentType<{
+className?: string,
+to: string | LocationShape,
+replace?: boolean,
+children?: React$Node,
...
}>
declare export var NavLink: React$ComponentType<{
+to: string | LocationShape,
+activeClassName?: string,
+className?: string,
+activeStyle?: { +[string]: mixed, ... },
+style?: { +[string]: mixed, ... },
+isActive?: (match: Match, location: Location) => boolean,
+children?: React$Node,
+exact?: boolean,
+strict?: boolean,
...
}>
// NOTE: Below are duplicated from react-router. If updating these, please
// update the react-router and react-router-native types as well.
declare export type Location = {
pathname: string,
search: string,
hash: string,
...
};
declare export type LocationShape = {
pathname?: string,
search?: string,
hash?: string,
...
};
declare export type HistoryAction = "PUSH" | "REPLACE" | "POP";
declare export type RouterHistory = {
length: number,
location: Location,
action: HistoryAction,
listen(
callback: (location: Location, action: HistoryAction) => void
): () => void,
push(path: string | LocationShape, state?: any): void,
replace(path: string | LocationShape, state?: any): void,
go(n: number): void,
goBack(): void,
goForward(): void,
canGo?: (n: number) => boolean,
block(
callback: string | (location: Location, action: HistoryAction) => ?string
): () => void,
...
};
declare export type Match = {
params: { [key: string]: ?string, ... },
isExact: boolean,
path: string,
url: string,
...
};
declare export type ContextRouter = {|
history: RouterHistory,
location: Location,
match: Match,
staticContext?: StaticRouterContext
|};
declare type ContextRouterVoid = {
history: RouterHistory | void,
location: Location | void,
match: Match | void,
staticContext?: StaticRouterContext | void,
...
};
declare export type GetUserConfirmation = (
message: string,
callback: (confirmed: boolean) => void
) => void;
declare export type StaticRouterContext = { url?: string, ... };
declare export var StaticRouter: React$ComponentType<{|
basename?: string,
location?: string | Location,
context: StaticRouterContext,
children?: React$Node
|}>
declare export var MemoryRouter: React$ComponentType<{|
initialEntries?: Array<LocationShape | string>,
initialIndex?: number,
getUserConfirmation?: GetUserConfirmation,
keyLength?: number,
children?: React$Node
|}>
declare export var Router: React$ComponentType<{|
history: RouterHistory,
children?: React$Node
|}>
declare export var Prompt: React$ComponentType<{|
message: string | ((location: Location) => string | boolean),
when?: boolean
|}>
declare export var Redirect: React$ComponentType<{|
to: string | LocationShape,
push?: boolean,
from?: string,
exact?: boolean,
strict?: boolean
|}>
declare export var Route: React$ComponentType<{|
component?: React$ComponentType<*>,
render?: (router: ContextRouter) => React$Node,
children?: React$ComponentType<ContextRouter> | React$Node,
path?: string | Array<string>,
exact?: boolean,
strict?: boolean,
location?: LocationShape,
sensitive?: boolean
|}>
declare export var Switch: React$ComponentType<{|
children?: React$Node,
location?: Location
|}>
declare export function withRouter<Props: {...}, Component: React$ComponentType<Props>>(
WrappedComponent: Component
): React$ComponentType<$Diff<React$ElementConfig<Component>, ContextRouterVoid>>;
declare type MatchPathOptions = {
path?: string | string[],
exact?: boolean,
sensitive?: boolean,
strict?: boolean,
...
};
declare export function matchPath(
pathname: string,
options?: MatchPathOptions | string | string[],
parent?: Match
): null | Match;
declare export function useHistory(): $PropertyType<ContextRouter, 'history'>;
declare export function useLocation(): $PropertyType<ContextRouter, 'location'>;
declare export function useParams(): $PropertyType<$PropertyType<ContextRouter, 'match'>, 'params'>;
declare export function useRouteMatch(path?: MatchPathOptions | string | string[]): $PropertyType<ContextRouter, 'match'>;
declare export function generatePath(pattern?: string, params?: { +[string]: mixed, ... }): string;
}
// flow-typed signature: 7bac6c05f7415881918d3d510109e739
// flow-typed version: fce74493f0/react-test-renderer_v16.x.x/flow_>=v0.104.x
// Type definitions for react-test-renderer 16.x.x
// Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer
type ReactComponentInstance = React$Component<any>;
type ReactTestRendererJSON = {
type: string,
props: { [propName: string]: any, ... },
children: null | ReactTestRendererJSON[],
...
};
type ReactTestRendererTree = ReactTestRendererJSON & {
nodeType: "component" | "host",
instance: ?ReactComponentInstance,
rendered: null | ReactTestRendererTree,
...
};
type ReactTestInstance = {
instance: ?ReactComponentInstance,
type: string,
props: { [propName: string]: any, ... },
parent: null | ReactTestInstance,
children: Array<ReactTestInstance | string>,
find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance,
findByType(type: React$ElementType): ReactTestInstance,
findByProps(props: { [propName: string]: any, ... }): ReactTestInstance,
findAll(
predicate: (node: ReactTestInstance) => boolean,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByType(
type: React$ElementType,
options?: { deep: boolean, ... }
): ReactTestInstance[],
findAllByProps(
props: { [propName: string]: any, ... },
options?: { deep: boolean, ... }
): ReactTestInstance[],
...
};
type TestRendererOptions = { createNodeMock(element: React$Element<any>): any, ... };
declare module "react-test-renderer" {
declare export type ReactTestRenderer = {
toJSON(): null | ReactTestRendererJSON,
toTree(): null | ReactTestRendererTree,
unmount(nextElement?: React$Element<any>): void,
update(nextElement: React$Element<any>): void,
getInstance(): ?ReactComponentInstance,
root: ReactTestInstance,
...
};
declare type Thenable = { then(resolve: () => mixed, reject?: () => mixed): mixed, ... };
declare function create(
nextElement: React$Element<any>,
options?: TestRendererOptions
): ReactTestRenderer;
declare function act(callback: () => void | Promise<void>): Thenable;
}
declare module "react-test-renderer/shallow" {
declare export default class ShallowRenderer {
static createRenderer(): ShallowRenderer;
getMountedInstance(): ReactTestInstance;
getRenderOutput<E: React$Element<any>>(): E;
getRenderOutput(): React$Element<any>;
render(element: React$Element<any>, context?: any): void;
unmount(): void;
}
}
{
"name": "todo-client",
"version": "1.0.0",
"description": "A simple Todo web client",
"license": "MIT",
"scripts": {
"start": "webpack --mode development --watch",
"test": "jest --setupFiles ./test/setup"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"collectCoverage": true
},
"browserslist": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
],
"dependencies": {
"axios": "^0.20.0",
"react-router-dom": "^5.2.0",
"react-simplified": "^2.0.1"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/preset-env": "^7.11.5",
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"babel-jest": "^26.3.0",
"babel-loader": "^8.1.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.4",
"enzyme-to-json": "^3.5.0",
"flow-bin": "^0.134.0",
"jest": "^26.4.2",
"prettier": "^2.1.1",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
}
}
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment