Skip to content

Commit f621549

Browse files
author
lumenn-home
committed
Switch to extendscript-es5-shim, added some test functions for illustrator
1 parent ebd1ea8 commit f621549

File tree

4 files changed

+76
-7
lines changed

4 files changed

+76
-7
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extendscriptr.options.forEach(function(opt) {
2727
);
2828
});
2929

30-
var prototypePolyfills = fs.readFileSync(require.resolve('extendscript.prototypes'), 'utf8');
30+
var prototypePolyfills = fs.readFileSync(require.resolve('extendscript-es5-shim'), 'utf8');
3131
var browserifyPlugins = [ [ prependify, prototypePolyfills ] ];
3232

3333
var adobeTarget = String(extendscriptr.target).toLowerCase();

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"browserify": "^16.2.3",
5252
"commander": "^2.15.1",
5353
"contributors": "^0.5.1",
54-
"extendscript.prototypes": "0.1.1",
54+
"extendscript-es5-shim": "^0.2.0",
5555
"prependify": "^1.3.0"
5656
},
5757
"devDependencies": {

test/src/illustrator.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,74 @@ feel more connected, bringing delight in big and \
2424
small ways, and empowering them to affect change."';
2525

2626
const fontStyle = text1.textRange.characterAttributes;
27-
fontStyle.textFont = app.textFonts.getByName("Courier");
27+
fontStyle.textFont = app.textFonts.getByName("MyriadPro-Bold");
2828
fontStyle.size = 2.5;
29+
30+
// Tests for Array methods
31+
32+
lib.write('### TESTING ARRAY METHODS ###');
33+
34+
lib.write('Testing map function');
35+
const testArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1];
36+
testArray.map(number => lib.write(`map = ${number} out of ${testArray.length - 1} = ${number * 4}`));
37+
38+
const reduceResult = testArray.reduce((acc, curr) => acc + curr, 0);
39+
lib.write(`Testing reduce function = ${reduceResult}`);
40+
41+
lib.write('Testing forEach function');
42+
testArray.forEach(value => lib.write(`forEach = ${value}`));
43+
44+
45+
lib.write('Testing filter function');
46+
47+
const filteredArray = testArray.filter( (number) => {
48+
if(number % 2 === 0) {
49+
return true;
50+
}
51+
return false;
52+
});
53+
54+
filteredArray.forEach(number => lib.write(`Filter = ${number}`));
55+
56+
lib.write('Testing every function');
57+
testArray.every(number => {
58+
if (number < 3) {
59+
lib.write(`Every = ${number}`);
60+
return true;
61+
}
62+
return false;
63+
});
64+
65+
lib.write('Testing indexOf function');
66+
lib.write(testArray.indexOf(4));
67+
68+
lib.write('Testing isArray function');
69+
const notArray = 10;
70+
lib.write(Array.isArray(notArray));
71+
lib.write(Array.isArray(testArray));
72+
73+
lib.write('Testing lastIndexOf function');
74+
lib.write(testArray.lastIndexOf(1));
75+
76+
lib.write('Testing reduceRight function');
77+
const reduceRightResult = testArray.reduceRight((acc, curr) => acc + curr, 0);
78+
lib.write(`Testing reduce function = ${reduceRightResult}`);
79+
80+
81+
// Tests for Date methods
82+
lib.write('### TESTING Date METHODS ###');
83+
84+
const today = new Date();
85+
lib.write(today.toISOString());
86+
87+
// Tests for Date methods
88+
lib.write('### TESTING Function METHODS ###');
89+
lib.write('### TESTING Object METHODS ###');
90+
91+
//TODO implement testing Fuction and Object methods
92+
93+
lib.write('### TESTING String METHODS ###');
94+
const newString = ' ThisIsSomeWordToTrim ';
95+
96+
lib.write(`Before trimming: ${newString}`);
97+
lib.write(`After trimming: ${newString.trim()}`);

0 commit comments

Comments
 (0)