Example #1
0
	'Expect eliminate to remove storage >': function() {
		this.model.store();
		var data = this.model.retrieve();

		this.model.eliminate();
		buster.refute.equals(this.model.retrieve, data);
	},
Example #2
0
	'Expect .sort("key") to sort the collection by that model property >': function() {
		this.collection.empty();

		this.collection.addModel({
			id: 300,
			name: 'A'
		});

		this.collection.addModel({
			id: 200,
			name: 'B'
		});

		this.collection.addModel({
			id: 400,
			name: 'C'
		});

		var current = this.collection.toJSON().map(function(el) {
			return el.name;
		}).join(','); // should be "A,B,C"

		this.collection.sort('id');

		var changed = this.collection.toJSON().map(function(el) {
			return el.name;
		}).join(','); // should be "B,A,C"

		buster.refute.equals(current, changed);
	},
Example #3
0
	'Expect two different dates not to be equal': function() {
		// this test fails! f*****g hell.
		var date1 = new Date(2010, 6, 26, 0, 0, 0),
			date2 = new Date(2000, 6, 27, 0, 0, 0);

		buster.refute.isTrue(Epitome.isEqual(date1, date2));
	},
	'Expect model.toJSON to return a dereferenced object >': function() {
		var json = this.model.toJSON(),
			testStr = 'testing';

		json.foo = testStr;
		buster.refute.equals(this.model.get('foo'), json.foo);
	},
	'Expect a model change not to fire if values have not changed >': function() {
		var spy = this.spy();
		this.model.on('change', function() {
			spy();
		});
		this.model.set(this.dataInitial);
		buster.refute.called(spy);
	},
	'Expect model not to set value when validation fails >': function() {
		var spy = this.spy();

		this.model.on('change:bar', spy);
		this.model.set(this.dataFail);

		buster.refute.calledWith(spy, this.dataPass.bar);
	},
	'Expect no errors to be fired when validation passes >': function() {
		var spy = this.spy();

		this.model.on('error', spy);
		this.model.set(this.dataPass);

		buster.refute.called(spy);
	},
 function (result) {
   var messages = result.split(/(?=HTTP\/1\.1)/);
   buster.assert.equals(messages.length, 2);
   var lines = messages[0].split('\r\n');
   buster.assert.contains(lines, 'HTTP/1.1 500 Internal Server Error');
   buster.refute.contains(lines, 'Transfer-Encoding: chunked');
   buster.assert.equals(messages[1], simple);
 }
Example #9
0
	'Expect a model that has been destroyed to be removed from the collection >': function() {
		var temp = new Epitome.Model({
			id: 'hai'
		});

		this.collection.addModel(temp);
		temp.destroy();
		buster.refute.equals(temp, this.collection.getModelById('hai'));
	},
Example #10
0
	'Expect a model to fire change event for each property passed >': function() {
		var spy = this.spy();
		this.model.on('change', function() {
			spy();
		});

		this.model.set(this.dataMany);
		buster.refute.calledThrice(spy);
	},
Example #11
0
	'Expect a model change not to fire if falsy values have not changed >': function(){
		var spy = this.spy();
		var model = this.model;
		model.set('foo', 0);
		model.on('change', function(){
			spy();
		});
		model.set('foo', 0);
		buster.refute.called(spy);
	},
	'Expect an event to be removed by off wildcard > ': function(){
		var spy = this.spy();

		var foo = new this.Foo({
			onTest: spy
		});

		foo.off('test');

		foo.trigger('test');
		buster.refute.called(spy);
	},
	'Expect to be able to use models with localStorage and sessionStorage at the same time >': function(){
		// share the same id, different storage medium
		this.model.set('foo', 'foo');

		this.model.store();

		this.model2.set('foo', 'more foo');

		this.model2.store();

		buster.refute.equals(this.model.retrieve(), this.model2.retrieve());
	},
Example #14
0
	'Expect a model change on non-primitive values that serialize to the same not to fire >': function() {
		var spy = this.spy();
		this.model.set('obj', {
			foo: 'bar'
		});
		this.model.on('change', function() {
			spy();
		});
		this.model.set('obj', {
			foo: 'bar'
		});
		buster.refute.called(spy);
	},
Example #15
0
    "hide and extract": function() {
        var message = "attack at dawn",
            password = "******",
            n = 52,
            stega = Stega.create( PlainCodec, AESCrypto ),
            ordering = stega.hideSync( message, password, n ),
            retrieved = stega.extractSync( ordering, password ),
            i;

        buster.assert.equals( ordering.length, n );
        buster.assert.equals( retrieved.search( message ), 0 );
        
        for(i = 0; i < n; i++) {
            buster.refute.equals( ordering.indexOf( i ), -1 );
        }
    }
Example #16
0
    "random padding works": function() {
        var payload = "11001110001001101110011010111010001011100101101",
            n = 20,
            encoded = Ordering.bitsToOrdering( payload, n ),
            encoded2 = Ordering.bitsToOrdering( payload, n ),
            decoded = Ordering.orderingToBits( encoded, payload.length ),
            decoded2 = Ordering.orderingToBits( encoded2, payload.length );
            

        buster.assert.equals( decoded, payload );
        buster.assert.equals( encoded.length, n );
        buster.assert.equals( decoded2, payload );
        buster.assert.equals( encoded2.length, n );

        // There's so much "room" in 20! compared to this payload that it
        // should be vanishingly unlikely that the same padding is chosen.

        buster.refute.equals( encoded, encoded2 );
    },
 function (result) {
   var lines = result.split('\r\n');
   buster.assert.contains(lines, 'HTTP/1.1 500 Internal Server Error');
   buster.refute.contains(lines, 'Transfer-Encoding: chunked');
 }
Example #18
0
	'Expect two different regexes not to be equal': function() {
		buster.refute.isTrue(Epitome.isEqual(new RegExp('\s'), new RegExp('\t')));
	}
Example #19
0
	'Expect no positives for objects with same length (bug in _.js)': function() {
		buster.refute.isTrue(Epitome.isEqual({length: 330}, {length: 330, plays: 1}));
	},
Example #20
0
	'Expect the model to have the default value overridden by model object >': function() {
		buster.refute.equals(this.model.get('foo'), this.options.defaults.foo);
	},
Example #21
0
	'Expect two identically looking separate functions to not be equal': function() {
		buster.refute.isTrue(Epitome.isEqual(
			(function() { return 'hi';}),
			(function() { return 'hi';})
		));
	},
Example #22
0
	'Removing a model from a collection should also remove the collection instance in the model.collections array >': function() {
		this.collection.removeModel(this.model);
		buster.refute.isTrue(this.model.collections.contains(this.collection));
	}