@microsoft/connected-workbooks 3.3.2-beta → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/constants.js +87 -49
- package/dist/utils/documentUtils.js +1 -1
- package/dist/utils/gridUtils.js +8 -8
- package/dist/utils/mashupDocumentParser.js +1 -1
- package/dist/utils/pqUtils.js +3 -3
- package/dist/utils/tableUtils.js +11 -4
- package/dist/utils/xmlInnerPartsUtils.js +245 -13
- package/dist/utils/xmlPartsUtils.js +74 -4
- package/dist/workbookManager.js +3 -3
- package/package.json +7 -3
- package/dist/src/generators.js +0 -15
- package/dist/src/types.js +0 -28
- package/dist/src/utils/arrayUtils.js +0 -51
- package/dist/src/utils/constants.js +0 -175
- package/dist/src/utils/documentUtils.js +0 -167
- package/dist/src/utils/gridUtils.js +0 -103
- package/dist/src/utils/htmlUtils.js +0 -19
- package/dist/src/utils/index.js +0 -24
- package/dist/src/utils/mashupDocumentParser.js +0 -188
- package/dist/src/utils/pqUtils.js +0 -194
- package/dist/src/utils/tableUtils.js +0 -233
- package/dist/src/utils/xmlInnerPartsUtils.js +0 -431
- package/dist/src/utils/xmlPartsUtils.js +0 -178
- package/dist/src/workbookTemplate.js +0 -9
- package/dist/tests/arrayUtils.test.js +0 -66
- package/dist/tests/documentUtils.test.js +0 -70
- package/dist/tests/gridUtils.test.js +0 -214
- package/dist/tests/htmlUtils.test.js +0 -111
- package/dist/tests/mashupDocumentParser.test.js +0 -113
- package/dist/tests/mocks/PqMock.js +0 -7
- package/dist/tests/mocks/index.js +0 -24
- package/dist/tests/mocks/section1mSimpleQueryMock.js +0 -8
- package/dist/tests/mocks/xmlMocks.js +0 -14
- package/dist/tests/tableUtils.test.js +0 -70
- package/dist/tests/workbookQueryTemplate.test.js +0 -218
- package/dist/tests/workbookTableTemplate.test.js +0 -126
- package/dist/tests/xmlInnerPartsUtils.test.js +0 -273
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
-
function step(op) {
|
|
18
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
-
switch (op[0]) {
|
|
23
|
-
case 0: case 1: t = op; break;
|
|
24
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
-
default:
|
|
28
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
-
if (t[2]) _.ops.pop();
|
|
33
|
-
_.trys.pop(); continue;
|
|
34
|
-
}
|
|
35
|
-
op = body.call(thisArg, _);
|
|
36
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
var workbookTemplate_1 = require("../src/workbookTemplate");
|
|
45
|
-
var utils_1 = require("../src/utils");
|
|
46
|
-
var constants_1 = require("../src/utils/constants");
|
|
47
|
-
var jszip_1 = __importDefault(require("jszip"));
|
|
48
|
-
var globals_1 = require("@jest/globals");
|
|
49
|
-
var getZip = function (template) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
return __generator(this, function (_a) {
|
|
51
|
-
switch (_a.label) {
|
|
52
|
-
case 0: return [4 /*yield*/, jszip_1.default.loadAsync(template, {
|
|
53
|
-
base64: true,
|
|
54
|
-
})];
|
|
55
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}); };
|
|
59
|
-
(0, globals_1.describe)("Single blank table template tests", function () {
|
|
60
|
-
var simpleTableDefaultTemplate = workbookTemplate_1.SIMPLE_BLANK_TABLE_TEMPLATE;
|
|
61
|
-
var defaultZipFile;
|
|
62
|
-
(0, globals_1.beforeAll)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, getZip(simpleTableDefaultTemplate)];
|
|
69
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
70
|
-
}
|
|
71
|
-
}); }); }).not.toThrow();
|
|
72
|
-
return [4 /*yield*/, getZip(simpleTableDefaultTemplate)];
|
|
73
|
-
case 1:
|
|
74
|
-
defaultZipFile = _a.sent();
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}); });
|
|
79
|
-
(0, globals_1.test)("Default template is a valid zip file", function () {
|
|
80
|
-
(0, globals_1.expect)(defaultZipFile).toBeTruthy();
|
|
81
|
-
});
|
|
82
|
-
(0, globals_1.test)("DataMashup XML doesn't exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var error_1;
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
_a.trys.push([0, 2, , 3]);
|
|
88
|
-
return [4 /*yield*/, utils_1.pqUtils.getDataMashupFile(defaultZipFile)];
|
|
89
|
-
case 1:
|
|
90
|
-
_a.sent();
|
|
91
|
-
return [3 /*break*/, 3];
|
|
92
|
-
case 2:
|
|
93
|
-
error_1 = _a.sent();
|
|
94
|
-
(0, globals_1.expect)(error_1).toBeTruthy();
|
|
95
|
-
return [3 /*break*/, 3];
|
|
96
|
-
case 3: return [2 /*return*/];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}); });
|
|
100
|
-
(0, globals_1.test)("A single blank table exists", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
|
-
var tableXml;
|
|
102
|
-
var _a;
|
|
103
|
-
return __generator(this, function (_b) {
|
|
104
|
-
switch (_b.label) {
|
|
105
|
-
case 0: return [4 /*yield*/, ((_a = defaultZipFile.file(constants_1.tableXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
106
|
-
case 1:
|
|
107
|
-
tableXml = _b.sent();
|
|
108
|
-
(0, globals_1.expect)(tableXml).toContain('name="Table1" displayName="Table1" ref="A1:A2"');
|
|
109
|
-
return [2 /*return*/];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}); });
|
|
113
|
-
(0, globals_1.test)("Does not contains query table", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
-
var queryTableXml;
|
|
115
|
-
var _a;
|
|
116
|
-
return __generator(this, function (_b) {
|
|
117
|
-
switch (_b.label) {
|
|
118
|
-
case 0: return [4 /*yield*/, ((_a = defaultZipFile.file(constants_1.queryTableXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
119
|
-
case 1:
|
|
120
|
-
queryTableXml = _b.sent();
|
|
121
|
-
(0, globals_1.expect)(queryTableXml).toBeFalsy();
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}); });
|
|
126
|
-
});
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
-
function step(op) {
|
|
18
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
-
switch (op[0]) {
|
|
23
|
-
case 0: case 1: t = op; break;
|
|
24
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
-
default:
|
|
28
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
-
if (t[2]) _.ops.pop();
|
|
33
|
-
_.trys.pop(); continue;
|
|
34
|
-
}
|
|
35
|
-
op = body.call(thisArg, _);
|
|
36
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
var mocks_1 = require("./mocks");
|
|
45
|
-
var utils_1 = require("../src/utils");
|
|
46
|
-
var globals_1 = require("@jest/globals");
|
|
47
|
-
var jszip_1 = __importDefault(require("jszip"));
|
|
48
|
-
var workbookTemplate_1 = require("../src/workbookTemplate");
|
|
49
|
-
(0, globals_1.describe)("Workbook Manager tests", function () {
|
|
50
|
-
var mockConnectionString = "<connections xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\" mc:Ignorable=\"xr16\">\n <connection id=\"1\" xr16:uid=\"{86BA784C-6640-4989-A85E-EB4966B9E741}\" keepAlive=\"1\" name=\"Query - Query1\" description=\"Connection to the 'Query1' query in the workbook.\" type=\"5\" refreshedVersion=\"7\" background=\"1\" saveData=\"1\">\n <dbPr connection=\"Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Query1;\" command=\"SELECT * FROM [Query1]\"/></connection></connections>";
|
|
51
|
-
(0, globals_1.test)("Connection XML attributes contain new query name", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
-
var connectionXmlFileString;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateConnections(mockConnectionString, "newQueryName", true)];
|
|
56
|
-
case 1:
|
|
57
|
-
connectionXmlFileString = (_a.sent()).connectionXmlFileString;
|
|
58
|
-
(0, globals_1.expect)(connectionXmlFileString.replace(/ /g, "")).toContain('command="SELECT * FROM [newQueryName]'.replace(/ /g, ""));
|
|
59
|
-
(0, globals_1.expect)(connectionXmlFileString.replace(/ /g, "")).toContain('name="Query - newQueryName"'.replace(/ /g, ""));
|
|
60
|
-
(0, globals_1.expect)(connectionXmlFileString.replace(/ /g, "")).toContain("description=\"Connection to the 'newQueryName' query in the workbook.\"".replace(/ /g, ""));
|
|
61
|
-
return [2 /*return*/];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}); });
|
|
65
|
-
(0, globals_1.test)("Connection XML attributes contain refreshOnLoad value", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var connectionXmlFileString;
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
switch (_a.label) {
|
|
69
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateConnections(mockConnectionString, "newQueryName", true)];
|
|
70
|
-
case 1:
|
|
71
|
-
connectionXmlFileString = (_a.sent()).connectionXmlFileString;
|
|
72
|
-
(0, globals_1.expect)(connectionXmlFileString.replace(/ /g, "")).toContain('refreshOnLoad="1"');
|
|
73
|
-
return [2 /*return*/];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
77
|
-
(0, globals_1.test)("SharedStrings XML contains new query name", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var newSharedStrings;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateSharedStrings('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>Query1</t></si><si><t/></si></sst>', "newQueryName")];
|
|
82
|
-
case 1:
|
|
83
|
-
newSharedStrings = (_a.sent()).newSharedStrings;
|
|
84
|
-
(0, globals_1.expect)(newSharedStrings.replace(/ /g, "")).toContain(mocks_1.sharedStringsXmlMock.replace(/ /g, ""));
|
|
85
|
-
return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}); });
|
|
89
|
-
(0, globals_1.test)("Tests SharedStrings update when XML contains query name", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
-
var newSharedStrings;
|
|
91
|
-
return __generator(this, function (_a) {
|
|
92
|
-
switch (_a.label) {
|
|
93
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateSharedStrings('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>newQueryName</t></si><si><t/></si></sst>', "newQueryName")];
|
|
94
|
-
case 1:
|
|
95
|
-
newSharedStrings = (_a.sent()).newSharedStrings;
|
|
96
|
-
(0, globals_1.expect)(newSharedStrings.replace(/ /g, "")).toContain(mocks_1.existingSharedStringsXmlMock.replace(/ /g, ""));
|
|
97
|
-
return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); });
|
|
101
|
-
(0, globals_1.test)("SharedStrings XML returns new index", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
-
var sharedStringIndex;
|
|
103
|
-
return __generator(this, function (_a) {
|
|
104
|
-
switch (_a.label) {
|
|
105
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateSharedStrings('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>Query1</t></si><si><t/></si></sst>', "newQueryName")];
|
|
106
|
-
case 1:
|
|
107
|
-
sharedStringIndex = (_a.sent()).sharedStringIndex;
|
|
108
|
-
(0, globals_1.expect)(sharedStringIndex).toEqual(2);
|
|
109
|
-
return [2 /*return*/];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}); });
|
|
113
|
-
(0, globals_1.test)("SharedStrings XML returns existing index", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
-
var sharedStringIndex;
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
switch (_a.label) {
|
|
117
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateSharedStrings('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>newQueryName</t></si><si><t/></si></sst>', "newQueryName")];
|
|
118
|
-
case 1:
|
|
119
|
-
sharedStringIndex = (_a.sent()).sharedStringIndex;
|
|
120
|
-
(0, globals_1.expect)(sharedStringIndex).toEqual(1);
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}); });
|
|
125
|
-
(0, globals_1.test)("Table XML contains refrshonload value", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
-
var _a, sharedStringIndex, newSharedStrings;
|
|
127
|
-
return __generator(this, function (_b) {
|
|
128
|
-
switch (_b.label) {
|
|
129
|
-
case 0: return [4 /*yield*/, utils_1.xmlInnerPartsUtils.updateSharedStrings('<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>Query1</t></si><si><t/></si></sst>', "newQueryName")];
|
|
130
|
-
case 1:
|
|
131
|
-
_a = _b.sent(), sharedStringIndex = _a.sharedStringIndex, newSharedStrings = _a.newSharedStrings;
|
|
132
|
-
(0, globals_1.expect)(sharedStringIndex).toEqual(2);
|
|
133
|
-
(0, globals_1.expect)(newSharedStrings.replace(/ /g, "")).toContain(mocks_1.sharedStringsXmlMock.replace(/ /g, ""));
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); });
|
|
138
|
-
(0, globals_1.test)("Table XML contains correct Table reference value with headers included", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
-
var singleTableDefaultTemplate, defaultZipFile, data, tableData, _a;
|
|
140
|
-
var _b;
|
|
141
|
-
return __generator(this, function (_c) {
|
|
142
|
-
switch (_c.label) {
|
|
143
|
-
case 0:
|
|
144
|
-
singleTableDefaultTemplate = workbookTemplate_1.SIMPLE_BLANK_TABLE_TEMPLATE;
|
|
145
|
-
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, jszip_1.default.loadAsync(singleTableDefaultTemplate, {
|
|
149
|
-
base64: true,
|
|
150
|
-
})];
|
|
151
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}); }).not.toThrow();
|
|
155
|
-
return [4 /*yield*/, jszip_1.default.loadAsync(singleTableDefaultTemplate, {
|
|
156
|
-
base64: true,
|
|
157
|
-
})];
|
|
158
|
-
case 1:
|
|
159
|
-
defaultZipFile = _c.sent();
|
|
160
|
-
data = [
|
|
161
|
-
["ID", "Name", "Income", "Gross", "Bonus"],
|
|
162
|
-
[123, "Alan C", 155000, 155000, 0.15],
|
|
163
|
-
[331, "Tim C", 65000, 13000, 0.12],
|
|
164
|
-
[222, "Bill G", 29501, 8850.3, 0.18],
|
|
165
|
-
[5582, "Mitch M", 87960, 17592, 0.15],
|
|
166
|
-
[43, "Dan F", 197296, 19729.6, 0.22],
|
|
167
|
-
[22, "Perry T-P", 186006, 37201.2, 0.4],
|
|
168
|
-
[335, "Mdrake", 197136, 78854.4, 0.1],
|
|
169
|
-
[6590, "Dr P", 139636, 41890.8, 0.13],
|
|
170
|
-
];
|
|
171
|
-
tableData = utils_1.gridUtils.parseToTableData({ data: data, config: { promoteHeaders: true, adjustColumnNames: true } });
|
|
172
|
-
return [4 /*yield*/, utils_1.xmlPartsUtils.updateWorkbookDataAndConfigurations(defaultZipFile, undefined, tableData)];
|
|
173
|
-
case 2:
|
|
174
|
-
_c.sent();
|
|
175
|
-
_a = globals_1.expect;
|
|
176
|
-
return [4 /*yield*/, ((_b = defaultZipFile.file("xl/tables/table1.xml")) === null || _b === void 0 ? void 0 : _b.async("text"))];
|
|
177
|
-
case 3:
|
|
178
|
-
_a.apply(void 0, [_c.sent()]).toContain("A1:E9");
|
|
179
|
-
return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}); });
|
|
183
|
-
(0, globals_1.test)("Table XML contains correct Table reference value without headers included", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
-
var singleTableDefaultTemplate, defaultZipFile, data, tableData, _a;
|
|
185
|
-
var _b;
|
|
186
|
-
return __generator(this, function (_c) {
|
|
187
|
-
switch (_c.label) {
|
|
188
|
-
case 0:
|
|
189
|
-
singleTableDefaultTemplate = workbookTemplate_1.SIMPLE_BLANK_TABLE_TEMPLATE;
|
|
190
|
-
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
191
|
-
return __generator(this, function (_a) {
|
|
192
|
-
switch (_a.label) {
|
|
193
|
-
case 0: return [4 /*yield*/, jszip_1.default.loadAsync(singleTableDefaultTemplate, {
|
|
194
|
-
base64: true,
|
|
195
|
-
})];
|
|
196
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}); }).not.toThrow();
|
|
200
|
-
return [4 /*yield*/, jszip_1.default.loadAsync(singleTableDefaultTemplate, {
|
|
201
|
-
base64: true,
|
|
202
|
-
})];
|
|
203
|
-
case 1:
|
|
204
|
-
defaultZipFile = _c.sent();
|
|
205
|
-
data = [
|
|
206
|
-
["ID", "Name", "Income", "Gross", "Bonus"],
|
|
207
|
-
[123, "Alan C", 155000, 155000, 0.15],
|
|
208
|
-
[331, "Tim C", 65000, 13000, 0.12],
|
|
209
|
-
[222, "Bill G", 29501, 8850.3, 0.18],
|
|
210
|
-
[5582, "Mitch M", 87960, 17592, 0.15],
|
|
211
|
-
[43, "Dan F", 197296, 19729.6, 0.22],
|
|
212
|
-
[22, "Perry T-P", 186006, 37201.2, 0.4],
|
|
213
|
-
[335, "Mdrake", 197136, 78854.4, 0.1],
|
|
214
|
-
[6590, "Dr P", 139636, 41890.8, 0.13],
|
|
215
|
-
];
|
|
216
|
-
tableData = utils_1.gridUtils.parseToTableData({ data: data, config: { promoteHeaders: false, adjustColumnNames: true } });
|
|
217
|
-
return [4 /*yield*/, utils_1.xmlPartsUtils.updateWorkbookDataAndConfigurations(defaultZipFile, undefined, tableData)];
|
|
218
|
-
case 2:
|
|
219
|
-
_c.sent();
|
|
220
|
-
_a = globals_1.expect;
|
|
221
|
-
return [4 /*yield*/, ((_b = defaultZipFile.file("xl/tables/table1.xml")) === null || _b === void 0 ? void 0 : _b.async("text"))];
|
|
222
|
-
case 3:
|
|
223
|
-
_a.apply(void 0, [_c.sent()]).toContain("A1:E10");
|
|
224
|
-
return [2 /*return*/];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
}); });
|
|
228
|
-
(0, globals_1.test)("Table XML contains correct Table reference value using template", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
229
|
-
var movedTableDefaultTemplate, templateMovedZipFile, data, tableData, _a;
|
|
230
|
-
var _b;
|
|
231
|
-
return __generator(this, function (_c) {
|
|
232
|
-
switch (_c.label) {
|
|
233
|
-
case 0:
|
|
234
|
-
movedTableDefaultTemplate = workbookTemplate_1.WORKBOOK_TEMPLATE_MOVED_TABLE;
|
|
235
|
-
(0, globals_1.expect)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
236
|
-
return __generator(this, function (_a) {
|
|
237
|
-
switch (_a.label) {
|
|
238
|
-
case 0: return [4 /*yield*/, jszip_1.default.loadAsync(movedTableDefaultTemplate, {
|
|
239
|
-
base64: true,
|
|
240
|
-
})];
|
|
241
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}); }).not.toThrow();
|
|
245
|
-
return [4 /*yield*/, jszip_1.default.loadAsync(movedTableDefaultTemplate, {
|
|
246
|
-
base64: true,
|
|
247
|
-
})];
|
|
248
|
-
case 1:
|
|
249
|
-
templateMovedZipFile = _c.sent();
|
|
250
|
-
data = [
|
|
251
|
-
["ID", "Name", "Income", "Gross", "Bonus"],
|
|
252
|
-
[123, "Alan C", 155000, 155000, 0.15],
|
|
253
|
-
[331, "Tim C", 65000, 13000, 0.12],
|
|
254
|
-
[222, "Bill G", 29501, 8850.3, 0.18],
|
|
255
|
-
[5582, "Mitch M", 87960, 17592, 0.15],
|
|
256
|
-
[43, "Dan F", 197296, 19729.6, 0.22],
|
|
257
|
-
[22, "Perry T-P", 186006, 37201.2, 0.4],
|
|
258
|
-
[335, "Mdrake", 197136, 78854.4, 0.1],
|
|
259
|
-
[6590, "Dr P", 139636, 41890.8, 0.13],
|
|
260
|
-
];
|
|
261
|
-
tableData = utils_1.gridUtils.parseToTableData({ data: data, config: { promoteHeaders: true, adjustColumnNames: true } });
|
|
262
|
-
return [4 /*yield*/, utils_1.xmlPartsUtils.updateWorkbookDataAndConfigurations(templateMovedZipFile, { templateFile: templateMovedZipFile }, tableData)];
|
|
263
|
-
case 2:
|
|
264
|
-
_c.sent();
|
|
265
|
-
_a = globals_1.expect;
|
|
266
|
-
return [4 /*yield*/, ((_b = templateMovedZipFile.file("xl/tables/table1.xml")) === null || _b === void 0 ? void 0 : _b.async("text"))];
|
|
267
|
-
case 3:
|
|
268
|
-
_a.apply(void 0, [_c.sent()]).toContain("B2:F10");
|
|
269
|
-
return [2 /*return*/];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}); });
|
|
273
|
-
});
|