// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`viewBuilder Calculate and filter creates a view with the calculation statistics and filter schema 1`] = `
Object {
  "map": "function (doc) {
      if ((doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" && !(
      doc[\\"myField\\"] === undefined ||
      doc[\\"myField\\"] === null ||
      doc[\\"myField\\"] === \\"\\" ||
      (Array.isArray(doc[\\"myField\\"]) && doc[\\"myField\\"].length === 0)
  )) && (doc[\\"age\\"] > 17)) {
        emit(doc[\\"_id\\"], doc[\\"myField\\"]);
      }
    }",
  "meta": Object {
    "calculation": "stats",
    "field": "myField",
    "filters": Array [
      Object {
        "condition": "MT",
        "key": "age",
        "value": 17,
      },
    ],
    "groupBy": undefined,
    "schema": Object {
      "avg": Object {
        "type": "number",
      },
      "count": Object {
        "type": "number",
      },
      "field": Object {
        "type": "string",
      },
      "max": Object {
        "type": "number",
      },
      "min": Object {
        "type": "number",
      },
      "sum": Object {
        "type": "number",
      },
      "sumsqr": Object {
        "type": "number",
      },
    },
    "tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
  },
  "reduce": "_stats",
}
`;

exports[`viewBuilder Calculate creates a view with the calculation statistics schema 1`] = `
Object {
  "map": "function (doc) {
      if ((doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" && !(
      doc[\\"myField\\"] === undefined ||
      doc[\\"myField\\"] === null ||
      doc[\\"myField\\"] === \\"\\" ||
      (Array.isArray(doc[\\"myField\\"]) && doc[\\"myField\\"].length === 0)
  )) ) {
        emit(doc[\\"_id\\"], doc[\\"myField\\"]);
      }
    }",
  "meta": Object {
    "calculation": "stats",
    "field": "myField",
    "filters": Array [],
    "groupBy": undefined,
    "schema": Object {
      "avg": Object {
        "type": "number",
      },
      "count": Object {
        "type": "number",
      },
      "field": Object {
        "type": "string",
      },
      "max": Object {
        "type": "number",
      },
      "min": Object {
        "type": "number",
      },
      "sum": Object {
        "type": "number",
      },
      "sumsqr": Object {
        "type": "number",
      },
    },
    "tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
  },
  "reduce": "_stats",
}
`;

exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = `
Object {
  "map": "function (doc) {
      if (doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" && (doc[\\"Name\\"] === \\"Test\\" || doc[\\"Yes\\"] > \\"Value\\")) {
        emit(doc[\\"_id\\"], doc[\\"undefined\\"]);
      }
    }",
  "meta": Object {
    "calculation": undefined,
    "field": undefined,
    "filters": Array [
      Object {
        "condition": "EQUALS",
        "key": "Name",
        "value": "Test",
      },
      Object {
        "condition": "MT",
        "conjunction": "OR",
        "key": "Yes",
        "value": "Value",
      },
    ],
    "groupBy": undefined,
    "schema": null,
    "tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
  },
}
`;

exports[`viewBuilder Group By creates a view emitting the group by field 1`] = `
Object {
  "map": "function (doc) {
      if (doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" ) {
        emit(doc[\\"age\\"], doc[\\"score\\"]);
      }
    }",
  "meta": Object {
    "calculation": undefined,
    "field": "score",
    "filters": Array [],
    "groupBy": "age",
    "schema": null,
    "tableId": "14f1c4e94d6a47b682ce89d35d4c78b0",
  },
}
`;
