Skip to content

Commit

Permalink
Initial project structure and simple component/test for proof
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysyngsun committed Dec 8, 2017
1 parent cffa662 commit f04f157
Show file tree
Hide file tree
Showing 19 changed files with 5,826 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*.py]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
43 changes: 43 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"extends": ["eslint-config-mitodl"],
"env":{
"mocha": false
},
"rules": {
"ava/assertion-arguments": "error",
"ava/max-asserts": ["off", 5],
"ava/no-async-fn-without-await": "error",
"ava/no-cb-test": "off",
"ava/no-duplicate-modifiers": "error",
"ava/no-identical-title": "error",
"ava/no-ignored-test-files": "error",
"ava/no-invalid-end": "error",
"ava/no-nested-tests": "error",
"ava/no-only-test": "error",
"ava/no-skip-assert": "error",
"ava/no-skip-test": "error",
"ava/no-statement-after-end": "error",
"ava/no-todo-implementation": "error",
"ava/no-todo-test": "warn",
"ava/no-unknown-modifiers": "error",
"ava/prefer-async-await": "error",
"ava/prefer-power-assert": "off",
"ava/test-ended": "error",
"ava/test-title": ["error", "if-multiple"],
"ava/use-t-well": "error",
"ava/use-t": "error",
"ava/use-test": "error",
"ava/use-true-false": "error",
"mocha/no-exclusive-tests": false,
"mocha/no-skipped-tests": false,
"mocha/no-sibling-hooks": false,
"mocha/no-global-tests": false,
"mocha/handle-done-callback": false,
"mocha/no-top-level-hooks": false,
"mocha/no-identical-title": false,
"mocha/no-nested-tests": false
},
"plugins": [
"ava"
]
}
15 changes: 15 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[ignore]
.*/node_modules/fbjs/.*
.*/node_modules/react-event-listener/src/index.js
.*.git/.*

[include]
./src

[libs]
./flow-typed/npm/

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.idea
*~
lib/
npm-debug.log
coverage
.nyc_output
yarn-error.log
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "8"
cache: yarn
script:
- ./travis/js_test.sh

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:8.9.2
LABEL maintainer "ODL DevOps <[email protected]>"

RUN apt-get update && apt-get install libelf1

COPY package.json /src/

RUN mkdir -p /root/.cache/yarn

RUN chown root:root /root/.cache/yarn
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"
services:
watch:
build: .
working_dir: /src
command: yarn test
volumes:
- .:/src
- yarn-cache:/root/.cache/yarn
volumes:
yarn-cache: {}
110 changes: 110 additions & 0 deletions flow-typed/npm/enzyme_v2.3.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// flow-typed signature: 905cf3353a9aaa3647dc2232b1cd864a
// flow-typed version: 8742c67386/enzyme_v2.3.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,
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,
getNode(): 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 export class ReactWrapper extends Wrapper {
constructor(nodes: NodeOrNodes, root: any, options?: ?Object): ReactWrapper,
mount(): this,
ref(refName: string): this,
detach(): void
}

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

declare export function shallow(
node: React.Node,
options?: { context?: Object }
): ShallowWrapper;
declare export function mount(
node: React.Node,
options?: {
context?: Object,
attachTo?: HTMLElement,
childContextTypes?: Object
}
): ReactWrapper;
declare export function render(
node: React.Node,
options?: { context?: Object }
): CheerioWrapper;
}
99 changes: 99 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"name": "mdl-react-components",
"version": "0.0.0",
"description": "React component implementations for material library",
"scripts": {
"test": "./scripts/test/js_test.sh",
"coverage": "COVERAGE=1 ./scripts/test/js_test.sh",
"codecov": "CODECOV=1 ./scripts/test/js_test.sh",
"watch": "WATCH=1 ./scripts/test/js_test.sh",
"lint": "node ./node_modules/eslint/bin/eslint.js ./src",
"flow": "flow check",
"fmt": "LOG_LEVEL= prettier-eslint --write --no-semi --ignore 'flow/**/*.js' 'src/**/*.js'",
"fmt:check": "prettier-eslint --list-different --no-semi --ignore 'flow/**/*.js' 'src/**/*.js'"
},
"main": "src/index.js",
"repository": {
"type": "git",
"url": "github.com/mitodl/mdl-react-components"
},
"keywords": [
"mdl",
"material",
"react"
],
"author": "",
"license": "BSD-3-Clause",
"devDependencies": {
"ava": "^0.24.0",
"babel-eslint": "7.2.3",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-latest": "^6.24.1",
"babel-preset-react": "^6.24.1",
"codecov": "^3.0.0",
"enzyme": "^3.2.0",
"enzyme-adapter-react-15": "^1.0.5",
"eslint": "^4.12.1",
"eslint-config-google": "^0.9.1",
"eslint-config-mitodl": "^0.0.4",
"eslint-plugin-ava": "^4.4.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-flow-vars": "^0.5.0",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-react": "^7.5.1",
"flow-bin": "^0.60.1",
"flow-typed": "^2.2.3",
"jsdom": "11.5.1",
"jsdom-global": "3.0.2",
"nyc": "^11.3.0",
"prettier-eslint-cli": "^4.4.2",
"react": "^15.6.0",
"react-dom": "^15.6.0",
"react-test-renderer": "^15.6.0"
},
"peerDependencies": {
"react": "^15.6.0",
"react-dom": "^15.6.0"
},
"ava": {
"concurrency": 2,
"files": "src/**/*_test.js",
"require": [
"babel-register",
"babel-polyfill",
"jsdom-global/register"
],
"babel": "inherit"
},
"babel": {
"presets": [
[
"env",
{
"modules": false
}
],
"latest",
"react"
],
"ignore": [
"node_modules/**"
],
"plugins": [
"transform-flow-strip-types",
"transform-object-rest-spread",
"transform-class-properties",
"syntax-dynamic-import",
"./scripts/test/configure.js"
]
},
"dependencies": {
"@material/dialog": "^0.26.0"
}
}
4 changes: 4 additions & 0 deletions scripts/test/configure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const Enzyme = require("enzyme")
const Adapter = require("enzyme-adapter-react-15")

Enzyme.configure({ adapter: new Adapter() })
Loading

0 comments on commit f04f157

Please sign in to comment.