Created
March 14, 2019 13:59
-
-
Save trafficinc/09ac6bfd3630129078c649f924497984 to your computer and use it in GitHub Desktop.
Address Comp JS
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
// specs code :: Jasmine | |
describe("Address Tests", function() { | |
it("Full Address", function() { | |
var appResponse = { | |
user: { | |
address: "120 Oak Avenue", | |
city: "Philadelphia" | |
} | |
}; | |
var address = appResponse.user.address || ''; | |
var city = appResponse.user.city || ''; | |
var fullAddress = address + (address && city ? ' ' : '') + city; | |
expect(fullAddress).toEqual("120 Oak Avenue Philadelphia"); | |
}); | |
it("No Street", function() { | |
var appResponse = { | |
user: { | |
address: "", | |
city: "Philadelphia" | |
} | |
}; | |
var address = appResponse.user.address || ''; | |
var city = appResponse.user.city || ''; | |
var fullAddress = address + (address && city ? ' ' : '') + city; | |
expect(fullAddress).toEqual("Philadelphia"); | |
}); | |
it("No Address", function() { | |
var appResponse = { | |
user: { | |
address: "", | |
city: "" | |
} | |
}; | |
var address = appResponse.user.address || ''; | |
var city = appResponse.user.city || ''; | |
var fullAddress = address + (address && city ? ' ' : '') + city; | |
expect(fullAddress).toEqual(""); | |
}); | |
it("Undefined value", function() { | |
var appResponse = { | |
user: { | |
address: undefined, | |
city: "Philadelphia" | |
} | |
}; | |
var address = appResponse.user.address || ''; | |
var city = appResponse.user.city || ''; | |
var fullAddress = address + (address && city ? ' ' : '') + city; | |
expect(fullAddress).toEqual("Philadelphia"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment