Esempio n. 1
0
  it('with schema', function(done) {
    var o = Object.create(null);
    o.name = String;
    o.created = Date;
    o.nested = Object.create(null);
    o.nested.n = Number;

    assert.doesNotThrow(function() {
      new Schema(o);
    });

    assert.doesNotThrow(function() {
      var s = new Schema;
      var o = Object.create(null);
      o.yay = Number;
      s.path('works', o);
    });

    assert.doesNotThrow(function() {
      var s = new Schema;
      var o = Object.create(null);
      o = {};
      o.name = String;
      var x = {type: [o]};
      s.path('works', x);
    });

    done();
  });
Esempio n. 2
0
    it('that do not conflict do not throw', function(done) {
      assert.doesNotThrow(function() {
        new Schema({
          model: String
        });
      });

      assert.doesNotThrow(function() {
        Schema({child: [{parent: String}]});
      });

      assert.doesNotThrow(function() {
        Schema({child: [{parentArray: String}]});
      });

      assert.doesNotThrow(function() {
        var s = new Schema({docs: [{path: String}]});
        var M = mongoose.model('gh-1245', s);
        new M({docs: [{path: 'works'}]});
      });

      assert.doesNotThrow(function() {
        var s = new Schema({setMaxListeners: String});
        var M = mongoose.model('setMaxListeners-as-property-name', s);
        new M({setMaxListeners: 'works'});
      });

      done();
    });
                callback("test", function() {
                    called = true;

                    clearTimeout(checkTimeout);

                    assert.doesNotThrow(function() {
                        filesystem.accessSync("tests/build/images.css", filesystem.F_OK);
                    }, "The images file should exists!");

                    assert.doesNotThrow(function() {
                        filesystem.accessSync("tests/build/images.png", filesystem.F_OK);
                    }, "The images file should exists!");
                });
      it('should use logError callback if no callback specified', function (done) {
        var scope = nock('https://www.googleapis.com')
          .get('/drive/v2/files?q=hello')
          .times(2)
          .reply(501, { error: 'not a real error' });

        // logError internally uses console.error - let's monkey-patch the
        // function to intercept calls to it, then restore the original function
        // once we are done testing
        var origFn = console.error;
        var count = 0;
        console.error = function (err) {
          count++;
          assert.equal(err.code, 501);
          if (count === 2) {
            console.error = origFn;
            scope.done();
            done();
          }
        };

        assert.doesNotThrow(function () {
          localDrive.files.list({ q: 'hello' });
          remoteDrive.files.list({ q: 'hello' });
        });
      });
Esempio n. 5
0
 it("Basic workflow with #setInterfaces(), #setImplementaions(), and .api", (done) => {
   // no api
   assert(!proxy.api["*"]);
   // register interfaces
   proxy.setInterfaces(interfaces);
   assert(proxy.api["*"]);
   assert(proxy.api["*"].hello);
   // but not implemented
   assert.throws(() => {
     proxy.api["*"].hello("world");
   });
   // register implementations
   proxy.setImplementations(implementations);
   // now implemented
   assert.doesNotThrow(() => {
     proxy.api["*"].hello("world");
   });
   // return value is just a Promise.
   proxy.api["*"].hello("world").then((result) => {
     assert(result === "hello world");
     // with co
     co(function *() {
       let result = yield proxy.api.math.add(1, 2);
       assert(result === 3);
       done();
     });
   });
 });
Esempio n. 6
0
    it('allow not passing a callback', function(done) {
      var db = start(),
          MR = db.model('MapReduce', collection);

      var o = {
        map: function() {
          emit(this.author, 1);
        },
        reduce: function(k, vals) {
          return vals.length;
        },
        query: {author: 'aaron', published: 1}
      };

      function validate(ret, stats) {
        assert.ok(Array.isArray(ret));
        assert.equal(ret.length, 1);
        assert.equal(ret[0]._id, 'aaron');
        assert.equal(ret[0].value, 6);
        assert.ok(stats);
      }

      function finish() {
        db.close(done);
      }

      var promise;

      assert.doesNotThrow(function() {
        promise = MR.mapReduce(o);
      });

      promise.then(validate, assert.ifError).then(finish).end();
    });
    it('works with nested schemas (gh-2821)', function(done) {
      var MinionSchema = function() {
        mongoose.Schema.apply(this, arguments);

        this.add({
          name: String
        });
      };
      util.inherits(MinionSchema, mongoose.Schema);

      var BaseSchema = function() {
        mongoose.Schema.apply(this, arguments);

        this.add({
          name: String,
          created_at: Date,
          minions: [new MinionSchema()]
        });
      };
      util.inherits(BaseSchema, mongoose.Schema);

      var PersonSchema = new BaseSchema();
      var BossSchema = new BaseSchema({
        department: String
      }, { id: false });

      assert.doesNotThrow(function() {
        var Person = db.model('gh2821', PersonSchema);
        Person.discriminator('gh2821-Boss', BossSchema);
      });
      done();
    });
    it("create", function() {
        var createPlugin = function() {
            var plugin = new Plugin();
        };

        assert.doesNotThrow(createPlugin);
    });
 it('should not throw if something is defined', () => {
   assert.doesNotThrow(() => {
     assert.doesNotThrow(() => {
       requireSources('Something', {a: 1}, 'a')
     })
   })
 })
Esempio n. 10
0
    it("works", () => {
      let midiDevice = new NodeMIDIDevice("DX7IIFD");

      assert.doesNotThrow(() => {
        midiDevice.send([ 0xb0, 0x16, 0x01 ]);
      });
    });
Esempio n. 11
0
    it('does not throw when empty array is passed as single argument', function(done) {
      var aggregate = new Aggregate();

      assert.doesNotThrow(function() {
        aggregate.append([]);
      });

      done();
    });
Esempio n. 12
0
    it('does not throw when 0 args passed', function(done) {
      var aggregate = new Aggregate();

      assert.doesNotThrow(function() {
        aggregate.append();
      });

      done();
    });
Esempio n. 13
0
  it('during construction', function(done) {
    assert.doesNotThrow(function() {
      new M(Object.create(null));
    });

    assert.doesNotThrow(function() {
      var o = Object.create(null);
      o.b = Object.create(null);
      new M(o);
    });

    assert.doesNotThrow(function() {
      var o = Object.create(null);

      o.b = Object.create(null);
      o.b.c = 9;

      var e = Object.create(null);
      e.e = 'hi i am a string';
      o.b.d = [e];

      var date = new Date;
      var f = Object.create(null);
      f.g = date;
      o.f = f;

      var h = Object.create(null);
      h.ad = 1;
      h.hoc = 2;
      h.obj = Object.create(null);
      o.h = h;

      var m = new M(o);

      assert.equal(m.b.c, 9);
      assert.equal(m.b.d[0].e, 'hi i am a string');
      assert.equal(date, m.f.g);
      assert.equal(m.h.ad, 1);
      assert.equal(m.h.hoc, 2);
      assert.deepEqual({}, m.h.obj);
    });

    done();
  });
    it('should throw error when broken manifests', function() {
        var loader = new FlCjsPlayer.AssetLoader();

        assert.throws(function() {
            loader.loadWithManifests();
        }, /Argument type error/);
        assert.doesNotThrow(function() {
            loader.loadWithManifests([]);
        });
    });
Esempio n. 15
0
        it("dose not throw when specified true", function() {

            beginSilent();

            assert.doesNotThrow(function() {
                CLI.Assert.truthy(true, 'should throw when specified true');
            });

            endSilent();

        });
Esempio n. 16
0
    it('allows passing identical name + schema args', function(done) {
      const m = new Mongoose;
      const schema = new Schema;
      let model = m.model('A', schema);

      assert.doesNotThrow(function() {
        m.model('A', model.schema);
      });

      done();
    });
Esempio n. 17
0
        it("dose not throw when specified false", function() {

            beginSilent();

            assert.doesNotThrow(function() {
                CLI.Assert.falsey(false, 'should throw when specified false');
            });

            endSilent();

        });
Esempio n. 18
0
        it("dose not throw when specified true object", function() {

            beginSilent();

            assert.doesNotThrow(function() {
                CLI.Assert.truthyProp({
                    myProp: true
                }, 'myProp');
            });

            endSilent();

        });
Esempio n. 19
0
        it("should throw when specified false object", function() {

            beginSilent();

            assert.doesNotThrow(function() {
                CLI.Assert.falseyProp({
                    myProp: false
                }, 'myProp');
            });

            endSilent();

        });
Esempio n. 20
0
    it('allows passing identical name + schema args', function(done) {
      var db = start();
      var name = 'gh-1209-b';
      var schema = new Schema;

      db.model(name, schema);
      assert.doesNotThrow(function() {
        db.model(name, schema);
      });

      db.close();
      done();
    });
Esempio n. 21
0
 it('\u554F\u984C\u306A\u3057', function () {
     setting = {
         required: {
             combineNum: 1,
             kind: [
                 'NUMBER',
                 'UC_ALPHABET'
             ]
         },
         useStrictMode: true
     };
     assert.doesNotThrow(function () {
         new TextVldtr(setting);
     });
 });
Esempio n. 22
0
        g.save(function(err) {
          assert.ifError(err);

          var pnt = {type: 'Point', coordinates: [90, 45]};
          var promise;
          assert.doesNotThrow(function() {
            promise = Geo.geoNear(pnt, {spherical: true, maxDistance: 1000});
          });

          function finish() {
            db.close(done);
          }

          promise.then(finish).end();
        });
      it('should contain only valid rule configuration', function() {
        var config = require(path.join(DEFAULT_CONFIG_PATH, file));

        for (var rule in config.rules) {
          var options = {
            config: config.rules[rule]
          };

          var Rule = rules[rule](options);
          assert.doesNotThrow(function() {
            new Rule({
              rawSource: ''
            });
          });
        }
      });
Esempio n. 24
0
    it('doesnt throw with refs (gh-2665)', function(done) {
      // Simple schema with throws option
      var FooSchema = new mongoose.Schema({
        name: {type: mongoose.Schema.Types.ObjectId, ref: 'test', required: false, default: null},
        father: {name: {full: String}}
      }, {strict: 'throw'});

      // Create the model
      var Foo = mongoose.model('Foo', FooSchema);

      assert.doesNotThrow(function() {
        new Foo({name: mongoose.Types.ObjectId(), father: {name: {full: 'bacon'}}});
      });

      done();
    });
Esempio n. 25
0
        g.save(function(err) {
          assert.ifError(err);

          var promise;
          assert.doesNotThrow(function() {
            promise = Geo.geoSearch({type: 'place'}, {near: [9, 9], maxDistance: 5});
          });
          function validate(ret) {
            assert.equal(ret.length, 1);
            assert.equal(ret[0].pos[0], 10);
            assert.equal(ret[0].pos[1], 10);
          }

          function finish() {
            done();
          }
          promise.then(validate, assert.ifError).then(finish);
        });
Esempio n. 26
0
    it('fails with extra fields', function(done) {
      // Simple schema with throws option
      var FooSchema = new mongoose.Schema({
        name: {type: String}
      }, {strict: 'throw'});

      // Create the model
      var Foo = mongoose.model('Foo1234', FooSchema);

      assert.doesNotThrow(function() {
        new Foo({name: 'bar'});
      });

      assert.throws(function() {
        // The extra baz field should throw
        new Foo({name: 'bar', baz: 'bam'});
      }, /Field `baz` is not in schema/);

      done();
    });
Esempio n. 27
0
        g.save(function(err) {
          assert.ifError(err);

          var pnt = {type: 'Point', coordinates: testLocations.PORT_AUTHORITY_STATION};
          var promise;
          assert.doesNotThrow(function() {
            promise = Geo.geoNear(pnt, {spherical: true, maxDistance: 300});
          });

          function validate(ret, stat) {
            assert.equal(1, ret.length);
            assert.equal(ret[0].obj.coordinates[0], testLocations.MONGODB_NYC_OFFICE[0]);
            assert.equal(ret[0].obj.coordinates[1], testLocations.MONGODB_NYC_OFFICE[1]);
            assert.ok(stat);
          }

          function finish() {
            db.close(done);
          }

          promise.then(validate, assert.ifError).then(finish).end();
        });
 assert.doesNotThrow(() => {
   assert.doesNotThrow(() => {
     requireSources('Something', {a: 1}, 'a')
   })
 })
Esempio n. 29
0
 it('存在しない番号でも例外を投げない', () => {
   assert.doesNotThrow(() => bingo.update({number: 99999}));
 });
Esempio n. 30
0
 model.validate(function(err) {
   assert.doesNotThrow(function() {
     JSON.stringify(err);
   });
   done();
 });