diff --git a/Sources/LicenseParser/FieldParser.swift b/Sources/LicenseParser/FieldParser.swift index 66e0d66..5e45b0b 100755 --- a/Sources/LicenseParser/FieldParser.swift +++ b/Sources/LicenseParser/FieldParser.swift @@ -265,7 +265,8 @@ public class FieldParser: FieldParsing { - Returns: An optional value parsed out of the raw data */ public func parseMiddleName() -> String? { - return parseString(key: "middleName") + let middleName = parseString(key: "middleName") + return middleName?.caseInsensitiveCompare("NONE") == .orderedSame ? nil : middleName } /** diff --git a/Tests/LicenseParserTests/DriverLicenseNameSpec.swift b/Tests/LicenseParserTests/DriverLicenseNameSpec.swift index 561f381..d321aac 100644 --- a/Tests/LicenseParserTests/DriverLicenseNameSpec.swift +++ b/Tests/LicenseParserTests/DriverLicenseNameSpec.swift @@ -25,5 +25,14 @@ class DriverLicenseNameSpec: QuickSpec{ expect(result.suffix).to(equal(.second)) } } + + describe("when the middle name is not present") { + it("should return nil") { + let sut = Parser(data: "DADNONE") + let result = sut.parse() + + expect(result.middleName).to(beNil()) + } + } } }