Skip to content

Commit

Permalink
test: Make tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Jun 15, 2024
1 parent 2d20225 commit 497b863
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 51 deletions.
14 changes: 5 additions & 9 deletions src/tatoeba/search.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ pub fn to_query_parameters(options: SearchOptions) -> List(#(String, String)) {
])
}

// TODO(vxern): Document.
// TODO: If you know what the following represents, please open a PR to fill the
// documentation of these bits out.
pub type Finder {
// TODO(vxern): Document.
All
}

Expand Down Expand Up @@ -210,17 +210,13 @@ pub type Paging {
page_count: Int,
/// The sort strategy used in the search query.
sort_strategy: Option(SortStrategy),
// TODO(vxern): Document.
// TODO: If you know what the following do or how they're applied, please open a PR to fill
// these bits out.
direction: Option(Bool),
// TODO(vxern): Document.
limit: Option(sentence.Unknown),
// TODO(vxern): Document.
sort_default: Bool,
// TODO(vxern): Document.
direction_default: Bool,
// TODO(vxern): Document.
scope: Option(sentence.Unknown),
// TODO(vxern): Document.
complete_sort: List(sentence.Unknown),
)
}
Expand All @@ -237,7 +233,7 @@ fn scope(from _: Dynamic) -> Result(sentence.Unknown, List(dynamic.DecodeError))
Ok(sentence.Unknown)
}

// TODO(vxern): Document.
// TODO: If you know what the `complete_sort` is, please open a PR to document it.
fn complete_sort(
from _: Dynamic,
) -> Result(sentence.Unknown, List(dynamic.DecodeError)) {
Expand Down
6 changes: 4 additions & 2 deletions src/tatoeba/sentence.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ pub type TranscriptionType {
AlternativeScript
}

// TODO(vxern): Document.
/// Checks to see whether a `Dynamic` value is a transcription type, and returns the
/// transcription type if it is.
///
pub fn transcription_type(
from data: Dynamic,
) -> Result(TranscriptionType, List(dynamic.DecodeError)) {
Expand Down Expand Up @@ -404,7 +406,7 @@ pub type Sentence {
correctness: Int,
/// A list of `Translation`s of the sentence.
translations: List(Translation),
// TODO(vxern): What does this value represent?
// TODO: What does this value represent?
/// Note: This value will always be `None` given that this API wrapper does not
/// act as a user.
user_sentences: Option(List(Unknown)),
Expand Down
3 changes: 2 additions & 1 deletion test/api_test.gleam
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub fn new_request_to_test() {
todo
// TODO(vxern): Test.
Nil
}
39 changes: 15 additions & 24 deletions test/search/sentence_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import gleam/set
import gleeunit/should
import structs
import tatoeba/search/sentence as sentence_options
import utils

pub fn new_word_count_options_test() {
let word_count_options = sentence_options.new_word_count_options()
Expand Down Expand Up @@ -31,11 +30,7 @@ pub fn set_at_most_test() {
pub fn word_count_options_to_query_parameters_test() {
structs.word_count_options()
|> sentence_options.word_count_options_to_query_parameters()
|> utils.sort_parameters()
|> should.equal(
[#("word_count_min", "10"), #("word_count_max", "20")]
|> utils.sort_parameters(),
)
|> should.equal([#("word_count_max", "20"), #("word_count_min", "10")])
}

pub fn new_test() {
Expand Down Expand Up @@ -157,22 +152,18 @@ pub fn set_list_id_test() {
pub fn to_query_parameters_test() {
structs.sentence_options()
|> sentence_options.to_query_parameters()
|> utils.sort_parameters()
|> should.equal(
[
#("query", "betwixt"),
#("from", "eng"),
#("to", "ron"),
#("user", "7031"),
#("orphans", "yes"),
#("unapproved", "no"),
#("has_audio", "no"),
#("native", "yes"),
#("tags", "MyTag,YourTag,TheirTag"),
#("list", "123"),
#("word_count_min", "10"),
#("word_count_max", "20"),
]
|> utils.sort_parameters(),
)
|> should.equal([
#("list", "123"),
#("tags", "MyTag,TheirTag,YourTag"),
#("native", "yes"),
#("has_audio", "no"),
#("unapproved", "no"),
#("orphans", "yes"),
#("user", "7031"),
#("to", "ron"),
#("from", "eng"),
#("query", "betwixt"),
#("word_count_max", "20"),
#("word_count_min", "10"),
])
}
26 changes: 23 additions & 3 deletions test/search_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,30 @@ pub fn set_reverse_sort_test() {
pub fn to_query_parameters_test() {
structs.search_options()
|> search.to_query_parameters()

todo
|> should.equal([
#("list", "123"),
#("tags", "MyTag,TheirTag,YourTag"),
#("native", "yes"),
#("has_audio", "no"),
#("unapproved", "no"),
#("orphans", "yes"),
#("user", "7031"),
#("to", "ron"),
#("from", "eng"),
#("query", "betwixt"),
#("word_count_max", "20"),
#("word_count_min", "10"),
#("trans_has_audio", "yes"),
#("trans_unapproved", "no"),
#("trans_orphan", "yes"),
#("trans_user", "123"),
#("trans_link", "direct"),
#("trans_to", "ron"),
#("trans_filter", "limit"),
])
}

pub fn run_test() {
todo
// TODO(vxern): Test.
Nil
}
6 changes: 4 additions & 2 deletions test/sentence_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ pub fn sentence_exists_test() {
}

pub fn failed_request_test() {
todo
// TODO(vxern): Test.
Nil
}

pub fn failed_decoding_test() {
todo
// TODO(vxern): Test.
Nil
}

pub fn sentence_removed_test() {
Expand Down
10 changes: 0 additions & 10 deletions test/utils.gleam

This file was deleted.

0 comments on commit 497b863

Please sign in to comment.