it("should generate triples", function() {
    let gp = new gpatterns.TreeGraphPattern("?root");

    gp.branch("disco:id", "?id");
    gp.branch("disco:content", "?cnt").branch("disco:id", "?cntid");

    assert.includeDeepMembers(gp.getDirectTriples(), [[ "?root", "disco:id", "?id" ]]);
    assert.includeDeepMembers(gp.getDirectTriples(), [[ "?root", "disco:content", "?cnt" ]]);
    assert.includeDeepMembers(gp.branch("disco:content")[0].getDirectTriples(), [[ "?cnt", "disco:id", "?cntid" ]]);
  });
  it("should expand the first depth level", function() {
    let expandTree = { Content: {} };
    let mapping = mhelper.createStructuredMapping("?post");
    let gp = createExpandPatternStrategy().create(schema.getEntityType("Post"), expandTree, mapping);

    assert.strictEqual(mapping.getComplexProperty("Content").elementaryPropertyExists("Id"), true);
    assert.strictEqual(gp.getUnionPatterns().length > 0, true);
    assert.includeDeepMembers(gp.getUnionPatterns()[1].getDirectTriples(),
      [[ "?post", "disco:content", mapping.getComplexProperty("Content").getVariable() ]]);
    assert.includeDeepMembers(gp.getUnionPatterns()[1].branch("disco:content")[0].getDirectTriples(),
      [[ mapping.getComplexProperty("Content").getVariable(), "disco:id",
      mapping.getComplexProperty("Content").getElementaryPropertyVariable("Id") ]]);
    assert.includeDeepMembers(gp.getDirectTriples(),
      [[ "?post", "disco:id", mapping.getElementaryPropertyVariable("Id") ]]);
  });
  it("should allow optional branches", function() {
    let gp = new gpatterns.TreeGraphPattern("?root");

    gp.optionalBranch("disco:id", "?id");

    assert.includeDeepMembers(gp.getOptionalPatterns()[0].getDirectTriples(), [[ "?root", "disco:id", "?id" ]]);
  });
  it("should allow me to merge with other trees", function() {
    let gp = new gpatterns.TreeGraphPattern("?root");
    let other = new gpatterns.TreeGraphPattern("?root");

    other.branch("disco:id", "?id");
    gp.merge(other);

    assert.includeDeepMembers(gp.getDirectTriples(), [[ "?root", "disco:id", "?id" ]]);
  });
  it("should allow me to integrate other trees as optional branches", function() {
    let gp = new gpatterns.TreeGraphPattern("?root");
    let inner = new gpatterns.TreeGraphPattern("?inner");

    inner.branch("disco:id", "?id");
    gp.optionalBranch("disco:inner", inner);

    assert.includeDeepMembers(gp.getOptionalPatterns()[0].getDirectTriples(), [[ "?root", "disco:inner", "?inner" ]]);
    assert.deepEqual(gp.getOptionalPatterns()[0].branch("disco:inner")[0], inner);
  });
Пример #6
0
        .run(err => {
          if (err) throw err;

          let pkg = JSON.parse(readFile(this.cwd, 'my-app/package.json'));
          assert.propertyVal(pkg, 'description', 'Foo "bar"');
          assert.deepPropertyVal(pkg, 'repository.url', 'http://www.example.com/foo.git?bar=%22baz%22');
          assert.propertyVal(pkg, 'author', 'Foo "Bar" Baz <*****@*****.**>');

          let cargo = TOML.parse(readFile(this.cwd, 'my-app/native/Cargo.toml'));
          assert.includeDeepMembers(cargo.package.authors, ['Foo "Bar" Baz <*****@*****.**>'])

          done();
        });
Пример #7
0
export function assertMigrationCount(
  migrationCount: number,
  sqlsCount = migrationCount
) {
  assert.ok(
    fs.existsSync(path.join(__dirname, '..', '..', 'migrations')),
    './migrations folder exists'
  );
  let migrationsFiles = fs.readdirSync(
    path.join(__dirname, '..', '..', 'migrations')
  );
  assert.ok(
    fs.existsSync(path.join(__dirname, '..', '..', 'migrations', 'sqls')),
    './sqls folder exists'
  );
  assert.includeDeepMembers(
    migrationsFiles,
    ['sqls', '20171203034929-first.ts'],
    './migrations folder contains sqls folder and first migration'
  );
  assert.isAtLeast(
    migrationsFiles.length,
    migrationCount,
    `There are at least ${migrationCount} things in the ./migrations folder`
  );
  let migrationsSqlsFiles = fs.readdirSync(
    path.join(__dirname, '..', '..', 'migrations', 'sqls')
  );
  assert.isAtLeast(
    migrationsSqlsFiles.length,
    sqlsCount,
    `There are at least ${sqlsCount} things in the ./migrations/sqls folder`
  );
  let downMigrationCount = 0;
  let upMigrationCount = 0;
  migrationsSqlsFiles.forEach(fileName => {
    if (fileName.includes('-down')) {
      downMigrationCount++;
    }
    if (fileName.includes('-up')) {
      upMigrationCount++;
    }
  });
}
  it("should allow value leaves", function() {
    let gp = new gpatterns.TreeGraphPattern("?root");
    gp.branch("disco:id", new gpatterns.ValueLeaf("1"));

    assert.includeDeepMembers(gp.getDirectTriples(), [[ "?root", "disco:id", "\"1\""]]);
  });