diff --git a/.gitignore b/.gitignore
index 5b048cd..0bea6d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,7 @@
/.idea
/coverage/
/.nyc_output/
-/.idea/
\ No newline at end of file
+/.idea/
+
+test-output.xlsx
+~$*.xlsx
\ No newline at end of file
diff --git a/README.md b/README.md
index c45a579..7b6b2ed 100644
--- a/README.md
+++ b/README.md
@@ -42,10 +42,10 @@ const viewModel = new MyAwesomeReportVm(); //or something else
|----------|-----:|-------|--------|-------------|:---------|
| - | [BaseCell](./src/cell/BaseCell.ts) | n/o | n/o | All Cell\`s definition classes extend it. | **abstract** |
| Content | [NormalCell](./src/cell/NormalCell.ts) | 1 | not started by `##` or `#!` | This one copy all styles, width, properties and value form template. | **default** |
-| Content | [VariableCell](./src/cell/VariableCell.ts) | 3 | `## pathToVariable ` | Write variable from `ViewModel`.
Paths to object's property or array item are allowed. | **Examples:**
`simplePath`
`someObject.property`
`array.0.field`
`items.1.path.to.object.prop`|
+| Content | [VariableCell](./src/cell/VariableCell.ts) | 3 | `## pathToVariable ` | Write variable from `ViewModel`.
Paths to object's property or array item are allowed.
When asking about undefined variable it returns empty string. | **Paths examples:**
`simplePath`
`someObject.property`
`array.0.field`
`items.1.path.to.object.prop`|
| Content | **TODO: describe it!** [HyperlinkCell](./src/cell/HyperlinkCell.ts) | | | | |
| Content | **TODO: describe it!** [FormulaCell](./src/cell/FormulaCell.ts) | | | | |
-| Navigation | **TODO: describe it!** [EndRowCell](./src/cell/EndRowCell.ts) | | | | |
+| Navigation | [EndRowCell](./src/cell/EndRowCell.ts) | 2 | `#! END_ROW` | Go to the beginning of next row | |
| Worksheet
Navigation
Loop | [FinishCell](./src/cell/FinishCell.ts) | 7 | `#! FINISH conditionPath` | Finish rendering for current worksheet and:
1) go to next worksheet if `conditionPath===true`
2) repeat this template worksheet again (`conditionPath === false`) - looping through worksheets
3) finished whole rendering when this worksheet is the last one. | **Examples:**
`#! FINISHED ` or `#! FINISHED itemFromLoop.__iterated` |
| Worksheet | **TODO: describe it!** [WsNameCell](./src/cell/WsNameCell.ts) | | | | |
| View Model | **TODO: describe it!** [DeleteCell](./src/cell/DeleteCell.ts) | | | | |
diff --git a/tests/Renderer.test.ts b/tests/Renderer.test.ts
deleted file mode 100644
index 989c0dc..0000000
--- a/tests/Renderer.test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-// import * as chai from 'chai'
-//
-// import Index from '../src/Renderer'
-//
-// describe('sample"', function () {
-//
-// it('sample test"', async function () {
-// const index = new Index();
-//
-// chai.expect(index.DoSomething()).eql("do nothing");
-// });
-// });
\ No newline at end of file
diff --git a/tests/integration/Renderer.ts b/tests/integration/Renderer.test.ts
similarity index 85%
rename from tests/integration/Renderer.ts
rename to tests/integration/Renderer.test.ts
index c47a12c..aaad6d0 100644
--- a/tests/integration/Renderer.ts
+++ b/tests/integration/Renderer.test.ts
@@ -21,15 +21,16 @@ function assertCells(expected: Workbook, result: Workbook, factor: number = 10)
if (r === 1) {
- chai.expect(ws.e.getColumn(c).width).eql(ws.r.getColumn(c).width);
+ chai.expect(ws.r.getColumn(c).width).eql(ws.e.getColumn(c).width);
}
if (c === 1) {
- chai.expect(ws.e.getRow(r).height).eql(ws.r.getRow(r).height);
+ chai.expect(ws.r.getRow(r).height).eql(ws.e.getRow(r).height);
}
-
- chai.expect(cell.e.style).eql(cell.r.style);
- chai.expect(cell.e.text).eql(cell.r.text);
- chai.expect(cell.e.value).eql(cell.r.value);
+
+ // console.log(r,c);
+ chai.expect(cell.r.style).eql(cell.e.style);
+ chai.expect(cell.r.text).eql(cell.e.text);
+ chai.expect(cell.r.value).eql(cell.e.value);
}
}
}
@@ -57,11 +58,11 @@ describe('INTEGRATION:: Test xlsx renderer ', function () {
chai.expect(() => assertCells(expected, failedWorksheetAmount, 20)).throw("expected 2 to deeply equal 3");
chai.expect(() => assertCells(expected, failedWorksheetNames, 20)).throw('expected [ \'Sheet1\', \'Sheet2\' ] to deeply equal [ \'Sheet1\', \'Sheet3\' ]');
- chai.expect(() => assertCells(expected, failedWidth, 20)).throw("expected 13 to deeply equal 7.90625");
- chai.expect(() => assertCells(expected, failedHeight, 20)).throw("expected 15 to deeply equal 34.5");
+ chai.expect(() => assertCells(expected, failedWidth, 20)).throw("expected 7.90625 to deeply equal 13");
+ chai.expect(() => assertCells(expected, failedHeight, 20)).throw("expected 34.5 to deeply equal 15");
chai.expect(() => assertCells(expected, failedStyle, 20)).throw("expected { Object (font, border, ...) } to deeply equal { Object (font, border, ...) }");
- chai.expect(() => assertCells(expected, failedText, 20)).throw('expected \'sadasd\' to deeply equal \'sadas\'');
- chai.expect(() => assertCells(expected, failedValue, 20)).throw('expected { Object (formula, result) } to deeply equal \'asdasda\'');
+ chai.expect(() => assertCells(expected, failedText, 20)).throw('expected \'sadas\' to deeply equal \'sadasd\'');
+ chai.expect(() => assertCells(expected, failedValue, 20)).throw('expected \'asdasda\' to deeply equal { Object (formula, result) }');
chai.expect(() => assertCells(expected, failedTable, 20)).throw('expected { Object (font, border, ...) } to deeply equal { Object (font, border, ...) }');
});
});
@@ -82,6 +83,10 @@ describe('INTEGRATION:: Test xlsx renderer ', function () {
const expected = await new Workbook().xlsx.readFile(path.join(dataPath, s.name, "expected.xlsx"));
+ try{
+ await result.xlsx.writeFile(path.join(dataPath, s.name, 'test-output.xlsx'));
+ }catch(e){}
+
assertCells(expected, result);
});
diff --git a/tests/integration/data/Renderer001-EndRow/expected.xlsx b/tests/integration/data/Renderer001-EndRow/expected.xlsx
new file mode 100644
index 0000000..ee11fec
Binary files /dev/null and b/tests/integration/data/Renderer001-EndRow/expected.xlsx differ
diff --git a/tests/integration/data/Renderer001-EndRow/template.xlsx b/tests/integration/data/Renderer001-EndRow/template.xlsx
new file mode 100644
index 0000000..d97eeeb
Binary files /dev/null and b/tests/integration/data/Renderer001-EndRow/template.xlsx differ
diff --git a/tests/integration/data/Renderer001-EndRow/viewModel.json b/tests/integration/data/Renderer001-EndRow/viewModel.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/tests/integration/data/Renderer001-EndRow/viewModel.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/tests/integration/data/Renderer002-Variable/expected.xlsx b/tests/integration/data/Renderer002-Variable/expected.xlsx
new file mode 100644
index 0000000..3bd61c3
Binary files /dev/null and b/tests/integration/data/Renderer002-Variable/expected.xlsx differ
diff --git a/tests/integration/data/Renderer002-Variable/template.xlsx b/tests/integration/data/Renderer002-Variable/template.xlsx
new file mode 100644
index 0000000..5ca1d03
Binary files /dev/null and b/tests/integration/data/Renderer002-Variable/template.xlsx differ
diff --git a/tests/integration/data/Renderer002-Variable/viewModel.json b/tests/integration/data/Renderer002-Variable/viewModel.json
new file mode 100644
index 0000000..fb00ee4
--- /dev/null
+++ b/tests/integration/data/Renderer002-Variable/viewModel.json
@@ -0,0 +1,44 @@
+{
+ "firstName": "Paweł",
+ "secondName": "Siemienik",
+ "email": "siemienik.pawel@gmail.com",
+ "address": {
+ "streetName": "Al.. Siemienika",
+ "city": {
+ "name": "BB",
+ "province": {
+ "name": "Silesia",
+ "country": {
+ "name": "Poland"
+ }
+ }
+ }
+ },
+ "tags": [
+ "ziom",
+ "fullStack"
+ ],
+ "achievements": [
+ {
+ "name": "open source maintainer",
+ "description": "bla bla blaaa"
+ },
+ {
+ "name": "some Other",
+ "description": "some other bla bla"
+ }
+ ],
+ "friends": [
+ {
+ "firstName": "anyone"
+ },
+ {
+ "firstName": "my body",
+ "achievements": [
+ {
+ "name": "type scriper"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file