forked from jackocnr/intl-tel-input
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
141 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use strict"; | ||
|
||
describe("isPossibleNumber:", function() { | ||
|
||
beforeEach(function() { | ||
intlSetup(true); | ||
input = $("<input>").wrap("div"); | ||
}); | ||
|
||
afterEach(function() { | ||
intlTeardown(); | ||
}); | ||
|
||
|
||
|
||
describe("init plugin and call public method isPossibleNumber", function() { | ||
|
||
beforeEach(function() { | ||
iti = window.intlTelInput(input[0]); | ||
}); | ||
|
||
it("returns true for: valid intl number", function() { | ||
iti.setNumber("+44 7733 123456"); | ||
expect(iti.isPossibleNumber()).toBeTruthy(); | ||
}); | ||
|
||
it("returns true for: possible but invalid (bad dial code) intl number", function() { | ||
iti.setNumber("+44 9999 123456"); | ||
expect(iti.isPossibleNumber()).toBeTruthy(); | ||
}); | ||
|
||
it("returns false for: invalid (too short by 2 digits) intl number", function() { | ||
iti.setNumber("+44 7733 1234"); | ||
expect(iti.isPossibleNumber()).toBeFalsy(); | ||
}); | ||
|
||
// guess this is a quirk of UK phone numbers that some valid ones are only 10 digits (e.g. 0773312345) | ||
it("returns true for: invalid (too short by 1 digit) intl number", function() { | ||
iti.setNumber("+44 7733 12345"); | ||
expect(iti.isPossibleNumber()).toBeTruthy(); | ||
}); | ||
|
||
it("returns false for: invalid (too long) intl number", function() { | ||
iti.setNumber("+44 7733 1234567"); | ||
expect(iti.isPossibleNumber()).toBeFalsy(); | ||
}); | ||
|
||
it("returns null when utils script is not available", function() { | ||
delete window.intlTelInputUtils; | ||
iti.setNumber("+44 7733 123456"); | ||
expect(iti.isPossibleNumber()).toBeNull(); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains 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