can-construct
Advanced tools
Comparing version 3.5.5 to 3.5.6
@@ -6,3 +6,3 @@ QUnit = require('steal-qunit'); | ||
QUnit.module('can-construct', { | ||
setup: function () { | ||
beforeEach: function(assert) { | ||
var Animal = this.Animal = Construct.extend({ | ||
@@ -43,9 +43,9 @@ count: 0, | ||
}); | ||
test('inherit', function () { | ||
QUnit.test('inherit', function(assert) { | ||
var Base = Construct({}); | ||
ok(new Base() instanceof Construct); | ||
assert.ok(new Base() instanceof Construct); | ||
var Inherit = Base({}); | ||
ok(new Inherit() instanceof Base); | ||
assert.ok(new Inherit() instanceof Base); | ||
}); | ||
test('Creating', function () { | ||
QUnit.test('Creating', function(assert) { | ||
new this.Dog(); | ||
@@ -55,30 +55,30 @@ var a1 = new this.Animal(); | ||
var ajax = new this.Ajax(1000); | ||
equal(2, this.Animal.count, 'right number of animals'); | ||
equal(1, this.Dog.count, 'right number of animals'); | ||
ok(this.Dog.match, 'right number of animals'); | ||
ok(!this.Animal.match, 'right number of animals'); | ||
ok(this.Dog.test(), 'right number of animals'); | ||
ok(!this.Animal.test(), 'right number of animals'); | ||
equal(1, this.Ajax.count, 'right number of animals'); | ||
equal(2, this.Animal.count, 'right number of animals'); | ||
equal(true, ajax.eyes, 'right number of animals'); | ||
equal(1000, ajax.hairs, 'right number of animals'); | ||
ok(a1 instanceof this.Animal); | ||
ok(a1 instanceof Construct); | ||
assert.equal(2, this.Animal.count, 'right number of animals'); | ||
assert.equal(1, this.Dog.count, 'right number of animals'); | ||
assert.ok(this.Dog.match, 'right number of animals'); | ||
assert.ok(!this.Animal.match, 'right number of animals'); | ||
assert.ok(this.Dog.test(), 'right number of animals'); | ||
assert.ok(!this.Animal.test(), 'right number of animals'); | ||
assert.equal(1, this.Ajax.count, 'right number of animals'); | ||
assert.equal(2, this.Animal.count, 'right number of animals'); | ||
assert.equal(true, ajax.eyes, 'right number of animals'); | ||
assert.equal(1000, ajax.hairs, 'right number of animals'); | ||
assert.ok(a1 instanceof this.Animal); | ||
assert.ok(a1 instanceof Construct); | ||
}); | ||
test('new instance', function () { | ||
QUnit.test('new instance', function(assert) { | ||
var d = this.Ajax.newInstance(6); | ||
equal(6, d.hairs); | ||
assert.equal(6, d.hairs); | ||
}); | ||
test('namespaces', function () { | ||
QUnit.test('namespaces', function(assert) { | ||
var fb = Construct.extend('Bar'); | ||
ok(!window.Bar, "not added to global namespace"); | ||
assert.ok(!window.Bar, "not added to global namespace"); | ||
if (Object.getOwnPropertyDescriptor) { | ||
equal(fb.name, 'Bar', 'name is right'); | ||
assert.equal(fb.name, 'Bar', 'name is right'); | ||
} | ||
equal(fb.shortName, 'Bar', 'short name is right'); | ||
assert.equal(fb.shortName, 'Bar', 'short name is right'); | ||
}); | ||
test('setups', function () { | ||
QUnit.test('setups', function(assert) { | ||
var order = 0, | ||
@@ -107,9 +107,9 @@ staticSetup, staticSetupArgs, staticInit, staticInitArgs, protoSetup, protoInitArgs, protoInit, staticProps = { | ||
new Car('geo'); | ||
equal(staticSetup, 1); | ||
equal(staticInit, 2); | ||
equal(protoSetup, 3); | ||
equal(protoInit, 4); | ||
deepEqual(Array.prototype.slice.call(staticInitArgs), ['something']); | ||
deepEqual(Array.prototype.slice.call(protoInitArgs), ['Ford: geo']); | ||
deepEqual(Array.prototype.slice.call(staticSetupArgs), [ | ||
assert.equal(staticSetup, 1); | ||
assert.equal(staticInit, 2); | ||
assert.equal(protoSetup, 3); | ||
assert.equal(protoInit, 4); | ||
assert.deepEqual(Array.prototype.slice.call(staticInitArgs), ['something']); | ||
assert.deepEqual(Array.prototype.slice.call(protoInitArgs), ['Ford: geo']); | ||
assert.deepEqual(Array.prototype.slice.call(staticSetupArgs), [ | ||
Construct, | ||
@@ -122,8 +122,8 @@ 'Car', | ||
Car.extend('Truck'); | ||
equal(staticSetup, 5, 'Static setup is called if overwriting'); | ||
assert.equal(staticSetup, 5, 'Static setup is called if overwriting'); | ||
}); | ||
test('Creating without extend', function () { | ||
QUnit.test('Creating without extend', function(assert) { | ||
var Bar = Construct('Bar', { | ||
ok: function () { | ||
ok(true, 'ok called'); | ||
assert.ok(true, 'ok called'); | ||
} | ||
@@ -135,3 +135,3 @@ }); | ||
dude: function () { | ||
ok(true, 'dude called'); | ||
assert.ok(true, 'dude called'); | ||
} | ||
@@ -145,7 +145,7 @@ }); | ||
if (dev) { | ||
test('console warning if extend is not used without new (#932)', function () { | ||
QUnit.test('console warning if extend is not used without new (#932)', function(assert) { | ||
var oldlog = dev.warn; | ||
dev.warn = function (text) { | ||
ok(text, "got a message"); | ||
assert.ok(text, "got a message"); | ||
dev.warn = oldlog; | ||
@@ -159,8 +159,8 @@ }; | ||
test("setup called with original arguments", function(){ | ||
QUnit.test("setup called with original arguments", function(assert) { | ||
var o2 = {}; | ||
var o1 = { | ||
setup: function(base, arg1, arg2){ | ||
equal(o1, arg1, "first argument is correct"); | ||
equal(o2, arg2, "second argument is correct"); | ||
assert.equal(o1, arg1, "first argument is correct"); | ||
assert.equal(o2, arg2, "second argument is correct"); | ||
} | ||
@@ -172,3 +172,3 @@ }; | ||
test("legacy namespace strings (A.B.C) accepted", function() { | ||
QUnit.test("legacy namespace strings (A.B.C) accepted", function(assert) { | ||
@@ -178,9 +178,9 @@ var Type = Construct.extend("Foo.Bar.Baz"); | ||
ok(new Type() instanceof Construct, "No unexpected behavior in the prototype chain"); | ||
assert.ok(new Type() instanceof Construct, "No unexpected behavior in the prototype chain"); | ||
if (Function.prototype.name) { | ||
equal(Type.name, expectedValue, "Name becomes underscored"); | ||
assert.equal(Type.name, expectedValue, "Name becomes underscored"); | ||
} | ||
}); | ||
test("reserved words accepted", function() { | ||
QUnit.test("reserved words accepted", function(assert) { | ||
@@ -190,5 +190,5 @@ var Type = Construct.extend("const"); | ||
ok(new Type() instanceof Construct, "No unexpected behavior in the prototype chain"); | ||
assert.ok(new Type() instanceof Construct, "No unexpected behavior in the prototype chain"); | ||
if (Function.prototype.name) { | ||
equal(Type.name, expectedValue, "Name becomes capitalized"); | ||
assert.equal(Type.name, expectedValue, "Name becomes capitalized"); | ||
} | ||
@@ -198,3 +198,3 @@ }); | ||
test("basic injection attacks thwarted", function() { | ||
QUnit.test("basic injection attacks thwarted", function(assert) { | ||
@@ -211,3 +211,3 @@ var rootToken = typeof window === "undefined" ? "global" : "window"; | ||
} finally { | ||
equal(rootObject[expando], undefined, "Injected code doesn't run"); | ||
assert.equal(rootObject[expando], undefined, "Injected code doesn't run"); | ||
} | ||
@@ -219,3 +219,3 @@ delete rootObject[expando]; | ||
} finally { | ||
equal(rootObject[expando], undefined, "Injected code doesn't run"); | ||
assert.equal(rootObject[expando], undefined, "Injected code doesn't run"); | ||
} | ||
@@ -225,3 +225,3 @@ | ||
QUnit.test("setters not invoked on extension (#28)", function(){ | ||
QUnit.test("setters not invoked on extension (#28)", function(assert) { | ||
@@ -231,3 +231,3 @@ var extending = true; | ||
set something(value){ | ||
QUnit.ok(!extending, "called when not extending"); | ||
assert.ok(!extending, "called when not extending"); | ||
}, | ||
@@ -246,3 +246,3 @@ get something(){ | ||
QUnit.test("return alternative value simple", function(){ | ||
QUnit.test("return alternative value simple", function(assert) { | ||
var Alternative = function(){}; | ||
@@ -254,6 +254,6 @@ var Base = Construct.extend({ | ||
}); | ||
QUnit.ok(new Base() instanceof Alternative, "Should create an instance of Alternative"); | ||
assert.ok(new Base() instanceof Alternative, "Should create an instance of Alternative"); | ||
}); | ||
QUnit.test("return alternative value on setup (full case)", function(){ | ||
QUnit.test("return alternative value on setup (full case)", function(assert) { | ||
var Student = function(name, school){ | ||
@@ -278,8 +278,8 @@ this.name = name; | ||
}); | ||
QUnit.equal(new Person({age: 12}).isStudent, false, "Age 12 cannot be a student"); | ||
QUnit.equal(new Person({age: 30}).isStudent, true, "Age 20 can be a student"); | ||
QUnit.ok(new Person({age: 30}) instanceof Student, "Should return an instance of Student"); | ||
assert.equal(new Person({age: 12}).isStudent, false, "Age 12 cannot be a student"); | ||
assert.equal(new Person({age: 30}).isStudent, true, "Age 20 can be a student"); | ||
assert.ok(new Person({age: 30}) instanceof Student, "Should return an instance of Student"); | ||
}); | ||
QUnit.test("extends defaults right", function(){ | ||
QUnit.test("extends defaults right", function(assert) { | ||
var BASE = Construct.extend({ | ||
@@ -295,7 +295,7 @@ defaults: { | ||
}, {}); | ||
ok(INHERIT.defaults.foo === 'bar', 'Class must inherit defaults from the parent class'); | ||
ok(INHERIT.defaults.newProp === 'newVal', 'Class must have own defaults'); | ||
assert.ok(INHERIT.defaults.foo === 'bar', 'Class must inherit defaults from the parent class'); | ||
assert.ok(INHERIT.defaults.newProp === 'newVal', 'Class must have own defaults'); | ||
}); | ||
QUnit.test("enumerability", function(){ | ||
QUnit.test("enumerability", function(assert) { | ||
var Parent = Construct.extend("Parent", {}); | ||
@@ -311,3 +311,3 @@ | ||
QUnit.deepEqual(props, { | ||
assert.deepEqual(props, { | ||
foo: true | ||
@@ -317,9 +317,9 @@ }, "only has ownProps"); | ||
QUnit.test("Has default init, setup functions", function(){ | ||
QUnit.test("Has default init, setup functions", function(assert) { | ||
var instance = new Construct(); | ||
QUnit.equal(typeof instance.init, "function", "has init"); | ||
QUnit.equal(typeof instance.setup, "function", "has setup"); | ||
assert.equal(typeof instance.init, "function", "has init"); | ||
assert.equal(typeof instance.setup, "function", "has setup"); | ||
}); | ||
QUnit.test("Extending should not update defaults nested objects", function() { | ||
QUnit.test("Extending should not update defaults nested objects", function(assert) { | ||
var Parent = Construct.extend({ | ||
@@ -341,4 +341,4 @@ defaults: { | ||
QUnit.equal(Parent.defaults.obj.foo, "Bar", "Base defaults are not changed"); | ||
QUnit.equal(Child.defaults.obj.foo, "Baz", "Child defaults get defaults right"); | ||
assert.equal(Parent.defaults.obj.foo, "Bar", "Base defaults are not changed"); | ||
assert.equal(Child.defaults.obj.foo, "Baz", "Child defaults get defaults right"); | ||
}); |
{ | ||
"name": "can-construct", | ||
"version": "3.5.5", | ||
"version": "3.5.6", | ||
"description": "easy constructor functions", | ||
@@ -47,3 +47,3 @@ "homepage": "http://canjs.com", | ||
"steal": "^1.2.8", | ||
"steal-qunit": "^1.0.1", | ||
"steal-qunit": "^2.0.0", | ||
"steal-tools": "^1.1.2", | ||
@@ -50,0 +50,0 @@ "testee": "^0.9.0" |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
48865
1
8