Skip to content

Commit 03985c2

Browse files
committed
Expand tests
1 parent 3eb473a commit 03985c2

4 files changed

Lines changed: 367 additions & 134 deletions

File tree

modules/triggerTestModule/resources/queries/exp.data/DataClassTest.js

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,93 @@
66
var shared = require("TriggerTestModule/EmployeeLib");
77
var console = require("console");
88

9+
function managedColumns() {
10+
return {
11+
insert: ["Country"],
12+
update: ["Country"],
13+
};
14+
}
15+
916
function init(event, errors) {
1017
console.log("init got triggered with event: " + event);
1118
console.log(shared.sampleFunc("this is from the shared function"));
1219
}
1320

1421
function beforeInsert(row, errors) {
1522
console.log("exp.data: beforeInsert: row is: " + row);
16-
if(row.Comments) {
17-
if (row.Comments == "Individual Test") {
18-
row.Country = "Inserting Single";
19-
row.Comments = "BeforeDelete"; //set this for next test step
20-
}
21-
else if (row.Comments == "Import Test")
22-
row.Country = "Importing TSV";
23-
else if (row.Comments == "API Test")
24-
row.Country = "API BeforeInsert";
23+
var name = row.Name || row.name;
24+
if (name === "Managed Insert") {
25+
row.Country = "MANAGED-INS";
26+
} else if (name === "Managed Struct") {
27+
row.Country = "MANAGED-STRUCT";
28+
row.undeclaredCol = "bad";
29+
} else if (name === "Managed Struct Remove") {
30+
row.Country = "MANAGED-STRUCT-REM";
31+
delete row.Comments;
32+
delete row.comments;
33+
}
34+
35+
if (name === "Managed Unhandled") {
36+
delete row.Country;
2537
} else {
26-
if (row.comments == "Individual Test") {
27-
row.country = "Inserting Single";
28-
row.comments = "BeforeDelete"; //set this for next test step
38+
if (row.Comments) {
39+
if (row.Comments === "Individual Test") {
40+
row.Country = "Inserting Single";
41+
row.Comments = "BeforeDelete"; //set this for next test step
42+
} else if (row.Comments === "Import Test") {
43+
row.Country = "Importing TSV";
44+
} else if (row.Comments === "API Test") {
45+
row.Country = "API BeforeInsert";
46+
}
47+
} else {
48+
if (row.comments === "Individual Test") {
49+
row.country = "Inserting Single";
50+
row.comments = "BeforeDelete"; //set this for next test step
51+
} else if (row.comments === "Import Test") {
52+
row.country = "Importing TSV";
53+
} else if (row.comments === "API Test") {
54+
row.country = "API BeforeInsert";
55+
}
2956
}
30-
else if (row.comments == "Import Test")
31-
row.country = "Importing TSV";
32-
else if (row.comments == "API Test")
33-
row.country = "API BeforeInsert";
57+
if (!row.Country)
58+
row.Country = "DC-DEFAULT";
3459
}
35-
3660
console.log("exp.data: edited row is: " + row);
3761
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
3862
}
3963

4064
function beforeUpdate(row, oldRow, errors) {
4165
console.log("exp.data: beforeUpdate: row is: " + row);
42-
if(row.Comments == "BeforeUpdate")
43-
row.Country = "Before Update changed me";
44-
else if(row.comments == "BeforeUpdate")
45-
row.country = "Before Update changed me";
66+
var comments = row.Comments || row.comments;
67+
if (comments === "Managed Update") {
68+
row.Country = "MANAGED-UPD";
69+
}
70+
else if (comments === "Managed Struct") {
71+
row.Country = "MANAGED-STRUCT";
72+
row.undeclaredCol = "bad";
73+
}
74+
else if (comments === "Managed Struct Remove") {
75+
row.Country = "MANAGED-STRUCT-REM";
76+
delete row.Comments;
77+
}
78+
79+
if (comments === "Managed Unhandled") {
80+
delete row.Country;
81+
} else {
82+
if (row.Comments === "BeforeUpdate")
83+
row.Country = "Before Update changed me";
84+
else if (row.comments === "BeforeUpdate")
85+
row.country = "Before Update changed me";
86+
if (!row.Country)
87+
row.Country = "DC-DEFAULT-UPD";
88+
}
4689
console.log("exp.data: old row is: " + oldRow);
4790
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
4891
}
4992

5093
function beforeDelete(row, errors) {
5194
console.log("exp.data: beforeDelete: row is: " + row);
52-
if(row.Comments == "BeforeDelete" || row.comments == "BeforeDelete")
95+
if (row.comments === "BeforeDelete")
5396
errors[null] = "This is the Before Delete Error";
5497

5598
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
@@ -58,7 +101,7 @@ function beforeDelete(row, errors) {
58101
function afterInsert(row, errors) {
59102
console.log("exp.data: afterInsert: row is: " + row);
60103

61-
if(row.Comments == "AfterInsert" || row.comments == "AfterInsert")
104+
if (row.comments === "AfterInsert")
62105
errors[null] = "This is the After Insert Error";
63106

64107
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
@@ -67,7 +110,7 @@ function afterInsert(row, errors) {
67110
function afterUpdate(row, oldRow, errors) {
68111
console.log("exp.data: afterUpdate: row is: " + row);
69112

70-
if(row.Comments == "AfterUpdate" || row.comments == "AfterUpdate")
113+
if (row.comments === "AfterUpdate")
71114
errors[null] = "This is the After Update Error";
72115

73116
console.log("exp.data: old row is: " +oldRow);
@@ -77,7 +120,7 @@ function afterUpdate(row, oldRow, errors) {
77120
function afterDelete(row, errors) {
78121
console.log("exp.data: afterDelete: row is: " + row);
79122

80-
if(row.Country == "Before Update changed me" || row.country == "Before Update changed me")
123+
if (row.country === "Before Update changed me")
81124
errors[null] = "This is the After Delete Error";
82125

83126
console.log(shared.sampleFunc("exp.data: this is from the shared function"));

modules/triggerTestModule/resources/queries/samples/SampleTypeTest.js

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,90 @@
66
var shared = require("TriggerTestModule/EmployeeLib");
77
var console = require("console");
88

9+
function managedColumns() {
10+
return {
11+
insert: ["Country"],
12+
update: ["Country"],
13+
};
14+
}
15+
916
function init(event, errors) {
1017
console.log("init got triggered with event: " + event);
1118
console.log(shared.sampleFunc("this is from the shared function"));
1219
}
1320

1421
function beforeInsert(row, errors) {
1522
console.log("samples: beforeInsert: row is: " + row);
16-
if(row.Comments) {
17-
if (row.Comments == "Individual Test") {
18-
row.Country = "Inserting Single";
19-
row.Comments = "BeforeDelete"; //set this for next test step
20-
}
21-
else if (row.Comments == "Import Test")
22-
row.Country = "Importing TSV";
23-
else if (row.Comments == "API Test")
24-
row.Country = "API BeforeInsert";
23+
if (row.name === "Managed Insert") {
24+
row.Country = "MANAGED-INS";
25+
} else if (row.name === "Managed Struct") {
26+
row.Country = "MANAGED-STRUCT";
27+
row.undeclaredCol = "bad";
28+
} else if (row.name === "Managed Struct Remove") {
29+
row.Country = "MANAGED-STRUCT-REM";
30+
delete row.Comments;
31+
}
32+
33+
if (row.name === "Managed Unhandled") {
34+
delete row.Country;
2535
} else {
26-
if (row.comments == "Individual Test") {
27-
row.country = "Inserting Single";
28-
row.comments = "BeforeDelete"; //set this for next test step
36+
if (row.Comments) {
37+
if (row.Comments === "Individual Test") {
38+
row.Country = "Inserting Single";
39+
row.Comments = "BeforeDelete";
40+
}
41+
else if (row.Comments === "Import Test")
42+
row.Country = "Importing TSV";
43+
else if (row.Comments === "API Test")
44+
row.Country = "API BeforeInsert";
45+
} else {
46+
if (row.Comments === "Individual Test") {
47+
row.country = "Inserting Single";
48+
row.Comments = "BeforeDelete";
49+
}
50+
else if (row.Comments === "Import Test")
51+
row.country = "Importing TSV";
52+
else if (row.Comments === "API Test")
53+
row.country = "API BeforeInsert";
2954
}
30-
else if (row.comments == "Import Test")
31-
row.country = "Importing TSV";
32-
else if (row.comments == "API Test")
33-
row.country = "API BeforeInsert";
55+
if (!row.Country)
56+
row.Country = "ST-DEFAULT";
3457
}
35-
3658
console.log("samples: edited row is: " + row);
3759
console.log(shared.sampleFunc("samples: this is from the shared function"));
3860
}
3961

4062
function beforeUpdate(row, oldRow, errors) {
4163
console.log("samples: beforeUpdate: row is: " + row);
42-
if(row.Comments == "BeforeUpdate")
43-
row.Country = "Before Update changed me";
44-
else if(row.comments == "BeforeUpdate")
45-
row.country = "Before Update changed me";
64+
if (row.Comments === "Managed Update") {
65+
row.Country = "MANAGED-UPD";
66+
} else if (row.Comments === "Managed Struct") {
67+
row.Country = "MANAGED-STRUCT";
68+
row.undeclaredCol = "bad";
69+
} else if (row.Comments === "Managed Struct Remove") {
70+
row.Country = "MANAGED-STRUCT-REM";
71+
delete row.Comments;
72+
}
73+
74+
if (row.Comments === "Managed Unhandled") {
75+
delete row.Country;
76+
} else {
77+
if (row.Comments === "BeforeUpdate")
78+
row.Country = "Before Update changed me";
79+
else if (row.Comments === "BeforeUpdate")
80+
row.country = "Before Update changed me";
81+
if (!row.Country) {
82+
row.Country = "ST-DEFAULT-UPD";
83+
}
84+
}
85+
4686
console.log("samples: old row is: " + oldRow);
4787
console.log(shared.sampleFunc("samples: this is from the shared function"));
4888
}
4989

5090
function beforeDelete(row, errors) {
5191
console.log("samples: beforeDelete: row is: " + row);
52-
if(row.Comments == "BeforeDelete" || row.comments == "BeforeDelete")
92+
if (row.Comments === "BeforeDelete")
5393
errors[null] = "This is the Before Delete Error";
5494

5595
console.log(shared.sampleFunc("samples: this is from the shared function"));
@@ -58,7 +98,7 @@ function beforeDelete(row, errors) {
5898
function afterInsert(row, errors) {
5999
console.log("samples: afterInsert: row is: " + row);
60100

61-
if(row.Comments == "AfterInsert" || row.comments == "AfterInsert")
101+
if (row.Comments === "AfterInsert")
62102
errors[null] = "This is the After Insert Error";
63103

64104
console.log(shared.sampleFunc("samples: this is from the shared function"));
@@ -67,7 +107,7 @@ function afterInsert(row, errors) {
67107
function afterUpdate(row, oldRow, errors) {
68108
console.log("samples: afterUpdate: row is: " + row);
69109

70-
if(row.Comments == "AfterUpdate" || row.comments == "AfterUpdate")
110+
if (row.Comments === "AfterUpdate")
71111
errors[null] = "This is the After Update Error";
72112

73113
console.log("samples: old row is: " +oldRow);
@@ -77,7 +117,7 @@ function afterUpdate(row, oldRow, errors) {
77117
function afterDelete(row, errors) {
78118
console.log("samples: afterDelete: row is: " + row);
79119

80-
if(row.Country == "Before Update changed me" || row.country == "Before Update changed me")
120+
if (row.country === "Before Update changed me")
81121
errors[null] = "This is the After Delete Error";
82122

83123
console.log(shared.sampleFunc("samples: this is from the shared function"));

0 commit comments

Comments
 (0)