Assert against proper next_page_params values

pull/306/head
Stamates 7 years ago
parent 8d78e906fd
commit 6696021bd9
  1. 8
      apps/explorer_web/test/explorer_web/controllers/address_internal_transaction_controller_test.exs
  2. 7
      apps/explorer_web/test/explorer_web/controllers/address_transaction_controller_test.exs
  3. 8
      apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs
  4. 5
      apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs
  5. 6
      apps/explorer_web/test/explorer_web/controllers/pending_transaction_controller_test.exs
  6. 7
      apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs
  7. 9
      apps/explorer_web/test/explorer_web/controllers/transaction_internal_transaction_controller_test.exs
  8. 2
      apps/explorer_web/test/explorer_web/controllers/transaction_log_controller_test.exs

@ -3,7 +3,7 @@ defmodule ExplorerWeb.AddressInternalTransactionControllerTest do
import ExplorerWeb.Router.Helpers, only: [address_internal_transaction_path: 4]
alias Explorer.Chain.InternalTransaction
alias Explorer.Chain.{Block, InternalTransaction, Transaction}
alias Explorer.ExchangeRates.Token
describe "GET index/3" do
@ -134,11 +134,13 @@ defmodule ExplorerWeb.AddressInternalTransactionControllerTest do
test "next_page_params exist if not on last page", %{conn: conn} do
address = insert(:address)
block = %Block{number: number} = insert(:block)
transaction =
%Transaction{index: transaction_index} =
:transaction
|> insert()
|> with_block()
|> with_block(block)
1..60
|> Enum.map(fn index ->
@ -152,7 +154,7 @@ defmodule ExplorerWeb.AddressInternalTransactionControllerTest do
conn = get(conn, address_internal_transaction_path(ExplorerWeb.Endpoint, :index, :en, address.hash))
assert conn.assigns.next_page_params
assert %{block_number: ^number, index: 11, transaction_index: ^transaction_index} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -3,7 +3,7 @@ defmodule ExplorerWeb.AddressTransactionControllerTest do
import ExplorerWeb.Router.Helpers, only: [address_transaction_path: 4]
alias Explorer.Chain.Transaction
alias Explorer.Chain.{Block, Transaction}
alias Explorer.ExchangeRates.Token
describe "GET index/2" do
@ -97,14 +97,15 @@ defmodule ExplorerWeb.AddressTransactionControllerTest do
test "next_page_params exist if not on last page", %{conn: conn} do
address = insert(:address)
block = %Block{number: number} = insert(:block)
60
|> insert_list(:transaction, from_address: address)
|> with_block()
|> with_block(block)
conn = get(conn, address_transaction_path(ExplorerWeb.Endpoint, :index, :en, address.hash))
assert conn.assigns.next_page_params
assert %{block_number: ^number, index: 10} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -1,5 +1,6 @@
defmodule ExplorerWeb.BlockControllerTest do
use ExplorerWeb.ConnCase
alias Explorer.Chain.Block
@locale "en"
@ -58,11 +59,14 @@ defmodule ExplorerWeb.BlockControllerTest do
end
test "next_page_params exist if not on last page", %{conn: conn} do
insert_list(60, :block)
%Block{number: number} =
60
|> insert_list(:block)
|> Enum.fetch!(10)
conn = get(conn, block_path(conn, :index, @locale))
assert conn.assigns.next_page_params
assert %{block_number: ^number} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -1,6 +1,7 @@
defmodule ExplorerWeb.BlockTransactionControllerTest do
use ExplorerWeb.ConnCase
alias Explorer.Chain.Block
import ExplorerWeb.Router.Helpers, only: [block_transaction_path: 4]
describe "GET index/2" do
@ -49,7 +50,7 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
end
test "next_page_params exist if not on last page", %{conn: conn} do
block = insert(:block)
block = %Block{number: number} = insert(:block)
60
|> insert_list(:transaction)
@ -57,7 +58,7 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do
conn = get(conn, block_transaction_path(ExplorerWeb.Endpoint, :index, :en, block))
assert conn.assigns.next_page_params
assert %{block_number: ^number, index: 10} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -78,12 +78,16 @@ defmodule ExplorerWeb.PendingTransactionControllerTest do
end
test "next_page_params exist if not on last page", %{conn: conn} do
%Transaction{inserted_at: inserted_at, hash: hash} =
60
|> insert_list(:transaction)
|> Enum.fetch!(10)
converted_date = DateTime.to_iso8601(inserted_at)
conn = get(conn, pending_transaction_path(ExplorerWeb.Endpoint, :index, :en))
assert conn.assigns.next_page_params
assert %{inserted_at: ^converted_date, hash: ^hash} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -1,6 +1,6 @@
defmodule ExplorerWeb.TransactionControllerTest do
use ExplorerWeb.ConnCase
alias Explorer.Chain.Transaction
alias Explorer.Chain.{Block, Transaction}
import ExplorerWeb.Router.Helpers, only: [transaction_path: 4, transaction_internal_transaction_path: 4]
@ -67,14 +67,15 @@ defmodule ExplorerWeb.TransactionControllerTest do
test "next_page_params exist if not on last page", %{conn: conn} do
address = insert(:address)
block = %Block{number: number} = insert(:block)
60
|> insert_list(:transaction, from_address: address)
|> with_block()
|> with_block(block)
conn = get(conn, "/en/transactions")
assert conn.assigns.next_page_params
assert %{block_number: ^number, index: 10} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -3,7 +3,7 @@ defmodule ExplorerWeb.TransactionInternalTransactionControllerTest do
import ExplorerWeb.Router.Helpers, only: [transaction_internal_transaction_path: 4]
alias Explorer.Chain.InternalTransaction
alias Explorer.Chain.{Block, InternalTransaction, Transaction}
alias Explorer.ExchangeRates.Token
describe "GET index/3" do
@ -109,10 +109,13 @@ defmodule ExplorerWeb.TransactionInternalTransactionControllerTest do
end
test "next_page_params exist if not on last page", %{conn: conn} do
block = %Block{number: number} = insert(:block)
transaction =
%Transaction{index: transaction_index} =
:transaction
|> insert()
|> with_block()
|> with_block(block)
1..60
|> Enum.map(fn index ->
@ -125,7 +128,7 @@ defmodule ExplorerWeb.TransactionInternalTransactionControllerTest do
conn = get(conn, transaction_internal_transaction_path(ExplorerWeb.Endpoint, :index, :en, transaction.hash))
assert conn.assigns.next_page_params
assert %{block_number: ^number, index: 11, transaction_index: ^transaction_index} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

@ -81,7 +81,7 @@ defmodule ExplorerWeb.TransactionLogControllerTest do
conn = get(conn, transaction_log_path(conn, :index, :en, transaction))
assert conn.assigns.next_page_params
assert %{index: 50} = conn.assigns.next_page_params
end
test "next_page_params are empty if on last page", %{conn: conn} do

Loading…
Cancel
Save