diff options
Diffstat (limited to 'tests/frontend/specs')
-rw-r--r-- | tests/frontend/specs/button_italic.js | 33 | ||||
-rw-r--r-- | tests/frontend/specs/keystroke_delete.js | 38 | ||||
-rw-r--r-- | tests/frontend/specs/keystroke_urls_become_clickable.js | 29 |
3 files changed, 100 insertions, 0 deletions
diff --git a/tests/frontend/specs/button_italic.js b/tests/frontend/specs/button_italic.js new file mode 100644 index 00000000..c394723c --- /dev/null +++ b/tests/frontend/specs/button_italic.js @@ -0,0 +1,33 @@ +describe("italic button", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + testHelper.newPad(cb); + }); + + it("makes text italic", function() { + //get the inner iframe + var $inner = testHelper.$getPadInner(); + + //get the first text element out of the inner iframe + var firstTextElement = $inner.find("div").first(); + + //select this text element + testHelper.selectText(firstTextElement[0], $inner); + + //get the bold button and click it + var $italicButton = testHelper.$getPadChrome().find(".buttonicon-italic"); + $italicButton.click(); + + //ace creates a new dom element when you press a button, so just get the first text element again + var newFirstTextElement = $inner.find("div").first(); + + // is there a <b> element now? + var isItalic = newFirstTextElement.find("i").length === 1; + + //expect it to be bold + expect(isItalic).to.be(true); + + //make sure the text hasn't changed + expect(newFirstTextElement.text()).to.eql(firstTextElement.text()); + }); +}); diff --git a/tests/frontend/specs/keystroke_delete.js b/tests/frontend/specs/keystroke_delete.js new file mode 100644 index 00000000..58a6b5bb --- /dev/null +++ b/tests/frontend/specs/keystroke_delete.js @@ -0,0 +1,38 @@ +describe("delete keystroke", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + testHelper.newPad(cb); + }); + + it("makes text delete", function() { + //get the inner iframe + var $inner = testHelper.$getPadInner(); + + //get the first text element out of the inner iframe + var firstTextElement = $inner.find("div").first(); + + // get the original length of this element + var elementLength = firstTextElement.html().length; + + // get the original string value minus the last char + var originalTextValue = firstTextElement.text(); + originalTextValue = originalTextValue.substring(0, originalTextValue.length -1); + + // simulate key presses to delete content + firstTextElement.sendkeys('{leftarrow}'); // simulate a keypress of the left arrow key + firstTextElement.sendkeys('{del}'); // simulate a keypress of delete + + //ace creates a new dom element when you press a keystroke, so just get the first text element again + var newFirstTextElement = $inner.find("div").first(); + + // get the new length of this element + var newElementLength = newFirstTextElement.html().length; + + //expect it to be one char less in length + expect(newElementLength).to.be((elementLength-1)); + + //make sure the text has changed correctly + expect(newFirstTextElement.text()).to.eql(originalTextValue); + + }); +}); diff --git a/tests/frontend/specs/keystroke_urls_become_clickable.js b/tests/frontend/specs/keystroke_urls_become_clickable.js new file mode 100644 index 00000000..87de3bae --- /dev/null +++ b/tests/frontend/specs/keystroke_urls_become_clickable.js @@ -0,0 +1,29 @@ +describe("urls become clickable", function(){ + //create a new pad before each test run + beforeEach(function(cb){ + testHelper.newPad(cb); + }); + + it("adds a url and makes sure it's clickable", function() { + //get the inner iframe + var $inner = testHelper.$getPadInner(); + + //get the first text element out of the inner iframe + var firstTextElement = $inner.find("div").first(); + + // simulate key presses to delete content + firstTextElement.sendkeys('{selectall}'); // select all + firstTextElement.sendkeys('{del}'); // clear the first line + firstTextElement.sendkeys('http://etherpad.org'); // add a url to the pad + + //ace creates a new dom element when you press a keystroke, so just get the first text element again + var newFirstTextElement = $inner.find("div").first(); + + // is there a url class now? + var isURL = newFirstTextElement.find("href").length === 1; + + //expect it to be bold + expect(isURL).to.be(true); + + }); +}); |