|
defmodule Medicode.TranscriptionsTest do |
|
use Medicode.DataCase |
|
|
|
alias Medicode.Transcriptions |
|
|
|
describe "transcriptions" do |
|
alias Medicode.Transcriptions.Transcription |
|
|
|
import Medicode.TranscriptionsFixtures |
|
import Medicode.AccountsFixtures |
|
|
|
@invalid_attrs %{filename: nil, recording_length_in_seconds: nil} |
|
|
|
test "list_transcriptions/1 returns all transcriptions" do |
|
user = user_fixture() |
|
transcription = transcription_fixture(%{user: user}) |
|
|
|
assert Transcriptions.list_transcriptions(user) == [transcription] |
|
end |
|
|
|
test "get_transcription!/1 returns the transcription with given id" do |
|
transcription = transcription_fixture() |
|
assert Transcriptions.get_transcription!(transcription.id) == transcription |
|
end |
|
|
|
test "create_transcription/1 with valid data creates a transcription" do |
|
user = user_fixture() |
|
|
|
valid_attrs = %{ |
|
user_id: user.id, |
|
filename: "some filename", |
|
recording_length_in_seconds: 42 |
|
} |
|
|
|
assert {:ok, %Transcription{} = transcription} = |
|
Transcriptions.create_transcription(valid_attrs) |
|
|
|
assert transcription.filename == "some filename" |
|
assert transcription.recording_length_in_seconds == 42 |
|
end |
|
|
|
test "create_transcription/1 with invalid data returns error changeset" do |
|
assert {:error, %Ecto.Changeset{}} = Transcriptions.create_transcription(@invalid_attrs) |
|
end |
|
|
|
test "update_transcription/2 with valid data updates the transcription" do |
|
transcription = transcription_fixture() |
|
update_attrs = %{filename: "some updated filename", recording_length_in_seconds: 43} |
|
|
|
assert {:ok, %Transcription{} = transcription} = |
|
Transcriptions.update_transcription(transcription, update_attrs) |
|
|
|
assert transcription.filename == "some updated filename" |
|
assert transcription.recording_length_in_seconds == 43 |
|
end |
|
|
|
test "update_transcription/2 with invalid data returns error changeset" do |
|
transcription = transcription_fixture() |
|
|
|
assert {:error, %Ecto.Changeset{}} = |
|
Transcriptions.update_transcription(transcription, @invalid_attrs) |
|
|
|
assert transcription == Transcriptions.get_transcription!(transcription.id) |
|
end |
|
|
|
test "delete_transcription/1 deletes the transcription" do |
|
transcription = transcription_fixture() |
|
assert {:ok, %Transcription{}} = Transcriptions.delete_transcription(transcription) |
|
|
|
assert_raise Ecto.NoResultsError, fn -> |
|
Transcriptions.get_transcription!(transcription.id) |
|
end |
|
end |
|
|
|
test "change_transcription/1 returns a transcription changeset" do |
|
transcription = transcription_fixture() |
|
assert %Ecto.Changeset{} = Transcriptions.change_transcription(transcription) |
|
end |
|
end |
|
end |
|
|