Skip to content

Commit

Permalink
Add snapshot testing
Browse files Browse the repository at this point in the history
* Add snapshot testing

* Add TravisCI
  • Loading branch information
diegomura committed May 20, 2017
1 parent ccd618f commit fed54c2
Show file tree
Hide file tree
Showing 12 changed files with 1,090 additions and 148 deletions.
9 changes: 6 additions & 3 deletions .eslintrc
Expand Up @@ -11,15 +11,18 @@
},
"extends": [
"prettier",
"prettier/react"
"prettier/react",
"plugin:jest/recommended"
],
"plugins": [
"promise",
"react"
"react",
"jest"
],
"env": {
"es6": true,
"node": true
"node": true,
"jest/globals": true
},
"globals": {
"document": false,
Expand Down
16 changes: 16 additions & 0 deletions .travis.yml
@@ -0,0 +1,16 @@
language: node_js
node_js:
- '7'
- '6'

matrix:
fast_finish: true

cache:
yarn: true
directories:
- node_modules

install: yarn

script: yarn test
7 changes: 6 additions & 1 deletion README.md
@@ -1,4 +1,9 @@
<big><h1 align="center">react-pdf</h1></big>
<div align="center">
<big>
<h1>react-pdf</h1>
</big>
</div>


> React renderer for creating PDF files on the browser, mobile and server
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
@@ -0,0 +1,5 @@
module.exports = {
modulePathIgnorePatterns: ['/node_modules/'],
moduleDirectories: ['packages', 'node_modules'],
testRegex: '/packages/.*?(Spec)\\.js$',
};
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -9,7 +9,8 @@
"postinstall": "lerna bootstrap",
"example": "babel-node ./examples/index.js",
"precommit": "lint-staged",
"lint": "eslint performance src --ignore-path .gitignore"
"lint": "eslint performance src --ignore-path .gitignore",
"test": "jest --config .jestrc"
},
"lint-staged": {
"*.js": [
Expand All @@ -29,12 +30,14 @@
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"eslint": "^3.19.0",
"eslint-config-prettier": "^2.1.0",
"eslint-plugin-jest": "^20.0.3",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.0.1",
"husky": "^0.13.2",
Expand All @@ -43,6 +46,7 @@
},
"dependencies": {
"fbjs": "^0.8.12",
"jest": "^20.0.3",
"lerna": "^2.0.0-rc.4",
"lodash.times": "^4.3.2"
},
Expand Down
305 changes: 305 additions & 0 deletions packages/react-pdf/specs/__snapshots__/pageSpec.js.snap
@@ -0,0 +1,305 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Page /> Should render A4 blank portrait page by default 1`] = `
"%PDF-1.7
%����
1 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
>>
endobj
2 0 obj
<<
/Type /Catalog
/Pages 6 0 R
>>
endobj
6 0 obj
<<
/Type /Pages
/Kids [3 0 R]
/Count 1
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 6 0 R
/Contents [7 0 R 5 0 R ]
/Resources 4 0 R
/MediaBox [0 0 595.280029296875 841.8900146484375]
>>
endobj
7 0 obj
<<
/Length 16
>>
stream
/DeviceRGB cs
endstream
endobj
5 0 obj
<<
/Length 31
>>
stream
1 0 0 -1 0 841.8900146484375 cm
endstream
endobj
4 0 obj
<<
/ProcSet [/PDF/Text]
/Font <</F1 1 0 R>>
>>
endobj
xref
0 6
0000000000 65535 f
0000000015 00000 n
0000000095 00000 n
0000000201 00000 n
0000000341 00000 n
0000000144 00000 n
trailer
<<
/Size 5
/Root 2 0 R
>>
startxref
403
%%EOF"
`;

exports[`<Page /> Should render given background color 1`] = `
"%PDF-1.7
%����
15 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
>>
endobj
16 0 obj
<<
/Type /Catalog
/Pages 20 0 R
>>
endobj
20 0 obj
<<
/Type /Pages
/Kids [17 0 R]
/Count 1
>>
endobj
17 0 obj
<<
/Type /Page
/Parent 20 0 R
/Contents [21 0 R 19 0 R ]
/Resources 18 0 R
/MediaBox [0 0 595.280029296875 841.8900146484375]
>>
endobj
21 0 obj
<<
/Length 102
>>
stream
/DeviceRGB cs
1 0.38823529411764707 0.2784313725490196 scn
0 0 595.280029296875 841.8900146484375 re
f
endstream
endobj
19 0 obj
<<
/Length 31
>>
stream
1 0 0 -1 0 841.8900146484375 cm
endstream
endobj
18 0 obj
<<
/ProcSet [/PDF/Text]
/Font <</F1 15 0 R>>
>>
endobj
xref
0 6
0000000000 65535 f
0000000015 00000 n
0000000096 00000 n
0000000206 00000 n
0000000351 00000 n
0000000147 00000 n
trailer
<<
/Size 5
/Root 16 0 R
>>
startxref
415
%%EOF"
`;

exports[`<Page /> Should render given size 1`] = `
"%PDF-1.7
%����
8 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
>>
endobj
9 0 obj
<<
/Type /Catalog
/Pages 13 0 R
>>
endobj
13 0 obj
<<
/Type /Pages
/Kids [10 0 R]
/Count 1
>>
endobj
10 0 obj
<<
/Type /Page
/Parent 13 0 R
/Contents [14 0 R 12 0 R ]
/Resources 11 0 R
/MediaBox [0 0 2383.93994140625 3370.389892578125]
>>
endobj
14 0 obj
<<
/Length 16
>>
stream
/DeviceRGB cs
endstream
endobj
12 0 obj
<<
/Length 31
>>
stream
1 0 0 -1 0 3370.389892578125 cm
endstream
endobj
11 0 obj
<<
/ProcSet [/PDF/Text]
/Font <</F1 8 0 R>>
>>
endobj
xref
0 6
0000000000 65535 f
0000000015 00000 n
0000000095 00000 n
0000000204 00000 n
0000000349 00000 n
0000000145 00000 n
trailer
<<
/Size 5
/Root 9 0 R
>>
startxref
412
%%EOF"
`;

exports[`<Page /> Should render landscape page 1`] = `
"%PDF-1.7
%����
22 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
>>
endobj
23 0 obj
<<
/Type /Catalog
/Pages 27 0 R
>>
endobj
27 0 obj
<<
/Type /Pages
/Kids [24 0 R]
/Count 1
>>
endobj
24 0 obj
<<
/Type /Page
/Parent 27 0 R
/Contents [28 0 R 26 0 R ]
/Resources 25 0 R
/MediaBox [0 0 841.8900146484375 595.280029296875]
>>
endobj
28 0 obj
<<
/Length 16
>>
stream
/DeviceRGB cs
endstream
endobj
26 0 obj
<<
/Length 30
>>
stream
1 0 0 -1 0 595.280029296875 cm
endstream
endobj
25 0 obj
<<
/ProcSet [/PDF/Text]
/Font <</F1 22 0 R>>
>>
endobj
xref
0 6
0000000000 65535 f
0000000015 00000 n
0000000096 00000 n
0000000206 00000 n
0000000351 00000 n
0000000147 00000 n
trailer
<<
/Size 5
/Root 23 0 R
>>
startxref
415
%%EOF"
`;

0 comments on commit fed54c2

Please sign in to comment.