Last active
August 29, 2015 14:26
-
-
Save GE-N/8c69a0200a40a195aa46 to your computer and use it in GitHub Desktop.
Initial test phone number validate - BDD on swift @Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Phone class part | |
// Phone.swift | |
import Foundation | |
class Phone { | |
class func validateNumber(number: String) -> Bool { | |
return false | |
} | |
} | |
// ==================================================================================== | |
// Test Phone part | |
// PhoneNumberSpec.swift | |
import Quick | |
import Nimble | |
import SMSME | |
class PhoneNumberSpec : QuickSpec { | |
override func spec() { | |
describe("Phone number") { | |
context("Validate") { | |
it("should length equal 10 digit") { | |
expect(Phone.validateNumber("12345")).to(beFalse()) | |
expect(Phone.validateNumber("1234567890")).to(beFalse()) | |
expect(Phone.validateNumber("0811122222")).to(beTrue()) | |
} | |
it("should begins with 08/09") { | |
expect(Phone.validateNumber("998876")).to(beFalse()) | |
expect(Phone.validateNumber("081122")).to(beFalse()) | |
expect(Phone.validateNumber("0811122222")).to(beTrue()) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment