Skip to content

Commit

Permalink
micnews/embeds#24 - expose embedAs twitter option
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar committed Jun 13, 2016
1 parent 31457d3 commit 1ff4fc4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/parse/embeds.js
Expand Up @@ -35,11 +35,11 @@ const transformers = {
user: user || null,
id, text, url
}),
twitter: ({url, date, user, id, text}) => ({
twitter: ({embedAs, url, date, user, id, text}) => ({
type: 'embed',
embedType: 'twitter',
caption: [],
url, date, user, id, text
embedAs, url, date, user, id, text
}),
youtube: ({youtubeId}) => ({
type: 'embed',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -50,7 +50,7 @@
"dependencies": {
"block-elements": "^1.1.0",
"embedly-url": "^1.0.0",
"embeds": "^2.0.1",
"embeds": "git://github.com/mikelax/embeds.git",
"es6-set": "^0.1.2",
"generate-function": "^2.0.0",
"get-youtube-id": "^1.0.0",
Expand Down
26 changes: 26 additions & 0 deletions test/parse-test.js
Expand Up @@ -368,6 +368,30 @@ test('parse() tweet - normal', t => {
const expected = [{
type: 'embed',
embedType: 'twitter',
embedAs: 'tweet',
caption: [],
text: [
{ content: 'GIF vs. JIF… This ', href: null },
{ content: 'pic.twitter.com/qFAHWgdbL6', href: 'https://t.co/qFAHWgdbL6' }
],
url: 'https://twitter.com/MattNavarra/status/684690494841028608',
date: 'January 6, 2016',
user: {
slug: 'MattNavarra',
name: 'Matt (foo) Navarra'
},
id: '684690494841028608'
}];
t.same(actual, expected);
});

test('parse() tweet - video', t => {
const input = '<blockquote class="twitter-video" lang="en"><p lang="en" dir="ltr">GIF vs. JIF… This <a href="https://t.co/qFAHWgdbL6">pic.twitter.com/qFAHWgdbL6</a></p>&mdash; Matt (foo) Navarra (@MattNavarra) <a href="https://twitter.com/MattNavarra/status/684690494841028608">January 6, 2016</a></blockquote><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>';
const actual = parse(input);
const expected = [{
type: 'embed',
embedType: 'twitter',
embedAs: 'video',
caption: [],
text: [
{ content: 'GIF vs. JIF… This ', href: null },
Expand All @@ -390,6 +414,7 @@ test('parse() tweet - no date', t => {
const expected = [{
type: 'embed',
embedType: 'twitter',
embedAs: 'tweet',
caption: [],
text: [
{ content: 'GIF vs. JIF… This ', href: null },
Expand Down Expand Up @@ -421,6 +446,7 @@ test('parse() tweet - no paragraph, no user', t => {
const expected = [{
type: 'embed',
embedType: 'twitter',
embedAs: 'tweet',
caption: [],
text: [],
url: 'https://twitter.com/MattNavarra/status/684690494841028608',
Expand Down

0 comments on commit 1ff4fc4

Please sign in to comment.