summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 11:33:32 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2015-11-24 15:33:17 +0300
commitfff27935f8581be9c2c93cad06f0f2fb1aa3051c (patch)
tree4b2fa0e1b34544636eff790d05eecab01abe5176
parent9c4e25e3d4cb3459fa41c2e749f98660a0b38ef9 (diff)
downloadawesomplete-fff27935f8581be9c2c93cad06f0f2fb1aa3051c.zip
awesomplete-fff27935f8581be9c2c93cad06f0f2fb1aa3051c.tar.gz
awesomplete-fff27935f8581be9c2c93cad06f0f2fb1aa3051c.tar.bz2
Awesomplete.FILTER_CONTAINS tests
-rw-r--r--test/static/filterContainsSpec.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/static/filterContainsSpec.js b/test/static/filterContainsSpec.js
new file mode 100644
index 0000000..f6db514
--- /dev/null
+++ b/test/static/filterContainsSpec.js
@@ -0,0 +1,60 @@
+describe("Awesomplete.FILTER_CONTAINS", function () {
+
+ subject(function () { return Awesomplete.FILTER_CONTAINS });
+
+ it("is a function", function () {
+ expect(this.subject).toEqual(jasmine.any(Function));
+ });
+
+ describe("search in a plain string", function () {
+ it("matches at the start", function () {
+ expect(this.subject("Hello world", "Hello")).toBe(true);
+ });
+
+ it("matches in the middle", function () {
+ expect(this.subject("Ticket to the moon", "to the")).toBe(true);
+ });
+
+ it("matches at the end", function () {
+ expect(this.subject("This is the end", "end")).toBe(true);
+ });
+
+ 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("matches in the middle", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "sc|ri\\p+t*")).toBe(true);
+ });
+
+ it("matches at the end", function () {
+ expect(this.subject("[^j(a)v?a-sc|ri\\p+t*]{.$}", "{.$}")).toBe(true);
+ });
+
+ 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);
+ });
+ });
+});