How to use the base/model function in base

To help you get started, we’ve selected a few base 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 drdelambre / drdelambre / tests / model.js View on Github external
it('should clear basic arrays', function() {
		var model = new Model({
			beans: []
		});

		model.fill({ beans: [ 1, 2, 3 ] });

		model.clear();

		expect(model.beans.length).to.equal(0);
	});
github drdelambre / drdelambre / tests / model.js View on Github external
it('should serialize on out', function() {
		var model = new Model({
				id: 12,
				name: 'beans'
			}),
			out;

		out = model.out();

		expect(Object.keys(out).length).to.equal(2);
		expect(out.id).to.equal(12);
		expect(out.name).to.equal('beans');

		model.extend({
			yolo: true,
			num: 100
		}).fill({
			id: 25,
github drdelambre / drdelambre / tests / model.js View on Github external
it('should be picky', function() {
		var model = new Model({
			id: 12,
			hashtag: 'yolo'
		});

		expect(function() {
			model.before({
				bean() {}
			});
		}).to.throw(
			'Model: called before on a property (bean) that does not exist');
	});
github drdelambre / drdelambre / tests / model.js View on Github external
it('should clear basic data', function() {
		var model = new Model({
			id: 12,
			name: 'beans',
			yolo: true
		});

		model.fill({
			id: 100,
			name: 'not beans',
			yolo: false,
			num: 100
		});

		model.clear();

		expect(model.id).to.equal(12);
		expect(model.name).to.equal('beans');
github drdelambre / drdelambre / tests / model.js View on Github external
it('should fill sub models defined as properties', function() {
		var model = new Model({
			id: 47,
			sub: SubModel
		});

		model.fill({
			id: 90,
			sub: {
				id: 34,
				name: 'hashtag',
				yolo: 'factor'
			}
		});

		expect(model.sub instanceof SubModel).to.be.true;
		expect(model.id).to.equal(90);
		expect(model.sub.id).to.equal(34);
github drdelambre / drdelambre / tests / model.js View on Github external
it('should update on unshifting', function(done) {
		var model = new Model({
				beans: []
			}),
			spy = sinon.spy();

		model.on_update('beans', spy);

		model.beans = [ 1, 2, 3 ];
		model.beans.unshift(7, 6, 5);

		expect(model.beans.length).to.equal(6);
		expect(model.beans[0]).to.equal(7);
		expect(model.beans[1]).to.equal(6);
		expect(model.beans[2]).to.equal(5);
		expect(model.beans[3]).to.equal(1);
		expect(model.beans[4]).to.equal(2);
		expect(model.beans[5]).to.equal(3);
github drdelambre / drdelambre / tests / model.js View on Github external
it('should fill with models', function() {
		var model = new Model({
			id: 12,
			name: 'beans',
			yolo: true
		});

		model.fill(new Model({
			name: 'not beans',
			yolo: false
		}));

		expect(model.id).to.equal(12);
		expect(model.name).to.equal('not beans');
		expect(model.yolo).to.be.false;
	});
github drdelambre / drdelambre / tests / model.js View on Github external
it('should fill basic data', function() {
		var model = new Model({
			id: 12,
			name: 'beans',
			yolo: true
		});

		model.fill({
			name: 'not beans',
			yolo: false,
			num: 100
		});

		expect(model.id).to.equal(12);
		expect(model.name).to.equal('not beans');
		expect(model.yolo).to.be.false;
		expect(model.num).to.be.undefined;
	});
github drdelambre / drdelambre / tests / model.js View on Github external
it('should extend with ease', function() {
		var model = new Model({
			id: 12,
			name: 'beans'
		});

		expect(model.keys().length).to.equal(2);

		model.extend({
			yolo: false,
			num: 100
		});

		expect(model.keys().length).to.equal(4);
		expect(model.yolo).to.be.false;
		expect(model.num).to.equal(100);
	});
github drdelambre / drdelambre / tests / model.js View on Github external
it('should throw events correctly on fill', function(done) {
		var model = new Model({
				id: 12,
				name: 'beans'
			}),
			spy1 = sinon.spy(),
			spy2 = sinon.spy();

		model.on_update('id', spy1);
		model.on_update('*', spy2);

		model.fill({
			id: 56,
			name: 'pinto'
		});

		setTimeout(function() {
			try {