Example #1
0
		it('should return identical hash for same object', () => {
			var ori = xm.jsonToIdent(valueA);
			var alt = xm.jsonToIdent(valueA);
			assert.isString(ori, 'ori');
			assert.isString(alt, 'alt');
			assert.strictEqual(ori, alt);
		});
Example #2
0
		it('exports packageInfo', () => {
			assert.isObject(ctx.packageInfo, 'packageInfo');
			assert.instanceOf(ctx.packageInfo, xm.PackageJSON, 'config');
			assert.isString(ctx.packageInfo.name, 'name');
			assert.isString(ctx.packageInfo.version, 'version');
			assert.isObject(ctx.packageInfo.raw, 'pkg');
		});
Example #3
0
		it('exports config', () => {
			assert.isObject(ctx.config, 'config');
			assert.instanceOf(ctx.config, tsd.Config, 'config');
			assert.isString(ctx.config.path, 'path');
			assert.isString(ctx.config.version, 'version');
			assert.isString(ctx.config.repo, 'repo');
			assert.isString(ctx.config.ref, 'ref');
			// assert.isObject(ctx.config.installed, 'installed');
		});
Example #4
0
		it('should return same hash for similar objects', () => {
			var valueA = {a: 1, b: 2, c: 3};
			var valueB = {b: 2, c: 3, a: 1};
			var hashA = xm.jsonToIdentHash(valueA, 16);
			var hashB = xm.jsonToIdentHash(valueB, 16);
			var expected = 'e47fb2071f83fdce';
			assert.lengthOf(hashA, 16, 'hashA');
			assert.lengthOf(hashB, 16, 'hashA');
			assert.isString(hashA, 'hashA');
			assert.isString(hashB, 'hashB');
			assert.strictEqual(hashA, hashB, 'equal');
			assert.strictEqual(hashA, expected, 'preset hash');
		});
Example #5
0
export function assertPin(pin: IPin, type?: PIN_TYPE) {
  assert.isObject(pin);
  assertNotEmptyString(pin.type);

  if (type) {
    assert.strictEqual(pin.type, type);
  }

  assertNotEmptyString(pin.name);
  assertCoords(pin.coords);

  if (pin.type === PIN_TYPE.platform) {
    assert.isString(pin.id);
    assertNotEmptyString(pin.platform_nr);
  } else {
    assertNotEmptyString(pin.id);
    assert.isUndefined(pin.platform_nr);
  }

  if (pin.type === PIN_TYPE.stop) {
    assert.isArray(pin.connections);
    if (pin.name !== "Ebertplatz") {
      assert.isNotEmpty(pin.connections);
    }
    pin.connections!.forEach(assertConnection);
  } else {
    assert.isUndefined(pin.connections);
  }

  if (pin.type === PIN_TYPE.parkandride) {
    assertNotEmptyString(pin.info);
  } else {
    assert.isUndefined(pin.info);
  }
}
Example #6
0
			var actual = xm.reduceHash(input, [], (memo:number[], elem:number, prop:string, collection) => {
				memo = memo.slice(0);
				memo.push(elem * elem);
				assert.isString(prop, 'prop');
				assert.equal(input, collection, 'collection');
				return memo;
			});
Example #7
0
 response.forEach((data) => {
   assertPoint(data);
   assert.include(data.name, "Frauenkirche");
   assert.strictEqual(data.city, "Dresden");
   assert.isString(data.id);
   assertCoords(data.coords);
   assert.oneOf(data.type, Object.keys(dvb.POI_TYPE));
 });
Example #8
0
	function getInfo(name:string):helper.HttpTest {
		assert.isString(name, 'name');
		var info = new helper.HttpTest();
		info.storeTmpDir = path.join(helper.getDirNameTmp(), name);
		info.storeFixtureDir = path.join(helper.getDirNameFixtures(), name);
		info.wwwHTTP = 'http://localhost:9090/';
		info.wwwDir = path.resolve(helper.getDirNameTmp(), '..', 'www');
		return info;
	}
        it('should return some proper html', function () {
            const html = ServerRenderer.render(store.createDefault({log: false}));

            assert.isString(html, "The rendered HTML needs to be a string");
            assert.include(html, '<div', 'rendered HTML contains at least an open div');
            assert.include(html, '</div>', 'rendered HTML contains at least an closed div');

            // TODO: Make assumptions about the state in store.getState();
        });
Example #10
0
function assertNode(node: INode) {
  assert.isString(node.direction);
  assert.isNumber(node.duration);

  assertMode(node.mode);

  if (
    node.mode.name !== "Footpath" &&
    node.mode.name !== "StayForConnection" &&
    node.mode.name.indexOf("Stairs") === -1
  ) {
    assert.isDefined(node.diva);
    assertDiva(node.diva!);
    assertNotEmptyString(node.line);
  } else {
    assert.isUndefined(node.diva);
    assert.isString(node.line);
  }

  if (
    (node.mode.name === "Footpath" && !node.departure) ||
    node.mode.name.indexOf("Stairs") > -1
  ) {
    assert.isUndefined(node.departure);
    assert.isUndefined(node.arrival);
    assert.isArray(node.stops);
    assert.isEmpty(node.stops);
  } else {
    assertStopLocation(node.departure!);
    assertStopLocation(node.arrival!);

    assert.isArray(node.stops);
    assert.isNotEmpty(node.stops);
    node.stops.forEach(assertStop);
  }

  assert.isArray(node.path);
  if (node.mode.name !== "StayForConnection") {
    assert.isNotEmpty(node.path);
    node.path.forEach(assertCoords);
  } else {
    assert.isEmpty(node.path);
  }
}