Skip to content

Commit

Permalink
Correct ref to rel attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Nov 9, 2016
1 parent 1d53f94 commit 3aeb1d0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/js/models/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const VALID_MARKUP_TAGNAMES = [

export const VALID_ATTRIBUTES = [
'href',
'ref'
'rel'
];

class Markup {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/parsers/dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ test('strong tag + em + text node creates section', (assert) => {

test('link (A tag) is parsed', (assert) => {
let url = 'http://bustle.com',
ref = 'nofollow';
let element = buildDOM(`<a href="${url}" ref="${ref}">link</a>`);
rel = 'nofollow';
let element = buildDOM(`<a href="${url}" rel="${rel}">link</a>`);
const post = parser.parse(element);

assert.equal(post.sections.length, 1, '1 section');
Expand All @@ -232,7 +232,7 @@ test('link (A tag) is parsed', (assert) => {

let markup = marker.markups[0];
assert.equal(markup.getAttribute('href'), url, 'has href attr');
assert.equal(markup.getAttribute('ref'), ref, 'has ref attr');
assert.equal(markup.getAttribute('rel'), rel, 'has rel attr');
});

test('span with font-style italic maps to em', (assert) => {
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/renderers/editor-dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,34 @@ test('renders a post with multiple markers', (assert) => {
assert.equal(renderTree.rootElement.innerHTML, '<p>hello <b>bold, <i>italic,</i></b> world.</p>');
});

test('renders a post with marker with link markup', (assert) => {
let post = builder.createPost();
let section = builder.createMarkupSection('P');
post.sections.append(section);

let href = 'http://google.com';
let rel = 'nofollow';
let linkMarkup = builder.createMarkup('A', {href, rel});

section.markers.append(builder.createMarker('hello', [linkMarkup]));

const renderTree = new RenderTree(post);
render(renderTree);
let {innerHTML: html} = renderTree.rootElement;
assert.ok(
html.match(/<p><a .*>hello<\/a><\/p>/),
'a tag present'
);
assert.ok(
html.match(new RegExp(`href="${href}"`)),
'href present'
);
assert.ok(
html.match(new RegExp(`rel="${rel}"`)),
'rel present'
);
});

test('renders a post with image', (assert) => {
let url = placeholderImageSrc;
let post = builder.createPost();
Expand Down

0 comments on commit 3aeb1d0

Please sign in to comment.