How to use the is.instance function in is

To help you get started, we’ve selected a few is examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-firestore / test / timestamp.js View on Github external
it('constructed using helper', function() {
    assert.ok(is.instance(Firestore.Timestamp.now(), Firestore.Timestamp));

    let actual = Firestore.Timestamp.fromDate(new Date(123123));
    let expected = new Firestore.Timestamp(123, 123000000);
    assert.ok(actual.isEqual(expected));

    actual = Firestore.Timestamp.fromMillis(123123);
    expected = new Firestore.Timestamp(123, 123000000);
    assert.ok(actual.isEqual(expected));
  });
github googleapis / nodejs-firestore / test / index.js View on Github external
it('returns collection', function() {
    let collection = firestore.collection('col1/doc1/col2');
    assert.ok(is.instance(collection, CollectionReference));
  });
github googleapis / nodejs-firestore / test / collection.js View on Github external
return promise.then(documentRef => {
        assert.ok(is.instance(documentRef, DocumentReference));
        assert.equal(collectionRef.id, 'collectionId');
        assert.ok(documentRef.id.length, 20);
      });
    });
github googleapis / nodejs-firestore / test / collection.js View on Github external
}, /Argument "documentPath" is not a valid ResourcePath. Path must be a non-empty string./);

    assert.throws(() => {
      collectionRef.doc('');
    }, /Argument "documentPath" is not a valid ResourcePath. Path must be a non-empty string./);

    assert.throws(() => {
      collectionRef.doc(undefined);
    }, /Argument "documentPath" is not a valid ResourcePath. Path must be a non-empty string./);

    assert.throws(function() {
      collectionRef.doc('doc/coll');
    }, /Argument "documentPath" must point to a document, but was "doc\/coll". Your path does not contain an even number of components\./);

    documentRef = collectionRef.doc('docId/colId/docId');
    assert.ok(is.instance(documentRef, DocumentReference));
  });
github googleapis / nodejs-firestore / test / query.js View on Github external
setImmediate(function() {
    for (let arg of args) {
      if (is.instance(arg, Error)) {
        stream.destroy(arg);
        return;
      }
      stream.push(arg);
    }
    stream.push(null);
  });
github googleapis / nodejs-firestore / test / collection.js View on Github external
return createInstance(overrides).then(firestore => {
      let collectionRef = firestore.collection('collectionId');
      assert.ok(collectionRef.add);
      let promise = collectionRef.add({});
      assert.ok(is.instance(promise, Promise));

      return promise.then(documentRef => {
        assert.ok(is.instance(documentRef, DocumentReference));
        assert.equal(collectionRef.id, 'collectionId');
        assert.ok(documentRef.id.length, 20);
      });
    });
  });
github googleapis / nodejs-firestore / test / index.js View on Github external
setImmediate(function() {
    for (let arg of args) {
      if (is.instance(arg, Error)) {
        stream.destroy(arg);
        return;
      }
      stream.push(arg);
    }
    stream.push(null);
  });
github googleapis / nodejs-firestore / test / document.js View on Github external
setImmediate(function() {
    for (let arg of args) {
      if (is.instance(arg, Error)) {
        stream.destroy(arg);
        return;
      }
      stream.push(arg);
    }
    stream.push(null);
  });
github firebase / user-privacy / functions / node_modules / @google-cloud / firestore / src / transaction.js View on Github external
get(refOrQuery) {
    if (!this._writeBatch.isEmpty) {
      throw new Error(
        'Firestore transactions require all reads to be ' +
          'executed before all writes.'
      );
    }

    if (is.instance(refOrQuery, DocumentReference)) {
      return this._firestore
        .getAll_([refOrQuery], {transactionId: this._transactionId})
        .then(res => {
          return Promise.resolve(res[0]);
        });
    }

    if (is.instance(refOrQuery, Query)) {
      return refOrQuery._get({transactionId: this._transactionId});
    }

    throw new Error('Argument "refOrQuery" must be a DocumentRef or a Query.');
  }
github googleapis / nodejs-firestore / dev / src / transaction.ts View on Github external
get(refOrQuery) {
    if (!this._writeBatch.isEmpty) {
      throw new Error(READ_AFTER_WRITE_ERROR_MSG);
    }

    if (is.instance(refOrQuery, DocumentReference)) {
      return this._firestore
          .getAll_([refOrQuery], this._requestTag, this._transactionId)
          .then(res => {
            return Promise.resolve(res[0]);
          });
    }

    if (is.instance(refOrQuery, Query)) {
      return refOrQuery._get(this._transactionId);
    }

    throw new Error('Argument "refOrQuery" must be a DocumentRef or a Query.');
  }

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis