Created
April 26, 2013 09:00
-
-
Save uhunkler/5465885 to your computer and use it in GitHub Desktop.
test object - JSTalk Sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Test object for simple asserts | |
* test.assert( typeof 1 === 'number', '1 is a number' ); // add a test | |
* test.print( 'text' ); // add some text | |
* test.show(); // output all results | |
*/ | |
var test = { | |
heap: [], | |
assert: function (value, desc) { | |
var result = value ? "--- pass: " : "xxx fail: "; | |
result += desc; | |
this.heap.push(result); | |
}, | |
print: function (desc) { | |
this.heap.push(desc); | |
}, | |
show: function () { | |
var s = ''; | |
for(var t in this.heap) { | |
s += this.heap[ t ] + "\n"; | |
} | |
print(s); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test some layer methods with the simple test object | |
// A text layer must be selected in Sketch | |
var layer = selection[0]; | |
// feature detection | |
test.print( "\n" + '__feature detection:' ); | |
test.assert( ('name' in layer), "text layer knows the 'name' method" ); | |
test.assert( ('setName' in layer), "text layer knows the 'setName' method" ); | |
test.assert( ('font' in layer), "text layer knows the 'font' method" ); | |
test.assert( ('setFont' in layer), "text layer knows the 'setFont' method" ); | |
test.assert( ('fontPostscriptName' in layer), "text layer knows the 'fontPostscriptName' method" ); | |
test.assert( ('setFontPostscriptName' in layer), "text layer knows the 'setFontPostscriptName' method" ); | |
test.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment