Skip to content

Commit

Permalink
Merge pull request #25 from dabapps/jest
Browse files Browse the repository at this point in the history
Jest
  • Loading branch information
JakeSidSmith authored May 15, 2017
2 parents f32c486 + a707976 commit 9a4265d
Show file tree
Hide file tree
Showing 36 changed files with 670 additions and 540 deletions.
4 changes: 0 additions & 4 deletions .mocha.opts

This file was deleted.

29 changes: 0 additions & 29 deletions .nycrc

This file was deleted.

38 changes: 26 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint-js": "tslint --project tsconfig.json --type-check '{src,tests,types,docs}/**/*.{ts,tsx}'",
"lint-less": "lesshint 'src/less/' 'docs/src/less/'",
"lint": "npm run lint-js && npm run lint-less",
"test": "npm run lint && ./scripts/test",
"tests": "jest",
"test": "npm run lint && npm run tests -- --coverage",
"postinstall": "./scripts/dist"
},
"repository": {
Expand All @@ -33,7 +34,6 @@
},
"homepage": "https://github.com/dabapps/roe#readme",
"dependencies": {
"@types/chai": "3.5.1",
"@types/classnames": "0.0.32",
"@types/highlight.js": "9.1.9",
"@types/random-seed": "0.3.2",
Expand All @@ -55,25 +55,18 @@
"typescript": "2.2.2"
},
"devDependencies": {
"@types/mocha": "2.2.41",
"@types/jest": "19.2.3",
"@types/node": "7.0.13",
"@types/react-test-renderer": "15.4.5",
"@types/sinon-chai": "2.7.27",
"brfs": "1.4.3",
"chai": "3.5.0",
"chai-jest-snapshot": "0.3.0",
"concurrently": "3.4.0",
"envify": "4.0.0",
"http-server": "0.9.0",
"jsdom": "10.1.0",
"jest": "20.0.1",
"lesshint": "3.3.1",
"livereload": "0.6.2",
"mocha": "3.3.0",
"nyc": "10.2.0",
"react-test-renderer": "15.5.4",
"sinon": "2.1.0",
"sinon-chai": "2.9.0",
"ts-node": "3.0.2",
"ts-jest": "20.0.3",
"tslint": "5.1.0",
"tslint-config-dabapps": "github:dabapps/tslint-config-dabapps#v0.2.0",
"watch-less-do-more": "0.2.0",
Expand All @@ -85,5 +78,26 @@
"react": ">= 15 < 16",
"react-dom": ">= 15 < 16",
"typescript": ">= 2 < 3"
},
"jest": {
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
},
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/tests/.*|\\.(test|spec))\\.(ts|tsx|js|jsx)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx"
],
"mapCoverage": true
}
}
1 change: 0 additions & 1 deletion scripts/dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
set -e

mkdir -p dist/js/
mkdir -p dist/css/

tsc --sourceMap --declaration --listFiles --project 'src/ts/tsconfig.json' --rootDir 'src/ts/' --outDir 'dist/js/' --module 'CommonJS'
12 changes: 0 additions & 12 deletions scripts/test

This file was deleted.

42 changes: 35 additions & 7 deletions src/ts/dab-ipsum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,24 @@ export const Ipsum: React.SFC<IIpsumProps> = (props) => {

switch (type) {
case 'li':
return <li>{ipsum}</li>;
return (
<li>
{ipsum}
</li>
);
case 'text':
return <span>{ipsum}</span>;
return (
<span>
{ipsum}
</span>
);
// case 'p': NOTE: this is the default, so a case for it is not needed
default:
return <p>{ipsum}</p>;
return (
<p>
{ipsum}
</p>
);
}
};

Expand All @@ -120,13 +133,28 @@ export class DabIpsum extends React.Component<IDabIpsumProps, void> {

switch (type) {
case 'ul':
return <ul>{items}</ul>;
return (
<ul>
{items}
</ul>
);
case 'ol':
return <ol>{items}</ol>;
return (
<ol>
{items}
</ol>
);
case 'text':
return <Ipsum type="text" />;
return (
<Ipsum type="text" />
);
// case 'p': NOTE: this is the default, so a case for it is not needed
default:
return <div>{items}</div>;
return (
<div>
{items}
</div>
);
}
}
}
4 changes: 2 additions & 2 deletions src/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"jsx": "react",
"target": "es5",
"typeRoots": [
"../node_modules/@types/",
"../types/"
"../../node_modules/@types/",
"../../types/"
]
}
}
8 changes: 6 additions & 2 deletions tests/alert.tsx.snap → tests/__snapshots__/alert.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Alert should match snapshot 1`] = `
<div
className="alert" />
className="alert"
/>
`;

exports[`Alert should take regular element attributes 1`] = `
<div
className="alert my-class" />
className="alert my-class"
/>
`;
17 changes: 12 additions & 5 deletions tests/button.tsx.snap → tests/__snapshots__/button.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button should match snapshot 1`] = `
<button
className="button" />
className="button"
/>
`;

exports[`Button should take an optional large prop 1`] = `
<button
className="button large" />
className="button large"
/>
`;

exports[`Button should take regular element attributes 1`] = `
<button
className="button my-class" />
className="button my-class"
/>
`;

exports[`Button should use a block prop (boolean) as a class name 1`] = `
<button
className="button block" />
className="button block"
/>
`;

exports[`Button should use a type prop as a class name 1`] = `
<button
className="button primary" />
className="button primary"
/>
`;
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CodeBlock should handle empty code snippets 1`] = `
<pre
className="language-javascript">
className="language-javascript"
>
</pre>
`;

exports[`CodeBlock should match snapshot 1`] = `
<pre
className="" />
className=""
/>
`;

exports[`CodeBlock should remove weird indentation from multi line snippets 1`] = `
<pre
className="">
<p>
className=""
>
&lt;p&gt;
Hello, World!
</p>
&lt;/p&gt;
</pre>
`;

exports[`CodeBlock should remove weird indentation from multi line snippets 2`] = `
<pre
className="">
<p>
className=""
>
&lt;p&gt;
Hello, World!
</p>
&lt;/p&gt;
</pre>
`;

exports[`CodeBlock should remove weird indentation from single line snippets 1`] = `
<pre
className="">
console.log(\'test\')
className=""
>
console.log('test')
</pre>
`;

exports[`CodeBlock should remove weird indentation from single line snippets 2`] = `
<pre
className="">
console.log(\'test\')
className=""
>
console.log('test')
</pre>
`;

exports[`CodeBlock should take an optional language prop 1`] = `
<pre
className="language-javascript" />
className="language-javascript"
/>
`;
Loading

0 comments on commit 9a4265d

Please sign in to comment.