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.110 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.109 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.108 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.107 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.106 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.105 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.104 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.103 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.102 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.101 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.100 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.99 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.98 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.97 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.96 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.95 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.94 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.93 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.92 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala
trackler-2.2.1.91 tracks/scala/exercises/phone-number/src/test/scala/PhoneNumberTest.scala