-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(ns wrike-ist.core-test | ||
(:require [cljs.test :refer-macros [deftest is testing run-tests]] | ||
[wrike-ist.core :refer [extract-details]])) | ||
|
||
(deftest extract-details-test | ||
(testing "No .body in payload" | ||
(let [payload (clj->js {})] | ||
(is (= nil (extract-details payload))))) | ||
(testing "No link in payload" | ||
(let [payload (clj->js {:body ""})] | ||
(is (= nil (extract-details payload))))) | ||
(testing "Extract link from payload" | ||
(let [url "https://www.wrike.com/open.htm?id=1" | ||
payload (clj->js {:body (str "a\n" url "\nb")})] | ||
(is (= url (:permalink (extract-details payload)))))) | ||
(testing "Extract pull request URL from payload" | ||
(let [url "https://github.com/valerauko/wrike-ist/pull/9001" | ||
payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:html_url url})] | ||
(is (= url (:pr-url (extract-details payload)))))) | ||
(testing "Extract pull request title from payload" | ||
(let [title "hoge" | ||
payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:title title})] | ||
(is (= title (:title (extract-details payload)))))) | ||
(testing "Translating pull request state" | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:merged true | ||
:state "closed"})] | ||
(is (= :merged (:state (extract-details payload))))) | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:merged true})] | ||
(is (= :merged (:state (extract-details payload))))) | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:merged false | ||
:state "closed"})] | ||
(is (= :closed (:state (extract-details payload))))) | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:state "closed"})] | ||
(is (= :closed (:state (extract-details payload))))) | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1" | ||
:merged false | ||
:state "open"})] | ||
(is (= :open (:state (extract-details payload))))) | ||
(let [payload (clj->js {:body "https://www.wrike.com/open.htm?id=1"})] | ||
(is (= :open (:state (extract-details payload))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(ns wrike-ist.wrike-test | ||
(:require [cljs.test :refer-macros [deftest is testing run-tests]] | ||
[wrike-ist.wrike :refer [link-html]])) | ||
|
||
(deftest link-html-test | ||
(testing "No title" | ||
(let [url "https://github.com/valerauko/wrike-ist/pull/9001" | ||
data {:pr-url url}] | ||
(is (= url (re-find (re-pattern url) (link-html data)))))) | ||
(testing "With title" | ||
(let [url "https://github.com/valerauko/wrike-ist/pull/9001" | ||
title "hoge" | ||
data {:pr-url url :title title}] | ||
(is (= url (re-find (re-pattern url) (link-html data)))) | ||
(is (= title (re-find (re-pattern title) (link-html data))))))) |