Sha256: efb802b8601ea8743a7662f3043014e3bcf96c5826507ac17fa7ddc2219db3a4

Contents?: true

Size: 1.12 KB

Versions: 396

Compression:

Stored size: 1.12 KB

Contents

local PhoneNumber = require('phone-number')

describe('phone-number', function()
  it('cleans the number (123) 456-7890', function()
    local phone = PhoneNumber:new('(123) 456-7890')
    assert.are.equals('1234567890', phone.number)
  end)

  it('cleans numbers with dots', function()
    local phone = PhoneNumber:new('123.456.7890')
    assert.are.equals('1234567890', phone.number)
  end)

  it('valid when 11 digits and first digit is 1', function()
    local phone = PhoneNumber:new('11234567890')
    assert.are.equals('1234567890', phone.number)
  end)

  it('invalid when 11 digits', function()
    local phone = PhoneNumber:new('21234567890')
    assert.are.equals('0000000000', phone.number)
  end)

  it('invalid when 9 digits', function()
    local phone = PhoneNumber:new('123456789')
    assert.are.equals('0000000000', phone.number)
  end)

  it('has an area code', function()
    local phone = PhoneNumber:new('1234567890')
    assert.are.equals('123', phone:areaCode())
  end)

  it('formats a number', function()
    local phone = PhoneNumber:new('1234567890')
    assert.are.equals('(123) 456-7890', tostring(phone))
  end)
end)

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.179 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.178 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.177 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.176 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.175 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.174 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.173 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.172 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.171 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.170 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.169 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.167 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.166 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.165 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.164 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.163 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.162 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.161 tracks/lua/exercises/phone-number/phone-number_spec.lua
trackler-2.2.1.160 tracks/lua/exercises/phone-number/phone-number_spec.lua