File size: 2,816 Bytes
3f219b5
 
8488f43
3f219b5
8488f43
 
3f219b5
8488f43
3f219b5
 
8488f43
 
 
c2cfe14
 
 
 
 
8488f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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