Skip to content

Commit

Permalink
lint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyou2012 committed Dec 2, 2016
1 parent 5d34865 commit 0d430f6
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 10 deletions.
12 changes: 6 additions & 6 deletions examples/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ htmlTo(`
<td colspan="2">world</td>
</tr>
<tr>
<td rowspan="2">adsfasdfasd</td>
<td>adsfasdfasd</td>
<td>adsfasdfasd</td>
<td>adsfasdfasd</td>
<td rowspan="2">foo</td>
<td>bar</td>
<td>ok</td>
<td>haha</td>
</tr>
<tr>
<td colspan="3">fadsasdf</td>
<td colspan="1">fadsasdf</td>
<td colspan="3">foo foo</td>
<td colspan="1">bar bar</td>
</tr>
</table>
`, (err, file) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"homepage": "https://github.com/d-band/html2xlsx#readme",
"dependencies": {
"better-xlsx": "^0.0.3",
"better-xlsx": "^0.1.0",
"cheerio": "^0.22.0",
"cssstyle": "^0.2.37",
"juice": "^4.0.2",
Expand Down
Binary file added test/expect/complex.xlsx
Binary file not shown.
Binary file added test/expect/merge.xlsx
Binary file not shown.
Binary file added test/expect/simple.xlsx
Binary file not shown.
288 changes: 285 additions & 3 deletions test/index.test.js

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions test/lib.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

import { expect } from 'chai';
import { color2argb, size2pt, css2style, getBorder } from '../src/lib';

describe('Test: lib.js', () => {
it('should color2argb ok', () => {
expect(color2argb('red')).to.equal('ffff0000');
expect(color2argb('#fff')).to.equal('ffffffff');
expect(color2argb('rgba (255, 0, 0, .5)')).to.equal('80ff0000');
});

it('should size2pt ok', () => {
expect(size2pt('12pt')).to.equal(12);
expect(size2pt('1em')).to.equal(12);
expect(size2pt('16px')).to.equal(12);
expect(size2pt('100%')).to.equal(12);
expect(size2pt('')).to.equal(12);
expect(size2pt('wrong')).to.equal(12);
});

it('should css2style ok', () => {
const css = css2style({
border: '1px solid #333'
});
expect(css.borderWidth).to.equal('1px');
expect(css['border-left-style']).to.equal('solid');
expect(css['border-right-color']).to.equal('#333');
});

it('should getBorder ok', () => {
const css1 = css2style({
borderLeft: '1px solid #333'
});
expect(getBorder(css1, 'left')).to.deep.equal({ style: 'thin', color: 'ff333333' });

const css2 = css2style({
borderLeft: '3px dashed #333'
});
expect(getBorder(css2, 'left')).to.deep.equal({ style: 'dashed', color: 'ff333333' });

const css3 = css2style({
borderLeft: '3px solid #333'
});
expect(getBorder(css3, 'left')).to.deep.equal({ style: 'medium', color: 'ff333333' });

const css4 = css2style({
borderLeft: '5px solid #333'
});
expect(getBorder(css4, 'left')).to.deep.equal({ style: 'thick', color: 'ff333333' });

const css5 = css2style({
borderLeft: '0px solid #333'
});
expect(getBorder(css5, 'left')).to.be.null;

const css6 = css2style({
borderLeft: '1px solid'
});
expect(getBorder(css6, 'left')).to.be.null;
});
});

0 comments on commit 0d430f6

Please sign in to comment.