summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 11:34:14 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 15:33:34 +0300
commitc97c34f3b5ccc6540bb7433904cc9b3419f8623f (patch)
tree0006339d1e5ab4d42bed43dc00490e94ae211b6e
parentfff27935f8581be9c2c93cad06f0f2fb1aa3051c (diff)
downloadawesomplete-c97c34f3b5ccc6540bb7433904cc9b3419f8623f.zip
awesomplete-c97c34f3b5ccc6540bb7433904cc9b3419f8623f.tar.gz
awesomplete-c97c34f3b5ccc6540bb7433904cc9b3419f8623f.tar.bz2
Awesomplete.FILTER_STARTSWITH tests
-rw-r--r--test/static/filterStartsWithSpec.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/static/filterStartsWithSpec.js b/test/static/filterStartsWithSpec.js
new file mode 100644
index 0000000..655ee23
--- /dev/null
+++ b/test/static/filterStartsWithSpec.js
@@ -0,0 +1,60 @@
+describe("Awesomplete.FILTER_STARTSWITH", function () {
+
+ subject(function () { return Awesomplete.FILTER_STARTSWITH });
+
+ it("is a function", function () {
+ expect(this.subject).toEqual(jasmine.any(Function));
+ });
+
+ describe("search in plain string", function () {
+ it("matches at the start", function () {
+ expect(this.subject("Hello world", "Hello")).toBe(true);
+ });
+
+ it("does not match in the middle", function () {
+ expect(this.subject("Ticket to the moon", "to the")).toBe(false);
+ });
+
+ it("does not match at the end", function () {
+ expect(this.subject("This is the end", "end")).toBe(false);
+ });
+
+ it("performs case insensitive match", function () {
+ expect(this.subject("Hey You", "HEY YOU")).toBe(true);
+ });
+
+ it("ignores whitespaces around the search value", function () {
+ expect(this.subject("Watch this", " Watch ")).toBe(true);
+ });
+
+ it("does not match if substring is not found", function () {
+ expect(this.subject("No", "way")).toBe(false);
+ });
+ });
+
+ describe("search in string with special RegExp chars", function () {
+ it("matches at the start", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "[^j(a)v?a-")).toBe(true);
+ });
+
+ it("does not match in the middle", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "sc|ri\\p+t*")).toBe(false);
+ });
+
+ it("does not match at the end", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "{.$}")).toBe(false);
+ });
+
+ it("performs case insensitive match", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "[^J(A)V?A-SC|RI\\P+T*]{.$}")).toBe(true);
+ });
+
+ it("ignores whitespaces around the search value", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", " [^j(a)v?a- ")).toBe(true);
+ });
+
+ it("does not match if substring is not found", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "no way")).toBe(false);
+ });
+ });
+});