# HG changeset patch # User Emmanuel Gil Peyrot # Date 1586542814 -7200 # Node ID d2e4584ba7b305c441b9863dee8767d8fa1fed89 # Parent 549e408bab1427934dd126c8742ccfc5908a76a3 spec: Add test cases for util.http.contains_token diff -r 549e408bab14 -r d2e4584ba7b3 spec/util_http_spec.lua --- a/spec/util_http_spec.lua Fri Apr 10 19:03:36 2020 +0200 +++ b/spec/util_http_spec.lua Fri Apr 10 20:20:14 2020 +0200 @@ -89,4 +89,23 @@ assert.equal("/foo/", http.normalize_path("/foo/", true)); end); end); + + describe("contains_token", function () + it("is present in field", function () + assert.is_true(http.contains_token("foo", "foo")); + assert.is_true(http.contains_token("foo, bar", "foo")); + assert.is_true(http.contains_token("foo,bar", "foo")); + assert.is_true(http.contains_token("bar, foo,baz", "foo")); + end); + + it("is absent from field", function () + assert.is_false(http.contains_token("bar", "foo")); + assert.is_false(http.contains_token("fooo", "foo")); + assert.is_false(http.contains_token("foo o,bar", "foo")); + end); + + it("is weird", function () + assert.is_(http.contains_token("fo o", "foo")); + end); + end); end);