fixed tests
This commit is contained in:
@@ -48,12 +48,12 @@ describe("$filter", () => {
|
||||
it("should support 'not'", () => {
|
||||
// REVISIT: We need to check with the Node.js team why they translated that to the equivalent of:
|
||||
// not name like concat('%','sunny','%') escape '^'
|
||||
expect (OData(`Foo?$filter = not contains(name,'sunny')`))
|
||||
expect (OData(`Foo?$filter= not contains(name,'sunny')`))
|
||||
.to.eql (CQL(`SELECT from Foo where not name like '%sunny%'`))
|
||||
});
|
||||
|
||||
it("should support group expr", () => {
|
||||
expect (OData(`Foo?$filter = (unitPrice lt 11 and length(name) eq 12) or name eq 'Restless and Wild'`))
|
||||
expect (OData(`Foo?$filter= (unitPrice lt 11 and length(name) eq 12) or name eq 'Restless and Wild'`))
|
||||
.to.eql (CQL(`SELECT from Foo where (unitPrice < 11 and length(name) = 12) or name = 'Restless and Wild'`))
|
||||
});
|
||||
});
|
||||
@@ -61,47 +61,47 @@ describe("$filter", () => {
|
||||
describe("function expressions", () => {
|
||||
|
||||
it("should support contains", () => {
|
||||
expect (OData(`Foo?$filter = contains(name,'sunny')`))
|
||||
expect (OData(`Foo?$filter= contains(name,'sunny')`))
|
||||
.to.eql (CQL(`SELECT from Foo where name like '%sunny%'`))
|
||||
});
|
||||
|
||||
it("should support startswith", () => {
|
||||
expect (OData(`Foo?$filter = startswith(name,'sunny')`))
|
||||
expect (OData(`Foo?$filter= startswith(name,'sunny')`))
|
||||
.to.eql (CQL(`SELECT from Foo where name like 'sunny%'`))
|
||||
});
|
||||
|
||||
it("should support endswith", () => {
|
||||
expect (OData(`Foo?$filter = endswith(name,'sunny')`))
|
||||
expect (OData(`Foo?$filter= endswith(name,'sunny')`))
|
||||
.to.eql (CQL(`SELECT from Foo where name like '%sunny'`))
|
||||
});
|
||||
|
||||
it("should support length", () => {
|
||||
expect (OData(`Foo?$filter = length(name) lt 11`))
|
||||
expect (OData(`Foo?$filter= length(name) lt 11`))
|
||||
.to.eql (CQL(`SELECT from Foo where length(name) < 11`))
|
||||
});
|
||||
|
||||
it("should support indexof", () => {
|
||||
expect (OData(`Foo?$filter = indexof(name,'x') eq 11`))
|
||||
.to.eql (CQL(`SELECT from Foo where locate(name,'x') = 12`))
|
||||
expect (OData(`Foo?$filter= indexof(name,'x') eq 11`))
|
||||
.to.eql (CQL(`SELECT from Foo where locate(name,'x') = 11`))
|
||||
});
|
||||
|
||||
it("should support substring", () => {
|
||||
expect (OData(`Foo?$filter = substring(name,1) eq 'foo'`))
|
||||
.to.eql (CQL(`SELECT from Foo where substring(name,2) = 'foo'`))
|
||||
expect (OData(`Foo?$filter= substring(name,1) eq 'foo'`))
|
||||
.to.eql (CQL(`SELECT from Foo where substring(name,1) = 'foo'`))
|
||||
});
|
||||
|
||||
it.each(['tolower','toupper','trim'])("should support '%s'", (fn) => {
|
||||
expect (OData(`Foo?$filter = ${fn}(name) eq 'foo'`))
|
||||
expect (OData(`Foo?$filter= ${fn}(name) eq 'foo'`))
|
||||
.to.eql (CQL(`SELECT from Foo where ${fn.replace(/^to/,'')}(name) = 'foo'`))
|
||||
});
|
||||
|
||||
it("should support 'day'", () => {
|
||||
expect (OData(`Foo?$filter = day(name) eq 11`))
|
||||
expect (OData(`Foo?$filter= day(name) eq 11`))
|
||||
.to.eql (CQL(`SELECT from Foo where dayofmonth(name) = 11`))
|
||||
});
|
||||
|
||||
it("should support concat", () => {
|
||||
expect (OData(`Foo?$filter = concat(name,'o') eq 'foo'`))
|
||||
expect (OData(`Foo?$filter= concat(name,'o') eq 'foo'`))
|
||||
.to.eql (CQL(`SELECT from Foo where concat(name,'o') = 'foo'`))
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user