defmodule TwittertexTest do use ExUnit.Case doctest Twittertex defp tweet_json(name) do contents = File.read!(Path.join(["test", "tweets", "#{name}.json"])) Jason.decode!(contents) end test "URLs and hashtags" do json = tweet_json("display_guidelines") assert Twittertex.format_tweet(json) == "Along with our new #Twitterbird, we've also updated our Display Guidelines: dev.twitter.com/terms/display-… ^JC" end test "photo and hashtags" do json = tweet_json("piglets") assert Twittertex.format_tweet(json) == "Just piggin lovely.
#smithillsfarm #kunekune #piglets #cuddling pic.twitter.com/mPMZlracLP" end test "mentions" do json = tweet_json("kanye") assert Twittertex.format_tweet(json) == "Hi @jack Dorsey, can you guys please take down all the fake Kanye accounts." end test "extended" do json = tweet_json("extended") assert Twittertex.format_tweet(json) == "@twitter @TwitterDev has more details about these changes at blog.twitter.com/2016/doing-mor…. Thanks for making @twitter more expressive! pic.twitter.com/AWmiH870F7" end test "URLs and hashtags with provided link_opts" do json = tweet_json("display_guidelines") opts = [link_opts: [target: "_blank", class: "foo"]] assert Twittertex.format_tweet(json, opts) == "Along with our new #Twitterbird, we've also updated our Display Guidelines: dev.twitter.com/terms/display-… ^JC" end test "URLs, mentions and hashtags from v2 API" do json = tweet_json("v2_mentions_hashtags_urls") assert Twittertex.format_tweet(json) == "Students & Researchers 🚨 Join us on January 28th for our livestream on twitch.tv/twitterdev

@suhemparack will be hosting Emily Chen, PhD candidate at University of Southern California to discuss best practices on building datasets for research using the #TwitterAPI v2 pic.twitter.com/1PcRy2jz2d" end end