Skip to content

Commit

Permalink
test: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iRoachie committed Dec 17, 2017
1 parent 321db34 commit ac9e4a2
Show file tree
Hide file tree
Showing 12 changed files with 2,286 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"jest": true
},
"parserOptions": {
"sourceType": "module",
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ node_js:
install:
- yarn

before_script:
- yarn run flow
- yarn run lint
script:
- yarn run flow && yarn run lint && yarn run test
32 changes: 32 additions & 0 deletions flow-typed/npm/babel-jest_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// flow-typed signature: 476cdf041c12e4372121dd0d59078192
// flow-typed version: <<STUB>>/babel-jest_v21.2.0/flow_v0.56.0

/**
* This is an autogenerated libdef stub for:
*
* 'babel-jest'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'babel-jest' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babel-jest/build/index' {
declare module.exports: any;
}

// Filename aliases
declare module 'babel-jest/build/index.js' {
declare module.exports: $Exports<'babel-jest/build/index'>;
}
73 changes: 73 additions & 0 deletions flow-typed/npm/babel-preset-react-native_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// flow-typed signature: 0a6f0b938b4ca850cbfe51d2630f769c
// flow-typed version: <<STUB>>/babel-preset-react-native_v4.0.0/flow_v0.56.0

/**
* This is an autogenerated libdef stub for:
*
* 'babel-preset-react-native'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'babel-preset-react-native' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babel-preset-react-native/configs/hmr' {
declare module.exports: any;
}

declare module 'babel-preset-react-native/configs/main' {
declare module.exports: any;
}

declare module 'babel-preset-react-native/lib/resolvePlugins' {
declare module.exports: any;
}

declare module 'babel-preset-react-native/plugins' {
declare module.exports: any;
}

declare module 'babel-preset-react-native/transforms/transform-dynamic-import' {
declare module.exports: any;
}

declare module 'babel-preset-react-native/transforms/transform-symbol-member' {
declare module.exports: any;
}

// Filename aliases
declare module 'babel-preset-react-native/configs/hmr.js' {
declare module.exports: $Exports<'babel-preset-react-native/configs/hmr'>;
}
declare module 'babel-preset-react-native/configs/main.js' {
declare module.exports: $Exports<'babel-preset-react-native/configs/main'>;
}
declare module 'babel-preset-react-native/index' {
declare module.exports: $Exports<'babel-preset-react-native'>;
}
declare module 'babel-preset-react-native/index.js' {
declare module.exports: $Exports<'babel-preset-react-native'>;
}
declare module 'babel-preset-react-native/lib/resolvePlugins.js' {
declare module.exports: $Exports<'babel-preset-react-native/lib/resolvePlugins'>;
}
declare module 'babel-preset-react-native/plugins.js' {
declare module.exports: $Exports<'babel-preset-react-native/plugins'>;
}
declare module 'babel-preset-react-native/transforms/transform-dynamic-import.js' {
declare module.exports: $Exports<'babel-preset-react-native/transforms/transform-dynamic-import'>;
}
declare module 'babel-preset-react-native/transforms/transform-symbol-member.js' {
declare module.exports: $Exports<'babel-preset-react-native/transforms/transform-symbol-member'>;
}
126 changes: 126 additions & 0 deletions flow-typed/npm/enzyme_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// flow-typed signature: 687805dabf4b11b8ad99d263c9d3703d
// flow-typed version: f0c7fe5246/enzyme_v3.x.x/flow_>=v0.53.x

import * as React from "react";

declare module "enzyme" {
declare type PredicateFunction<T: Wrapper> = (
wrapper: T,
index: number
) => boolean;
declare type NodeOrNodes = React.Node | Array<React.Node>;
declare type EnzymeSelector = string | Class<React.Component<*, *>> | Object;

// 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 {
find(selector: EnzymeSelector): this,
findWhere(predicate: PredicateFunction<this>): this,
filter(selector: EnzymeSelector): this,
filterWhere(predicate: PredicateFunction<this>): this,
contains(nodeOrNodes: NodeOrNodes): boolean,
containsMatchingElement(node: React.Node): boolean,
containsAllMatchingElements(nodes: NodeOrNodes): boolean,
containsAnyMatchingElements(nodes: NodeOrNodes): boolean,
dive(option?: { context?: Object }): this,
exists(): boolean,
isEmptyRender(): boolean,
matchesElement(node: React.Node): boolean,
hasClass(className: string): boolean,
is(selector: EnzymeSelector): boolean,
isEmpty(): boolean,
not(selector: EnzymeSelector): this,
children(selector?: EnzymeSelector): this,
childAt(index: number): this,
parents(selector?: EnzymeSelector): this,
parent(): this,
closest(selector: EnzymeSelector): this,
render(): CheerioWrapper,
unmount(): this,
text(): string,
html(): string,
get(index: number): React.Node,
getNodes(): Array<React.Node>,
getDOMNode(): HTMLElement | HTMLInputElement,
at(index: number): this,
first(): this,
last(): this,
state(key?: string): any,
context(key?: string): any,
props(): Object,
prop(key: string): any,
key(): string,
simulate(event: string, ...args: Array<any>): this,
setState(state: {}, callback?: Function): this,
setProps(props: {}): this,
setContext(context: Object): this,
instance(): React.Component<*, *>,
update(): this,
debug(): string,
type(): string | Function | null,
name(): string,
forEach(fn: (node: this, index: number) => mixed): this,
map<T>(fn: (node: this, index: number) => T): Array<T>,
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>,
some(selector: EnzymeSelector): boolean,
someWhere(predicate: PredicateFunction<this>): boolean,
every(selector: EnzymeSelector): boolean,
everyWhere(predicate: PredicateFunction<this>): boolean,
length: number
}

declare class ReactWrapper extends Wrapper {
constructor(nodes: NodeOrNodes, root: any, options?: ?Object): ReactWrapper,
mount(): this,
ref(refName: string): this,
detach(): void
}

declare class ShallowWrapper extends Wrapper {
constructor(
nodes: NodeOrNodes,
root: any,
options?: ?Object
): ShallowWrapper,
equals(node: React.Node): boolean,
shallow(options?: { context?: Object }): ShallowWrapper
}

declare function shallow(
node: React.Node,
options?: { context?: Object, disableLifecycleMethods?: boolean }
): ShallowWrapper;
declare function mount(
node: React.Node,
options?: {
context?: Object,
attachTo?: HTMLElement,
childContextTypes?: Object
}
): ReactWrapper;
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
};
}
Loading

0 comments on commit ac9e4a2

Please sign in to comment.