From db9887cdae7f1a4f4a057b3d6af0eb857c3ef0bb Mon Sep 17 00:00:00 2001 From: Jack OConnor Date: Sun, 30 Jul 2017 10:28:18 +0100 Subject: [PATCH] fix tests --- src/spec/tests/core/initialValues.js | 47 +++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/spec/tests/core/initialValues.js b/src/spec/tests/core/initialValues.js index b9d6fe490..1295b59ec 100644 --- a/src/spec/tests/core/initialValues.js +++ b/src/spec/tests/core/initialValues.js @@ -56,16 +56,53 @@ describe("initial values:", function() { - describe("init vanilla plugin on input containing valid toll-free (regionless) NANP number with intl dial code", function() { + describe("input containing valid regionless NANP number with intl dial code", function() { beforeEach(function() { input = $(""); - input.intlTelInput(); }); - it("does not set the selected flag or the active list item", function() { - expect(getSelectedFlagElement().attr("class")).toBe("iti-flag"); - expect(getActiveListItem().length).toEqual(0); + describe("init plugin with nationalMode enabled", function() { + + beforeEach(function() { + input.intlTelInput(); + }); + + it("defaults to US flag", function() { + expect(getSelectedFlagElement()).toHaveClass("us"); + }); + + }); + + describe("init plugin with nationalMode enabled and an initialCountry", function() { + + var initialCountry = "ca"; + + beforeEach(function() { + input.intlTelInput({ + initialCountry: initialCountry + }); + }); + + it("defaults to the initialCountry flag", function() { + expect(getSelectedFlagElement()).toHaveClass(initialCountry); + }); + + }); + + describe("init plugin with nationalMode disabled", function() { + + beforeEach(function() { + input.intlTelInput({ + nationalMode: false + }); + }); + + it("does not set the selected flag or the active list item", function() { + expect(getSelectedFlagElement().attr("class")).toBe("iti-flag"); + expect(getActiveListItem().length).toEqual(0); + }); + }); });