javascript - Uncaught SyntaxError: Unexpected identifier in public players -
- i new jasmine , test cases
- i trying write test cases js code in fiddle.
- but facing aan error. uncaught syntaxerror: unexpected identifier
- can tell me how fix it.
- providing code below
- should neot use players method??
- do need pass parameters players
http://jsfiddle.net/2yw4o6z8/1/
public players(container: any, options: any, that: any,selectedoptions) { $(".displayinlineblock").removeclass("swimmingumentmobilediplay"); let swimmingimagemobile = "swimmingumentmobile"; let extensiontype = { ".pdf": "pdfmobile", ".ppt": "pptmobile", ".xls": "xlsmobile", ".xlsx": "xlsmobile", ".swimming": "swimmingumentmobile", ".swimmingx": "swimmingumentmobile", ".msg": "mailmobile" }; let lastindex = options.model.swimmingumentname.lastindexof("."); swimmingimagemobile = extensiontype[options.model.swimmingumentname.slice(lastindex).tolowercase()]; if (typeof options.model.swimmingumentmobile != "undefined" && options.model.swimmingumentmobile != "") { swimmingimagemobile = options.model.swimmingumentmobile; } if (typeof swimmingimagemobile == "undefined") { swimmingimagemobile = "newdocmobile"; } let kendotxtmenu = ""; if (options.model.iselfdoc == true) { kendotxtmenu = "swimmingumentmobilediplay"; } //"iselfdoc":true; let input = $("<span class='" + swimmingimagemobile + " displayinlineblock " + options.model.swimmingumentlength + " " + kendotxtmenu + " ' ></span><ul class='filetypeholder' id='filetypemobiles' style='display: none;'><li class='filetypeholdertitle'>elf document type</li><li><span class='swimmingumentmobile displayinlineblock' (click)='browsefiletype(swimming)'></span></li> <li><span class='xlsmobile displayinlineblock' (click)='browsefiletype('xls')'></span></li> <li><span class='pptmobile displayinlineblock'(click)='browsefiletype('ppt')'></span></li> <li><span class='pdfmobile displayinlineblock' (click)='browsefiletype('pdf')'></span></li><li><span class='newdocmobile displayinlineblock' (click)='browsefiletype('newswimming')'></span></li><li><span class='mailmobile displayinlineblock' (click)='browsefiletype('mail')'></span></li><li class='filetypeholderclosebtn'> <button id='closebtn' class='commonbtn'>close</button></ul>"); input.appendto(container); // <button class='commonbtn' id='closebtn'>close</button> this.selectedoptions = null; this.selectedoptions = options; $("#filetypemobiles").kendocontextmenu({ target: ".swimmingumentmobilediplay", showon: "click", open: function(e) { // console.log($(this).index(this)); // console.log($(this).index()); }, select: function(e) { //console.log(e.item.firstelementchild); //console.log(e.item.firstelementchild.firstelementchild.classname); var returnclassname = e.item.firstelementchild.firstelementchild.classname if (returnclassname == "commonbtn") { return false; } let firstclass = $("." + options.model.swimmingumentlength).attr('class').split(" ")[0]; var extensiontype = { "pdfmobile": "pdf", "pptmobile": "ppt", "xlsmobile": "xls", "swimmingumentmobile": "swimming", "newdocmobile": "default", "mailmobile": "msg" }; var classnames = "pdfmobile pptmobile xlsmobile swimmingumentmobile mailmobile newdocmobile"; var classes = $("." + options.model.swimmingumentlength).attr('class').split(" "); $("#" + options.model.swimmingumentlength).val("." + extensiontype[returnclassname.split(" ")[0]]); options.model.swimmingumentname = ""; options.model.swimmingumentname = "." + extensiontype[returnclassname.split(" ")[0]]; options.model.iselfdoc = false; (var c = 0; c < classes.length; c++) { if (classnames.includes(classes[c])) { $("." + options.model.swimmingumentlength).removeclass(classes[c]); } } options.model.swimmingumentmobile = returnclassname.split(" ")[0]; $("." + options.model.swimmingumentlength).addclass(e.item.firstelementchild.firstelementchild.classname); //$("."+options.model.swimmingumentid).addclass("displayinlineblock"); $("." + options.model.swimmingumentlength).addclass("swimmingumentmobilediplay"); let data_source = that.gridkendo._datasource.data(); (let d = 0; d < data_source.length; d++) { if (data_source[d].iselfdoc == true && data_source[d].elfdocid == "") { that.gridkendo.enablesavedocument(false); } } } }); } describe("our data array", function() { it("has 4 items", function() { expect(players()).tobe(0); }); });
the primary problem jsfiddle doesn't compile typescript javascript you.
try typescript playground , if need to, copy javascript across jsfiddle.
additional issues
you haven't enclosed public method within class... wrap players
method in class... i.e.
class example { public players(...) { } }
you need create instance of example
class use method unless make static:
const example = new example(); example.players(...);
you need specify property "selectedoptions" surprise compiler when reference it. add inside class also:
private selectedoptions: any;
you still have work make method return value. aren't passing arguments, have undefined-ness on shop.
if "running", you'll see test fails due options
being undefined:
http://jsfiddle.net/om4pc7s8/1/
i hope helps.
Comments
Post a Comment