Sha256: fac5bcfea3d4f3113de3709746b1545f86f2d625908684fd91698aae2096bc4b

Contents?: true

Size: 1.59 KB

Versions: 137

Compression:

Stored size: 1.59 KB

Contents

import org.scalatest.{Matchers, FunSuite}

/** @version 1.2.0 */
class PhoneNumberTest extends FunSuite with Matchers {

  test("cleans the number") {
    PhoneNumber.clean("(223) 456-7890") should be (Some("2234567890"))
  }

  test("cleans numbers with dots") {
    pending
    PhoneNumber.clean("223.456.7890") should be (Some("2234567890"))
  }

  test("cleans numbers with multiple spaces") {
    pending
    PhoneNumber.clean("223 456   7890   ") should be (Some("2234567890"))
  }

  test("invalid when 9 digits") {
    pending
    PhoneNumber.clean("123456789") should be (None)
  }

  test("invalid when 11 digits does not start with a 1") {
    pending
    PhoneNumber.clean("22234567890") should be (None)
  }

  test("valid when 11 digits and starting with 1") {
    pending
    PhoneNumber.clean("12234567890") should be (Some("2234567890"))
  }

  test("valid when 11 digits and starting with 1 even with punctuation") {
    pending
    PhoneNumber.clean("+1 (223) 456-7890") should be (Some("2234567890"))
  }

  test("invalid when more than 11 digits") {
    pending
    PhoneNumber.clean("321234567890") should be (None)
  }

  test("invalid with letters") {
    pending
    PhoneNumber.clean("123-abc-7890") should be (None)
  }

  test("invalid with punctuations") {
    pending
    PhoneNumber.clean("123-@:!-7890") should be (None)
  }

  test("invalid if area code does not start with 2-9") {
    pending
    PhoneNumber.clean("(123) 456-7890") should be (None)
  }

  test("invalid if exchange code does not start with 2-9") {
    pending
    PhoneNumber.clean("(223) 056-7890") should be (None)
  }
}

Version data entries

137 entries across 137 versions & 1 rubygems

Version Path
trackler-2.2.1.90 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.89 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.88 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.87 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.86 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.85 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.84 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.83 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.82 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.81 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.80 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.79 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.78 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.77 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.76 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.75 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.74 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.73 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.72 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.71 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala