diff --git a/test/squire.spec.js b/test/squire.spec.js
index 52cf70f..6705f61 100644
--- a/test/squire.spec.js
+++ b/test/squire.spec.js
@@ -195,6 +195,76 @@ describe('Squire RTE', function () {
});
});
+ describe('getPath', function () {
+ var startHTML;
+ beforeEach( function () {
+ startHTML = '
one two three four five
';
+ editor.setHTML(startHTML);
+
+ var range = doc.createRange();
+ range.setStart(doc.body.childNodes.item(0), 0);
+ range.setEnd(doc.body.childNodes.item(0), 1);
+ editor.setSelection(range);
+ });
+
+ it('returns the path to the selection', function () {
+ editor.insertHTML('Bold Text');
+ expect(editor.getPath(), 'to be', 'DIV>B');
+ });
+
+ it('includes id in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV#spanId');
+ });
+
+ it('includes class name in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.myClass');
+ });
+
+ it('includes all class names in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.myClass.myClass2.myClass3');
+ });
+
+ it('includes direction in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV[dir=rtl]');
+ });
+
+ it('includes highlight value in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.highlight[backgroundColor=rgb(255,0,0)]');
+ });
+
+ it('includes color value in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.colour[color=rgb(255,0,0)]');
+ });
+
+ it('includes font family value in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.font[fontFamily=Arial,sans-serif]');
+ });
+
+ it('includes font size value in the path', function () {
+ editor.insertHTML('Text
');
+ expect(editor.getPath(), 'to be', 'DIV.size[fontSize=12pt]');
+ });
+
+ it('is (selection) when the selection is a range', function() {
+ var range = doc.createRange();
+ range.setStart(doc.body.childNodes.item(0).childNodes.item(0), 0);
+ range.setEnd(doc.body.childNodes.item(0).childNodes.item(3), 0);
+ editor.setSelection(range);
+
+ //Manually tell it to update the path
+ editor._updatePath(range);
+
+ expect(editor.getPath(), 'to be', '(selection)');
+ });
+ });
+
afterEach(function () {
editor = null;
var iframe = document.getElementById('testFrame');