bexio 0.7.2 → 3.0.1
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/Readme.md +20 -119
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +146 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/jest-html-reporters-attach/index.js +58 -0
- package/jest-html-reporters-attach/result.js +1 -0
- package/jest_html_reporters.html +1 -0
- package/junit.xml +155 -0
- package/lib/index.d.ts +9 -103
- package/lib/index.js +55 -237
- package/lib/index.js.map +1 -1
- package/lib/interfaces/BillsStatic.js +1 -0
- package/lib/interfaces/BillsStatic.js.map +1 -1
- package/lib/interfaces/BusinessActivitiesStatic.js +1 -0
- package/lib/interfaces/BusinessActivitiesStatic.js.map +1 -1
- package/lib/interfaces/CalendarStatic.js +1 -0
- package/lib/interfaces/CalendarStatic.js.map +1 -1
- package/lib/interfaces/ContactGroupsStatic.js +1 -0
- package/lib/interfaces/ContactGroupsStatic.js.map +1 -1
- package/lib/interfaces/ContactRelationsStatic.js +1 -0
- package/lib/interfaces/ContactRelationsStatic.js.map +1 -1
- package/lib/interfaces/ContactSectorsStatic.js +1 -0
- package/lib/interfaces/ContactSectorsStatic.js.map +1 -1
- package/lib/interfaces/ContactTypesStatic.js +1 -0
- package/lib/interfaces/ContactTypesStatic.js.map +1 -1
- package/lib/interfaces/ContactsStatic.js +1 -0
- package/lib/interfaces/ContactsStatic.js.map +1 -1
- package/lib/interfaces/ExpensesStatic.js +1 -0
- package/lib/interfaces/ExpensesStatic.js.map +1 -1
- package/lib/interfaces/InvoicesStatic.d.ts +100 -0
- package/lib/interfaces/InvoicesStatic.js +25 -0
- package/lib/interfaces/InvoicesStatic.js.map +1 -0
- package/lib/interfaces/ItemsStatic.d.ts +120 -0
- package/lib/interfaces/ItemsStatic.js +47 -0
- package/lib/interfaces/ItemsStatic.js.map +1 -0
- package/lib/interfaces/NotesStatic.js +1 -0
- package/lib/interfaces/NotesStatic.js.map +1 -1
- package/lib/interfaces/OrdersStatic.js +1 -0
- package/lib/interfaces/OrdersStatic.js.map +1 -1
- package/lib/interfaces/PositionStatic.d.ts +35 -0
- package/lib/interfaces/PositionStatic.js +3 -0
- package/lib/interfaces/PositionStatic.js.map +1 -0
- package/lib/interfaces/ProjectStatusesStatic.js +1 -0
- package/lib/interfaces/ProjectStatusesStatic.js.map +1 -1
- package/lib/interfaces/ProjectTypesStatic.js +1 -0
- package/lib/interfaces/ProjectTypesStatic.js.map +1 -1
- package/lib/interfaces/ProjectsStatic.js +1 -0
- package/lib/interfaces/ProjectsStatic.js.map +1 -1
- package/lib/interfaces/SalesOrderManagementStatic.js +1 -0
- package/lib/interfaces/SalesOrderManagementStatic.js.map +1 -1
- package/lib/interfaces/TimetrackingStatusesStatic.js +1 -0
- package/lib/interfaces/TimetrackingStatusesStatic.js.map +1 -1
- package/lib/interfaces/TimetrackingsStatic.js +1 -0
- package/lib/interfaces/TimetrackingsStatic.js.map +1 -1
- package/lib/interfaces/UsersStatic.js +1 -0
- package/lib/interfaces/UsersStatic.js.map +1 -1
- package/lib/resources/BaseCrud.d.ts +13 -24
- package/lib/resources/BaseCrud.js +37 -44
- package/lib/resources/BaseCrud.js.map +1 -1
- package/lib/resources/Bills.d.ts +5 -6
- package/lib/resources/Bills.js +14 -17
- package/lib/resources/Bills.js.map +1 -1
- package/lib/resources/BusinessActivities.d.ts +1 -2
- package/lib/resources/BusinessActivities.js +2 -3
- package/lib/resources/BusinessActivities.js.map +1 -1
- package/lib/resources/ContactGroups.d.ts +1 -2
- package/lib/resources/ContactGroups.js +3 -4
- package/lib/resources/ContactGroups.js.map +1 -1
- package/lib/resources/ContactRelations.d.ts +1 -2
- package/lib/resources/ContactRelations.js +2 -3
- package/lib/resources/ContactRelations.js.map +1 -1
- package/lib/resources/ContactSectors.d.ts +1 -2
- package/lib/resources/ContactSectors.js +6 -7
- package/lib/resources/ContactSectors.js.map +1 -1
- package/lib/resources/ContactTypes.d.ts +1 -2
- package/lib/resources/ContactTypes.js +6 -7
- package/lib/resources/ContactTypes.js.map +1 -1
- package/lib/resources/Contacts.d.ts +1 -2
- package/lib/resources/Contacts.js +2 -3
- package/lib/resources/Contacts.js.map +1 -1
- package/lib/resources/Expenses.d.ts +2 -3
- package/lib/resources/Expenses.js +4 -5
- package/lib/resources/Expenses.js.map +1 -1
- package/lib/resources/Invoices.d.ts +6 -0
- package/lib/resources/Invoices.js +27 -0
- package/lib/resources/Invoices.js.map +1 -0
- package/lib/resources/Items.d.ts +5 -0
- package/lib/resources/Items.js +13 -0
- package/lib/resources/Items.js.map +1 -0
- package/lib/resources/Orders.d.ts +1 -2
- package/lib/resources/Orders.js +2 -3
- package/lib/resources/Orders.js.map +1 -1
- package/lib/resources/Payments.d.ts +1 -2
- package/lib/resources/Payments.js +2 -11
- package/lib/resources/Payments.js.map +1 -1
- package/lib/resources/ProjectStatuses.d.ts +1 -2
- package/lib/resources/ProjectStatuses.js +2 -3
- package/lib/resources/ProjectStatuses.js.map +1 -1
- package/lib/resources/ProjectTypes.d.ts +1 -2
- package/lib/resources/ProjectTypes.js +6 -7
- package/lib/resources/ProjectTypes.js.map +1 -1
- package/lib/resources/Projects.d.ts +1 -2
- package/lib/resources/Projects.js +2 -3
- package/lib/resources/Projects.js.map +1 -1
- package/lib/resources/TimetrackingStatuses.d.ts +1 -2
- package/lib/resources/TimetrackingStatuses.js +2 -3
- package/lib/resources/TimetrackingStatuses.js.map +1 -1
- package/lib/resources/Timetrackings.d.ts +1 -2
- package/lib/resources/Timetrackings.js +2 -3
- package/lib/resources/Timetrackings.js.map +1 -1
- package/lib/resources/Users.d.ts +1 -2
- package/lib/resources/Users.js +2 -3
- package/lib/resources/Users.js.map +1 -1
- package/lib/tests/BaseCrud.test.js +290 -0
- package/lib/tests/BaseCrud.test.js.map +1 -0
- package/lib/tests/Bills.test.js +93 -143
- package/lib/tests/Bills.test.js.map +1 -1
- package/lib/tests/BusinessActivities.test.js +14 -85
- package/lib/tests/BusinessActivities.test.js.map +1 -1
- package/lib/tests/ContactGroups.test.js +14 -92
- package/lib/tests/ContactGroups.test.js.map +1 -1
- package/lib/tests/ContactRelations.test.js +14 -87
- package/lib/tests/ContactRelations.test.js.map +1 -1
- package/lib/tests/ContactSectors.test.js +14 -124
- package/lib/tests/ContactSectors.test.js.map +1 -1
- package/lib/tests/ContactTypes.test.js +14 -118
- package/lib/tests/ContactTypes.test.js.map +1 -1
- package/lib/tests/Contacts.test.js +23 -0
- package/lib/tests/Contacts.test.js.map +1 -0
- package/lib/tests/Expenses.test.js +14 -98
- package/lib/tests/Expenses.test.js.map +1 -1
- package/lib/tests/Invoices.test.d.ts +1 -0
- package/lib/tests/Invoices.test.js +23 -0
- package/lib/tests/Invoices.test.js.map +1 -0
- package/lib/tests/Items.test.d.ts +1 -0
- package/lib/tests/Items.test.js +23 -0
- package/lib/tests/Items.test.js.map +1 -0
- package/lib/tests/Orders.test.js +14 -127
- package/lib/tests/Orders.test.js.map +1 -1
- package/lib/tests/Payments.test.js +15 -90
- package/lib/tests/Payments.test.js.map +1 -1
- package/lib/tests/ProjectStatuses.test.js +14 -123
- package/lib/tests/ProjectStatuses.test.js.map +1 -1
- package/lib/tests/ProjectTypes.test.js +14 -119
- package/lib/tests/ProjectTypes.test.js.map +1 -1
- package/lib/tests/Projects.test.js +14 -91
- package/lib/tests/Projects.test.js.map +1 -1
- package/lib/tests/TimetrackingStatuses.test.js +14 -123
- package/lib/tests/TimetrackingStatuses.test.js.map +1 -1
- package/lib/tests/Timetrackings.test.js +14 -102
- package/lib/tests/Timetrackings.test.js.map +1 -1
- package/lib/tests/Users.test.js +14 -125
- package/lib/tests/Users.test.js.map +1 -1
- package/package.json +45 -29
- package/lib/constants/Scopes.d.ts +0 -32
- package/lib/constants/Scopes.js +0 -36
- package/lib/constants/Scopes.js.map +0 -1
- package/lib/libs/OAuth2.d.ts +0 -122
- package/lib/libs/OAuth2.js +0 -202
- package/lib/libs/OAuth2.js.map +0 -1
- package/lib/tests/Authentication.test.js +0 -83
- package/lib/tests/Authentication.test.js.map +0 -1
- package/lib/tests/Contact.test.js +0 -103
- package/lib/tests/Contact.test.js.map +0 -1
- /package/lib/tests/{Authentication.test.d.ts → BaseCrud.test.d.ts} +0 -0
- /package/lib/tests/{Contact.test.d.ts → Contacts.test.d.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseCrud_1 = __importDefault(require("../resources/BaseCrud"));
|
|
7
|
+
const utils_1 = require("ts-jest/utils");
|
|
8
|
+
const Invoices_1 = __importDefault(require("../resources/Invoices"));
|
|
9
|
+
const chance_1 = __importDefault(require("chance"));
|
|
10
|
+
jest.mock("../resources/BaseCrud");
|
|
11
|
+
const mockedBase = (0, utils_1.mocked)(BaseCrud_1.default, true);
|
|
12
|
+
const seedgenerator = new chance_1.default();
|
|
13
|
+
const seed = seedgenerator.hash();
|
|
14
|
+
console.log(`using chance seed ${seed}`);
|
|
15
|
+
const chance = new chance_1.default(seed);
|
|
16
|
+
describe("Invoices", () => {
|
|
17
|
+
it("Should use init the base correctly", () => {
|
|
18
|
+
const token = chance.string();
|
|
19
|
+
new Invoices_1.default(token);
|
|
20
|
+
expect(mockedBase).toHaveBeenCalledWith(token, "/kb_invoice");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=Invoices.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invoices.test.js","sourceRoot":"","sources":["../../src/tests/Invoices.test.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,yCAAuC;AACvC,qEAA6C;AAC7C,oDAA4B;AAE5B,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,kBAAQ,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,gBAAM,EAAE,CAAC;AACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,kBAAQ,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseCrud_1 = __importDefault(require("../resources/BaseCrud"));
|
|
7
|
+
const utils_1 = require("ts-jest/utils");
|
|
8
|
+
const chance_1 = __importDefault(require("chance"));
|
|
9
|
+
const Items_1 = __importDefault(require("../resources/Items"));
|
|
10
|
+
jest.mock("../resources/BaseCrud");
|
|
11
|
+
const mockedBase = (0, utils_1.mocked)(BaseCrud_1.default, true);
|
|
12
|
+
const seedgenerator = new chance_1.default();
|
|
13
|
+
const seed = seedgenerator.hash();
|
|
14
|
+
console.log(`using chance seed ${seed}`);
|
|
15
|
+
const chance = new chance_1.default(seed);
|
|
16
|
+
describe("Items", () => {
|
|
17
|
+
it("Should use init the base correctly", () => {
|
|
18
|
+
const token = chance.string();
|
|
19
|
+
new Items_1.default(token);
|
|
20
|
+
expect(mockedBase).toHaveBeenCalledWith(token, "/article");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=Items.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Items.test.js","sourceRoot":"","sources":["../../src/tests/Items.test.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,yCAAuC;AACvC,oDAA4B;AAC5B,+DAAuC;AAEvC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,kBAAQ,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,gBAAM,EAAE,CAAC;AACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,eAAK,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/tests/Orders.test.js
CHANGED
|
@@ -1,136 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
12
|
-
if (mod && mod.__esModule) return mod;
|
|
13
|
-
var result = {};
|
|
14
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
15
|
-
result["default"] = mod;
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const
|
|
23
|
-
const
|
|
6
|
+
const BaseCrud_1 = __importDefault(require("../resources/BaseCrud"));
|
|
7
|
+
const utils_1 = require("ts-jest/utils");
|
|
24
8
|
const Orders_1 = __importDefault(require("../resources/Orders"));
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
!BEXIO_CLIENTSECRET ||
|
|
38
|
-
!HOSTNAME ||
|
|
39
|
-
!BEXIO_USERNAME ||
|
|
40
|
-
!BEXIO_PASSWORD)
|
|
41
|
-
throw new Error("not all necessary variables defined");
|
|
42
|
-
api = new __1.default(BEXIO_CLIENTID, BEXIO_CLIENTSECRET, `http://${HOSTNAME}/callback`, [__1.Scopes.KB_ORDER_EDIT, __1.Scopes.KB_ORDER_SHOW]);
|
|
43
|
-
yield api.fakeLogin(BEXIO_USERNAME, BEXIO_PASSWORD);
|
|
44
|
-
}));
|
|
45
|
-
it("init Orders object", () => {
|
|
46
|
-
moduleToTest = new Orders_1.default(api["bexioAuth"]);
|
|
9
|
+
const chance_1 = __importDefault(require("chance"));
|
|
10
|
+
jest.mock("../resources/BaseCrud");
|
|
11
|
+
const mockedBase = (0, utils_1.mocked)(BaseCrud_1.default, true);
|
|
12
|
+
const seedgenerator = new chance_1.default();
|
|
13
|
+
const seed = seedgenerator.hash();
|
|
14
|
+
console.log(`using chance seed ${seed}`);
|
|
15
|
+
const chance = new chance_1.default(seed);
|
|
16
|
+
describe("Orders", () => {
|
|
17
|
+
it("Should use init the base correctly", () => {
|
|
18
|
+
const token = chance.string();
|
|
19
|
+
new Orders_1.default(token);
|
|
20
|
+
expect(mockedBase).toHaveBeenCalledWith(token, "/kb_order");
|
|
47
21
|
});
|
|
48
|
-
it("create new order", () => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
order = yield moduleToTest.create({
|
|
50
|
-
contact_id: 1,
|
|
51
|
-
user_id: 1,
|
|
52
|
-
logopaper_id: 1,
|
|
53
|
-
bank_account_id: 1,
|
|
54
|
-
currency_id: 1,
|
|
55
|
-
is_compact_view: false,
|
|
56
|
-
is_valid_from: Date.now(),
|
|
57
|
-
language_id: 1,
|
|
58
|
-
mwst_type: 2,
|
|
59
|
-
nb_decimals_amount: 99,
|
|
60
|
-
nb_decimals_price: 123,
|
|
61
|
-
payment_type_id: 1,
|
|
62
|
-
show_position_taxes: true,
|
|
63
|
-
positions: [
|
|
64
|
-
{
|
|
65
|
-
amount: "99",
|
|
66
|
-
unit_price: "1",
|
|
67
|
-
is_optional: false,
|
|
68
|
-
tax_id: 16,
|
|
69
|
-
text: "test",
|
|
70
|
-
type: "KbPositionCustom"
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
chai_1.expect(order.contact_id).to.be.eq(1);
|
|
75
|
-
}));
|
|
76
|
-
it("list Orders", () => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const list = yield moduleToTest.list({});
|
|
78
|
-
chai_1.expect(list.map(el => el.id)).includes(order.id);
|
|
79
|
-
}));
|
|
80
|
-
it("search order", () => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const searchResult = yield moduleToTest.search({}, [
|
|
82
|
-
{
|
|
83
|
-
field: OrdersStatic_1.OrdersStatic.OrderSearchParameters.id,
|
|
84
|
-
value: order.id,
|
|
85
|
-
criteria: "="
|
|
86
|
-
}
|
|
87
|
-
]);
|
|
88
|
-
chai_1.expect(searchResult.length).to.be.eq(1);
|
|
89
|
-
chai_1.expect(searchResult[0].id).to.be.eq(order.id);
|
|
90
|
-
}));
|
|
91
|
-
it("show order", () => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const show = yield moduleToTest.show({}, order.id);
|
|
93
|
-
chai_1.expect(show.id).to.be.eq(order.id);
|
|
94
|
-
}));
|
|
95
|
-
it("overwrite order", () => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const overwritten = yield moduleToTest.overwrite(order.id, {
|
|
97
|
-
contact_id: 2,
|
|
98
|
-
user_id: 1,
|
|
99
|
-
logopaper_id: 1,
|
|
100
|
-
bank_account_id: 1,
|
|
101
|
-
currency_id: 1,
|
|
102
|
-
is_compact_view: false,
|
|
103
|
-
is_valid_from: Date.now(),
|
|
104
|
-
language_id: 1,
|
|
105
|
-
mwst_type: 2,
|
|
106
|
-
nb_decimals_amount: 99,
|
|
107
|
-
nb_decimals_price: 123,
|
|
108
|
-
payment_type_id: 1,
|
|
109
|
-
show_position_taxes: true,
|
|
110
|
-
positions: [
|
|
111
|
-
{
|
|
112
|
-
amount: "99",
|
|
113
|
-
article_id: 1,
|
|
114
|
-
unit_price: "1",
|
|
115
|
-
is_optional: false,
|
|
116
|
-
tax_id: 16,
|
|
117
|
-
text: "test",
|
|
118
|
-
type: "KbPositionArticle"
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
});
|
|
122
|
-
chai_1.expect(overwritten.contact_id).to.be.eq(2);
|
|
123
|
-
}));
|
|
124
|
-
it("edit order", () => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
const edited = yield moduleToTest.edit(order.id, {
|
|
126
|
-
is_compact_view: true,
|
|
127
|
-
language_id: 2
|
|
128
|
-
});
|
|
129
|
-
chai_1.expect(edited.language_id).to.be.eq(2);
|
|
130
|
-
}));
|
|
131
|
-
it("delete order", () => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const result = yield moduleToTest.delete(order.id);
|
|
133
|
-
chai_1.expect(result).to.be.true;
|
|
134
|
-
}));
|
|
135
22
|
});
|
|
136
23
|
//# sourceMappingURL=Orders.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Orders.test.js","sourceRoot":"","sources":["../../src/tests/Orders.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Orders.test.js","sourceRoot":"","sources":["../../src/tests/Orders.test.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,yCAAuC;AACvC,iEAAyC;AACzC,oDAA4B;AAE5B,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,kBAAQ,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,gBAAM,EAAE,CAAC;AACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,gBAAM,CAAC,KAAK,CAAC,CAAC;QAClB,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,99 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
12
|
-
if (mod && mod.__esModule) return mod;
|
|
13
|
-
var result = {};
|
|
14
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
15
|
-
result["default"] = mod;
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
6
|
+
const BaseCrud_1 = __importDefault(require("../resources/BaseCrud"));
|
|
7
|
+
const utils_1 = require("ts-jest/utils");
|
|
25
8
|
const Payments_1 = __importDefault(require("../resources/Payments"));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
!BEXIO_USERNAME ||
|
|
40
|
-
!BEXIO_PASSWORD)
|
|
41
|
-
throw new Error("not all necessary variables defined");
|
|
42
|
-
api = new __1.default(BEXIO_CLIENTID, BEXIO_CLIENTSECRET, `http://${HOSTNAME}/callback`, [
|
|
43
|
-
__1.Scopes.KB_BILL_SHOW,
|
|
44
|
-
__1.Scopes.KB_INVOICE_SHOW,
|
|
45
|
-
__1.Scopes.KB_CREDIT_VOUCHER_SHOW,
|
|
46
|
-
__1.Scopes.KB_BILL_EDIT
|
|
47
|
-
]);
|
|
48
|
-
yield api.fakeLogin(BEXIO_USERNAME, BEXIO_PASSWORD);
|
|
49
|
-
}));
|
|
50
|
-
it("init payment object", () => {
|
|
51
|
-
moduleToTest = new Payments_1.default(api["bexioAuth"], billId);
|
|
9
|
+
const chance_1 = __importDefault(require("chance"));
|
|
10
|
+
jest.mock("../resources/BaseCrud");
|
|
11
|
+
const mockedBase = (0, utils_1.mocked)(BaseCrud_1.default, true);
|
|
12
|
+
const seedgenerator = new chance_1.default();
|
|
13
|
+
const seed = seedgenerator.hash();
|
|
14
|
+
console.log(`using chance seed ${seed}`);
|
|
15
|
+
const chance = new chance_1.default(seed);
|
|
16
|
+
describe("Payments", () => {
|
|
17
|
+
it("Should use init the base correctly", () => {
|
|
18
|
+
const token = chance.string();
|
|
19
|
+
const billId = chance.integer();
|
|
20
|
+
new Payments_1.default(token, billId);
|
|
21
|
+
expect(mockedBase).toHaveBeenCalledWith(token, `/kb_bill/${billId}/payment`);
|
|
52
22
|
});
|
|
53
|
-
it("create new payment", () => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
payment = yield moduleToTest.create({
|
|
55
|
-
date: "01-01-1970",
|
|
56
|
-
value: 50
|
|
57
|
-
});
|
|
58
|
-
}));
|
|
59
|
-
it("list payouts", () => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const list = yield moduleToTest.list({});
|
|
61
|
-
chai_1.expect(list.map(el => el.id)).includes(payment.id);
|
|
62
|
-
}));
|
|
63
|
-
it.skip("search payment", () => __awaiter(this, void 0, void 0, function* () { }));
|
|
64
|
-
it("should return a not implemented error on search", () => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
try {
|
|
66
|
-
const searchResult = yield moduleToTest.search({}, []);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
it("show payment", () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const showedPayment = yield moduleToTest.show({}, payment.id);
|
|
74
|
-
chai_1.expect(showedPayment.id).to.be.eq(payment.id);
|
|
75
|
-
}));
|
|
76
|
-
it.skip("overwrite payment", () => { });
|
|
77
|
-
it("should return a not implemented error on overwrite", () => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
const overwritten = yield moduleToTest.overwrite(payment.id, {});
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
83
|
-
}
|
|
84
|
-
}));
|
|
85
|
-
it.skip("edit payment", () => { });
|
|
86
|
-
it("should return a not implemented error on edit", () => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
try {
|
|
88
|
-
const overwritten = yield moduleToTest.edit(payment.id, {});
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
94
|
-
it("delete payment", () => __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const result = yield moduleToTest.delete(payment.id);
|
|
96
|
-
chai_1.expect(result).to.be.true;
|
|
97
|
-
}));
|
|
98
23
|
});
|
|
99
24
|
//# sourceMappingURL=Payments.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Payments.test.js","sourceRoot":"","sources":["../../src/tests/Payments.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Payments.test.js","sourceRoot":"","sources":["../../src/tests/Payments.test.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,yCAAuC;AACvC,qEAA6C;AAC7C,oDAA4B;AAE5B,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,kBAAQ,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,gBAAM,EAAE,CAAC;AACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,kBAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5B,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CACrC,KAAK,EACL,YAAY,MAAM,UAAU,CAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,132 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
12
|
-
if (mod && mod.__esModule) return mod;
|
|
13
|
-
var result = {};
|
|
14
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
15
|
-
result["default"] = mod;
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
25
|
-
const ProjectStatusesStatic_1 = require("../interfaces/ProjectStatusesStatic");
|
|
6
|
+
const BaseCrud_1 = __importDefault(require("../resources/BaseCrud"));
|
|
7
|
+
const utils_1 = require("ts-jest/utils");
|
|
26
8
|
const ProjectStatuses_1 = __importDefault(require("../resources/ProjectStatuses"));
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
!BEXIO_USERNAME ||
|
|
40
|
-
!BEXIO_PASSWORD)
|
|
41
|
-
throw new Error("not all necessary variables defined");
|
|
42
|
-
api = new __1.default(BEXIO_CLIENTID, BEXIO_CLIENTSECRET, `http://${HOSTNAME}/callback`, [__1.Scopes.PROJECT_EDIT, __1.Scopes.PROJECT_SHOW]);
|
|
43
|
-
yield api.fakeLogin(BEXIO_USERNAME, BEXIO_PASSWORD);
|
|
44
|
-
}));
|
|
45
|
-
it("init project", () => {
|
|
46
|
-
moduleToTest = new ProjectStatuses_1.default(api["bexioAuth"]);
|
|
9
|
+
const chance_1 = __importDefault(require("chance"));
|
|
10
|
+
jest.mock("../resources/BaseCrud");
|
|
11
|
+
const mockedBase = (0, utils_1.mocked)(BaseCrud_1.default, true);
|
|
12
|
+
const seedgenerator = new chance_1.default();
|
|
13
|
+
const seed = seedgenerator.hash();
|
|
14
|
+
console.log(`using chance seed ${seed}`);
|
|
15
|
+
const chance = new chance_1.default(seed);
|
|
16
|
+
describe("ProjectStatuses", () => {
|
|
17
|
+
it("Should use init the base correctly", () => {
|
|
18
|
+
const token = chance.string();
|
|
19
|
+
new ProjectStatuses_1.default(token);
|
|
20
|
+
expect(mockedBase).toHaveBeenCalledWith(token, `/pr_project_state`);
|
|
47
21
|
});
|
|
48
|
-
it.skip("create new project status (not implemented by Bexio yet)", () => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
projectStatusEntry = yield moduleToTest.create({
|
|
50
|
-
name: "test"
|
|
51
|
-
});
|
|
52
|
-
}));
|
|
53
|
-
it("should return a not implemented error on creation", () => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
projectStatusEntry = {
|
|
55
|
-
id: 1,
|
|
56
|
-
name: "Offen"
|
|
57
|
-
};
|
|
58
|
-
try {
|
|
59
|
-
yield moduleToTest.create({
|
|
60
|
-
name: "test"
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
65
|
-
}
|
|
66
|
-
}));
|
|
67
|
-
it("list project statuses", () => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const list = yield moduleToTest.list({});
|
|
69
|
-
chai_1.expect(list.map(el => el.id)).includes(projectStatusEntry.id);
|
|
70
|
-
}));
|
|
71
|
-
// search is currently broken on bexio side
|
|
72
|
-
it.skip("search project statuses", () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const searchResult = yield moduleToTest.search({}, [
|
|
74
|
-
{
|
|
75
|
-
field: ProjectStatusesStatic_1.ProjectStatusesStatic.ProjectStatusSearchParameters.text,
|
|
76
|
-
value: projectStatusEntry.name,
|
|
77
|
-
criteria: "="
|
|
78
|
-
}
|
|
79
|
-
]);
|
|
80
|
-
chai_1.expect(searchResult.length).to.be.greaterThan(0);
|
|
81
|
-
chai_1.expect(searchResult[0].id).to.be.eq(projectStatusEntry.id);
|
|
82
|
-
}));
|
|
83
|
-
it("show project statuses", () => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const showedEntry = yield moduleToTest.show({}, projectStatusEntry.id);
|
|
85
|
-
chai_1.expect(showedEntry.name).to.be.eq(projectStatusEntry.name);
|
|
86
|
-
}));
|
|
87
|
-
it.skip("overwrite a project status (not implemented by Bexio yet)", () => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const overwritten = yield moduleToTest.overwrite(projectStatusEntry.id, {
|
|
89
|
-
name: "test"
|
|
90
|
-
});
|
|
91
|
-
chai_1.expect(overwritten.name).to.be.eq("test");
|
|
92
|
-
}));
|
|
93
|
-
it("should return a not implemented error on overwrite", () => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
try {
|
|
95
|
-
yield moduleToTest.overwrite(projectStatusEntry.id, {
|
|
96
|
-
name: "test"
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
it.skip("edit project status (not implemented by Bexio yet)", () => __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const edited = yield moduleToTest.edit(projectStatusEntry.id, {
|
|
105
|
-
name: "test"
|
|
106
|
-
});
|
|
107
|
-
chai_1.expect(edited.name).to.be.eq("test");
|
|
108
|
-
}));
|
|
109
|
-
it("should return a not implemented error on edit", () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
try {
|
|
111
|
-
yield moduleToTest.edit(projectStatusEntry.id, {
|
|
112
|
-
name: "test"
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
117
|
-
}
|
|
118
|
-
}));
|
|
119
|
-
it.skip("delete project status (not implemented by Bexio yet)", () => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const result = yield moduleToTest.delete(projectStatusEntry.id);
|
|
121
|
-
chai_1.expect(result).to.be.true;
|
|
122
|
-
}));
|
|
123
|
-
it("should return a not implemented error on deletion", () => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
try {
|
|
125
|
-
yield moduleToTest.delete(projectStatusEntry.id);
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
chai_1.expect(err.message).to.be.eq("not implemented by Bexio yet");
|
|
129
|
-
}
|
|
130
|
-
}));
|
|
131
22
|
});
|
|
132
23
|
//# sourceMappingURL=ProjectStatuses.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectStatuses.test.js","sourceRoot":"","sources":["../../src/tests/ProjectStatuses.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProjectStatuses.test.js","sourceRoot":"","sources":["../../src/tests/ProjectStatuses.test.ts"],"names":[],"mappings":";;;;;AAAA,qEAA6C;AAC7C,yCAAuC;AACvC,mFAA2D;AAC3D,oDAA4B;AAE5B,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,kBAAQ,EAAE,IAAI,CAAC,CAAC;AAE1C,MAAM,aAAa,GAAG,IAAI,gBAAM,EAAE,CAAC;AACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;AACzC,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,yBAAe,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|