(t *testing.T)
| 698 | } |
| 699 | |
| 700 | func TestBindDbx(t *testing.T) { |
| 701 | app, _ := tests.NewTestApp() |
| 702 | defer app.Cleanup() |
| 703 | |
| 704 | vm := goja.New() |
| 705 | vm.Set("db", app.DB()) |
| 706 | BindCore(vm) |
| 707 | BindDbx(vm) |
| 708 | |
| 709 | testBindsCount(vm, "$dbx", 15, t) |
| 710 | |
| 711 | sceneraios := []struct { |
| 712 | js string |
| 713 | expected string |
| 714 | }{ |
| 715 | { |
| 716 | `$dbx.exp("a = 1").build(db, {})`, |
| 717 | "a = 1", |
| 718 | }, |
| 719 | { |
| 720 | `$dbx.hashExp({ |
| 721 | "a": 1, |
| 722 | b: null, |
| 723 | c: [1, 2, 3], |
| 724 | }).build(db, {})`, |
| 725 | "`a`={:p0} AND `b` IS NULL AND `c` IN ({:p1}, {:p2}, {:p3})", |
| 726 | }, |
| 727 | { |
| 728 | `$dbx.not($dbx.exp("a = 1")).build(db, {})`, |
| 729 | "NOT (a = 1)", |
| 730 | }, |
| 731 | { |
| 732 | `$dbx.and($dbx.exp("a = 1"), $dbx.exp("b = 2")).build(db, {})`, |
| 733 | "(a = 1) AND (b = 2)", |
| 734 | }, |
| 735 | { |
| 736 | `$dbx.or($dbx.exp("a = 1"), $dbx.exp("b = 2")).build(db, {})`, |
| 737 | "(a = 1) OR (b = 2)", |
| 738 | }, |
| 739 | { |
| 740 | `$dbx.in("a", 1, 2, 3).build(db, {})`, |
| 741 | "`a` IN ({:p0}, {:p1}, {:p2})", |
| 742 | }, |
| 743 | { |
| 744 | `$dbx.notIn("a", 1, 2, 3).build(db, {})`, |
| 745 | "`a` NOT IN ({:p0}, {:p1}, {:p2})", |
| 746 | }, |
| 747 | { |
| 748 | `$dbx.like("a", "test1", "test2").match(true, false).build(db, {})`, |
| 749 | "`a` LIKE {:p0} AND `a` LIKE {:p1}", |
| 750 | }, |
| 751 | { |
| 752 | `$dbx.orLike("a", "test1", "test2").match(false, true).build(db, {})`, |
| 753 | "`a` LIKE {:p0} OR `a` LIKE {:p1}", |
| 754 | }, |
| 755 | { |
| 756 | `$dbx.notLike("a", "test1", "test2").match(true, false).build(db, {})`, |
| 757 | "`a` NOT LIKE {:p0} AND `a` NOT LIKE {:p1}", |
nothing calls this directly
no test coverage detected
searching dependent graphs…