<commit_before>import XCTest
@testable import KsApi
import Models

class DiscoveryParamsTests: XCTestCase {

  func testInit() {
    let params = DiscoveryParams(
      staffPicks: true,
      hasVideo: true,
      starred: false,
      backed: false,
      social: nil,
      recommended: nil,
      similarTo: nil,
      category: nil,
      query: "wallet",
      state: .Live,
      sort: .Magic,
      page: 1,
      perPage: 20,
      includePOTD: nil,
      seed: nil
    )

    XCTAssertEqual(params.staffPicks, true)
  }

  func testWith() {
    let params = DiscoveryParams()
    let newParams = params.with(state: .Live, sort: .Popular)

    XCTAssertEqual(newParams.state, .Live)
    XCTAssertEqual(newParams.sort, .Popular)
  }

  func testNextPage() {
    let params = DiscoveryParams()
    let nextPage = params.nextPage()

    XCTAssertEqual(params.page, 1)
    XCTAssertEqual(nextPage.page, 2)
  }

  func testNextPageWithUnspecifiedPage() {
    let params = DiscoveryParams(page: nil)
    let nextPage = params.nextPage()

    XCTAssertEqual(params.page, nil)
    XCTAssertEqual(nextPage.page, 2)
  }

  func testQueryParams() {
    let defaultParams = DiscoveryParams()
    XCTAssertEqual(defaultParams.queryParams, [
      "page": DiscoveryParams.defaultPage.description,
      "per_page": DiscoveryParams.defaultPerPage.description
    ])<commit_msg>More extensive test on 'with' method.<commit_after>import XCTest
@testable import KsApi
import Models

class DiscoveryParamsTests: XCTestCase {

  func testInit() {
    let params = DiscoveryParams(
      staffPicks: true,
      hasVideo: true,
      starred: false,
      backed: false,
      social: nil,
      recommended: nil,
      similarTo: nil,
      category: nil,
      query: "wallet",
      state: .Live,
      sort: .Magic,
      page: 1,
      perPage: 20,
      includePOTD: nil,
      seed: nil
    )

    XCTAssertEqual(params.staffPicks, true)
  }

  func testWith() {
    let params = DiscoveryParams(
      staffPicks: true,
      hasVideo: true,
      starred: false,
      backed: false,
      social: nil,
      recommended: nil,
      similarTo: nil,
      category: nil,
      query: "wallet",
      state: .Live,
      sort: .Magic,
      page: 1,
      perPage: 20,
      includePOTD: nil,
      seed: nil
    )

    XCTAssertEqual(params.with(state: .Live).state, .Live)
    XCTAssertEqual(params.with(sort: .Popular).sort, .Popular)
    XCTAssertEqual(params.with(staffPicks: false).staffPicks, false)
    XCTAssertEqual(params.with(hasVideo: false).hasVideo, false)
    XCTAssertEqual(params.with(starred: true).starred, true)
    XCTAssertEqual(params.with(backed: true).backed, true)
    XCTAssertEqual(params.with(social: false).social, false)
    XCTAssertEqual(params.with(recommended: false).recommended, false)
    XCTAssertEqual(params.with(page: 2).page, 2)
    XCTAssertEqual(params.with(perPage: 2).perPage, 2)
    XCTAssertEqual(params.with(seed: 123).seed, 123)
  }

  func testNextPage() {
    let params = DiscoveryParams()
    let nextPage = params.nextPage()

    XCTAssertEqual(params.page, 1)
    XCTAssertEqual(nextPage.page, 2)
  }

  func testNextPageWithUnspecifiedPage() {
    let params = DiscoveryParams(page: nil)
    let nextPage = params.nextPage()

    XCTAssertEqual(params.page, nil)
    XCTAssertEqual(nextPage.page, 2)
  }

  func testQueryParams() {
    let defaultParams = DiscoveryParams()
    XCTAssertEqual(defaultParams.queryParams, [
      "page": DiscoveryParams.defaultPage.description,
      "per_page": DiscoveryParams.defaultPerPage.description
    ])
{'fraction_non_alphanumeric': 0.10700389105058365, 'fraction_numerical': 0.006948304613674263, 'mean_word_length': 3.05749718151071, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5509341', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1146, 'n_words': 252}