ampersand-state
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -493,2 +493,3 @@ var _ = require('underscore'); | ||
child.prototype._definition = _.extend({}, parent.prototype._definition); | ||
child.prototype._collections = _.extend({}, parent.prototype._collections); | ||
@@ -495,0 +496,0 @@ // Mix in all prototype properties to the subclass if supplied. |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -10,11 +10,12 @@ "bugs": { | ||
"dependencies": { | ||
"array-next": "~0.0.1", | ||
"backbone-events-standalone": "~0.2.1", | ||
"underscore": "~1.6.0", | ||
"array-next": "~0.0.1" | ||
"underscore": "~1.6.0" | ||
}, | ||
"devDependencies": { | ||
"ampersand-collection": "~0.2.3", | ||
"ampersand-registry": "0.x.x", | ||
"precommit-hook": "~0.3.10", | ||
"run-browser": "~1.2.0", | ||
"tape": "~2.11.0", | ||
"precommit-hook": "~0.3.10" | ||
"tape": "~2.12.1" | ||
}, | ||
@@ -21,0 +22,0 @@ "homepage": "https://github.com/ampersandjs/ampersand-state", |
var tape = require('tape'); | ||
var State = require('../ampersand-state'); | ||
var AmpersandRegistry = require('ampersand-registry'); | ||
var Collection = require('ampersand-collection'); | ||
var definition, Foo, registry; | ||
@@ -97,3 +98,8 @@ | ||
"use strict"; | ||
// detect if strict mode worked | ||
var isStrict = (function () { return !this; })(); | ||
bar.someProperty = 'new'; | ||
// throw type error to be able to test in browsers | ||
// that don't support strict | ||
if (!isStrict) throw TypeError; | ||
}, TypeError, 'Throws exception in strict mode.'); | ||
@@ -654,1 +660,57 @@ bar.someOtherProperty = 'something'; | ||
}); | ||
test('should be able to inherit for use in other objects', function (t) { | ||
var StateObj = State.extend({ | ||
props: { | ||
name: 'string' | ||
} | ||
}); | ||
function AwesomeThing() { | ||
StateObj.apply(this, arguments); | ||
} | ||
AwesomeThing.prototype = Object.create(StateObj.prototype, { | ||
constructor: AwesomeThing | ||
}); | ||
AwesomeThing.prototype.hello = function () { | ||
return this.name; | ||
}; | ||
var awe = new AwesomeThing({name: 'cool'}); | ||
t.equal(awe.hello(), 'cool'); | ||
t.equal(awe.name, 'cool'); | ||
t.end(); | ||
}); | ||
test('extended state objects should maintain child collections of parents', function (t) { | ||
var State1 = State.extend({ | ||
collections: { | ||
myStuff: Collection | ||
} | ||
}); | ||
var State2 = State1.extend({ | ||
collections: { | ||
myOtherCollection: Collection | ||
} | ||
}); | ||
var thing = new State2(); | ||
t.ok(thing.myStuff); | ||
t.ok(thing.myOtherCollection); | ||
t.end(); | ||
}); | ||
test('`initialize` should have access to initialized child collections', function (t) { | ||
var StateObj = State.extend({ | ||
initialize: function () { | ||
t.ok(this.myStuff); | ||
t.equal(this.myStuff.parent, this); | ||
t.end(); | ||
}, | ||
collections: { | ||
myStuff: Collection | ||
} | ||
}); | ||
var thing = new StateObj(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
54775
1316
0
5