.then((table: DataTable[]) => {
            let row = table[0].rows[0];

            //    assert.equal(row["guid"], testGuid);
            assert.equal(row["str250"], testStr250);
            assert.equal(row["text"], testText);
            assert.equal(row["sbyte"], testSByte);
            assert.equal(row["byte"], testByte);
            assert.equal(row["short"], testShort);
            assert.equal(row["int"], testInt);
            assert.equal(row["uint"], testUInt);
            assert.equal(row["long"], testLong);

            assert.equal(row["ulong"], testULong);

            assert.isBelow(Math.abs(row["float"] - testFloat), 1e+33);

            assert.equal(row["decimal"], testDecimal);
            assert.equal(row["date"].getTime(), testDate.getTime());
            assert.equal(row["datetime"].getTime(), testDateTime.getTime());

            //console.log({fromDb1: row["double"], test: testDouble, sub: row["double"] - testDouble});
            assert.isBelow(Math.abs(row["double"] - testDouble), 5e+293);

            done();
        })
Пример #2
0
    it("arrayLengthCompare", () => {
        assert.isAbove(Utils.arrayLengthCompare([1, 2], []), 0);
        assert.strictEqual(Utils.arrayLengthCompare([1, 2], [1, 2]), 0);
        assert.isBelow(Utils.arrayLengthCompare([], [1, 2]), 0);

        assert.isAbove(Utils.arrayLengthCompare([1]), 0);
        assert.strictEqual(Utils.arrayLengthCompare(), 0);
        assert.isBelow(Utils.arrayLengthCompare(undefined, [1]), 0);
    });
Пример #3
0
       'if the first ranker does not produce a tie', () => {
        const specM1 = SpecQueryModel.build(
          {
            mark: Mark.POINT,
            encodings: [
              {channel: Channel.X, field: 'Q', type: Type.QUANTITATIVE},
              {channel: Channel.Y, field: 'Q1', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const specM2 = SpecQueryModel.build(
          {
            mark: Mark.POINT,
            encodings: [
              {aggregate: 'mean', channel: Channel.X, field: 'Q', type: Type.QUANTITATIVE},
              {aggregate: 'mean', channel: Channel.Y, field: 'Q1', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const comparator = comparatorFactory(['aggregationQuality', 'effectiveness'], schema, DEFAULT_QUERY_CONFIG);
        assert.isBelow(comparator(specM1, specM2), 0);
      });
Пример #4
0
       'if the first ranker results in a tie', () => {
        const specM1 = SpecQueryModel.build(
          {
            mark: Mark.LINE,
            encodings: [
              {channel: Channel.X, field: 'date', type: Type.TEMPORAL, timeUnit: TimeUnit.DAY},
              {aggregate: 'mean', channel: Channel.Y, field: 'price', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const specM2 = SpecQueryModel.build(
          {
            mark: Mark.POINT,
            encodings: [
              {channel: Channel.X, field: 'date', type: Type.TEMPORAL, timeUnit: TimeUnit.DAY},
              {aggregate: 'mean', channel: Channel.Y, field: 'price', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const comparator = comparatorFactory(['aggregationQuality', 'effectiveness'], schema, DEFAULT_QUERY_CONFIG);
        assert.isBelow(comparator(specM1, specM2), 0);
      });
Пример #5
0
      it('should create a comparator that correctly sorts two spec when passed an orderBy string of aggregationQuality', () => {
        const specM1 = SpecQueryModel.build(
          {
            mark: Mark.POINT,
            encodings: [
              {channel: Channel.X, field: 'Q', type: Type.QUANTITATIVE},
              {channel: Channel.Y, field: 'Q1', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const specM2 = SpecQueryModel.build(
          {
            mark: Mark.POINT,
            encodings: [
              {aggregate: 'mean', channel: Channel.X, field: 'Q', type: Type.QUANTITATIVE},
              {aggregate: 'mean', channel: Channel.Y, field: 'Q1', type: Type.QUANTITATIVE},
            ]
          },
          schema,
          DEFAULT_QUERY_CONFIG
        );

        const comparator = comparatorFactory('aggregationQuality', schema, DEFAULT_QUERY_CONFIG);
        assert.isBelow(comparator(specM1, specM2), 0);
      });
Пример #6
0
        function* infiniteCounter() {
            let c = 0;
            while (true) {
                assert.isBelow(c, 6, 'Iterated more than 5 times.');

                yield c++;
            }
        }
Пример #7
0
 return safe.nfs.getDir(client, { dirPath: topLevelPath, isPathShared: scenario.shared }).then(resp => {
   assert.lengthOf(resp.subDirectories, 0)
   assert.lengthOf(resp.files, 1)
   assert.equal(resp.files[0].name, fileName)
   assert.equal(resp.files[0].size, 0)
   // Is in the past 20 seconds?
   assert.isBelow(resp.files[0].createdOn, Date.now())
   assert.isAbove(resp.files[0].createdOn, Date.now() - (20 * 1000))
 })
Пример #8
0
 return safe.nfs.getDir(client, { dirPath: '/', isPathShared: scenario.shared }).then(resp => {
   const foundDir = resp.subDirectories.find(dir => dir.name == topLevelName)
   assert.isNotNull(foundDir)
   assert.equal(foundDir.isPrivate, scenario.private)
   assert.equal(foundDir.metadata, '')
   assert.equal(foundDir.createdOn, foundDir.modifiedOn)
   // Is in the past 20 seconds?
   assert.isBelow(foundDir.createdOn, Date.now())
   assert.isAbove(foundDir.createdOn, Date.now() - (20 * 1000))
 })
  @test('getAllProducts with flavor filter: sweet>2 spicy>2')
  public async sweetHotFilter() {
    await updateProduct(1, {
      metadata: {
        flavor: { sweet: 5, sour: 5, bitter: 5, salty: 5, spicy: 5 }
      },
      tags: []
    });

    let allResults = await getAllProducts();
    let sweetHotResults = await getAllProducts({
      filter: {
        flavor: [
          { flavorName: 'spicy', type: 'greater-than', level: 2 },
          { flavorName: 'sweet', type: 'greater-than', level: 2 }
        ]
      }
    });
    assert.isAbove(
      sweetHotResults.length,
      0,
      'Nonzezro number of sweetHotResults'
    );
    assert.isBelow(
      sweetHotResults.length,
      allResults.length,
      'Sweet-hot products are a subset of all products'
    );
    assert.ok(
      sweetHotResults.every(
        p =>
          p.metadata &&
          p.metadata.flavor &&
          p.metadata.flavor.sweet > 2 &&
          p.metadata.flavor.spicy > 2
      ),
      'All results from sweet-hot filter have sweet > 2 and spicy > 2'
    );
    assert.ok(
      differenceWith(
        allResults,
        sweetHotResults,
        (a: any, b: any) => a.id === b.id
      ).every(
        p =>
          !p.metadata ||
          p.metadata.flavor.sweet <= 2 ||
          p.metadata.flavor.spicy <= 2
      ),
      'All results excluded by sweet-hot filter have sweet <= 2 OR spicy <= 2'
    );
  }
 @test('getAllProducts with flavor filter: sweet>2 sour>2')
 public async sweetSourFilter() {
   let allResults = await getAllProducts();
   let sweetSourResults = await getAllProducts({
     filter: {
       flavor: [
         { flavorName: 'sour', type: 'greater-than', level: 2 },
         { flavorName: 'sweet', type: 'greater-than', level: 2 }
       ]
     }
   });
   assert.isBelow(
     sweetSourResults.length,
     allResults.length,
     'Sweet-sour products are a subset of all products'
   );
   assert.ok(
     sweetSourResults.every(
       p =>
         p &&
         p.metadata &&
         p.metadata.flavor &&
         p.metadata.flavor.sweet > 2 &&
         p.metadata.flavor.sour > 2
     ),
     'All results from sweet-sour filter have sweet > 2 and sour > 2'
   );
   assert.ok(
     differenceWith(
       allResults,
       sweetSourResults,
       (a: any, b: any) => a.id === b.id
     ).every(
       p =>
         !p ||
         !p.metadata ||
         !p.metadata.flavor ||
         (p.metadata.flavor.sweet <= 2 || p.metadata.flavor.sour <= 2)
     ),
     'All results excluded by sweet-sour filter have sweet <= 2 OR sour <= 2'
   );
 }