Software /
code /
prosody
Changeset
10711:d2e4584ba7b3
spec: Add test cases for util.http.contains_token
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 10 Apr 2020 20:20:14 +0200 |
parents | 10710:549e408bab14 |
children | 10712:dc24a8783c5d |
files | spec/util_http_spec.lua |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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);