describe("import functionality", function(){ beforeEach(function(cb){ helper.newPad(cb); // creates a new pad this.timeout(60000); }); function getinnertext(){ var inner = helper.padInner$ if(!inner){ return "" } var newtext = "" inner("div").each(function(line,el){ newtext += el.innerHTML+"\n" }) return newtext } function importrequest(data,importurl,type){ var success; var error; var result = $.ajax({ url: importurl, type: "post", processData: false, async: false, contentType: 'multipart/form-data; boundary=boundary', accepts: { text: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" }, data: 'Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.'+type+'"\r\nContent-Type: text/plain\r\n\r\n' + data + '\r\n\r\n--boundary', error: function(res){ error = res } }) expect(error).to.be(undefined) return result } function exportfunc(link){ var exportresults = [] $.ajaxSetup({ async:false }) $.get(link+"/export/html",function(data){ var start = data.indexOf("") var end = data.indexOf("") var html = data.substr(start+6,end-start-6) exportresults.push(["html",html]) }) $.get(link+"/export/txt",function(data){ exportresults.push(["txt",data]) }) return exportresults } xit("import a pad with newlines from txt", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var textWithNewLines = 'imported text\nnewline' importrequest(textWithNewLines,importurl,"txt") helper.waitFor(function(){ return expect(getinnertext()).to.be('imported text\nnewline\n
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be("imported text
newline

") expect(results[1][1]).to.be("imported text\nnewline\n\n") done() }) xit("import a pad with newlines from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithNewLines = 'htmltext
newline' importrequest(htmlWithNewLines,importurl,"html") helper.waitFor(function(){ return expect(getinnertext()).to.be('htmltext\nnewline\n
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be("htmltext
newline

") expect(results[1][1]).to.be("htmltext\nnewline\n\n") done() }) xit("import a pad with attributes from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithNewLines = 'htmltext
newline' importrequest(htmlWithNewLines,importurl,"html") helper.waitFor(function(){ return expect(getinnertext()).to.be('htmltext\nnewline\n
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be('htmltext
newline

') expect(results[1][1]).to.be('htmltext\nnewline\n\n') done() }) xit("import a pad with bullets from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithBullets = '' importrequest(htmlWithBullets,importurl,"html") helper.waitFor(function(){ return expect(getinnertext()).to.be('\ \n\ \n\ \n\ \n\
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be('
') expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n') done() }) xit("import a pad with bullets and newlines from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithBullets = '

' importrequest(htmlWithBullets,importurl,"html") helper.waitFor(function(){ return expect(getinnertext()).to.be('\ \n\
\n\ \n\ \n\
\n\ \n\
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be('


') expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n') done() }) xit("import a pad with bullets and newlines and attributes from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithBullets = '

' importrequest(htmlWithBullets,importurl,"html") helper.waitFor(function(){ return expect(getinnertext()).to.be('\ \n\
\n\ \n\ \n
\n\ \n\ \n\ \n\
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be('


') expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n') done() }) xit("import a pad with nested bullets from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithBullets = '' importrequest(htmlWithBullets,importurl,"html") var oldtext=getinnertext() helper.waitFor(function(){ return oldtext != getinnertext() // return expect(getinnertext()).to.be('\ //\n\ //\n\ //\n\ //\n\ //\n\ //\n\ //
\n') }) var results = exportfunc(helper.padChrome$.window.location.href) expect(results[0][1]).to.be('
') expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1\n\t* bullet2 line 1\n\n') done() }) xit("import a pad with 8 levels of bullets and newlines and attributes from html", function(done){ var importurl = helper.padChrome$.window.location.href+'/import' var htmlWithBullets = '