Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[test] Added a simple test.

  • Loading branch information...
commit 82eb37aa436b2d0e173f6e5c9eec403734702c1c 1 parent a1b17aa
@3rd-Eden 3rd-Eden authored
Showing with 43 additions and 1 deletion.
  1. +1 −1  package.json
  2. +42 −0 test.js
View
2  package.json
@@ -4,7 +4,7 @@
"description": "Extend constructors",
"main": "index.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "node test.js"
},
"repository": "",
"author": "Arnout Kazemier",
View
42 test.js
@@ -0,0 +1,42 @@
+'use strict';
+
+var extend = require('./index')
+ , assert = require('assert')
+ , EventEmitter = require('events').EventEmitter;
+
+function Awesomeness() {
+ var self = this;
+
+ this.foo = 'foo';
+
+ setTimeout(function () {
+ self.render(self.data);
+ }, 100);
+
+ EventEmitter.call(this);
+}
+
+Awesomeness.prototype = new EventEmitter;
+Awesomeness.prototype.constructor = Awesomeness;
+
+Awesomeness.prototype.data = 'bar';
+Awesomeness.prototype.render = function render() {
+ // does nothing
+};
+
+Awesomeness.extend = extend;
+
+var SuperAwesome = Awesomeness.extend({
+ data: 'trololol'
+
+ , render: function render(data) {
+ assert.ok(this.data === 'trololol');
+ assert.ok(data === 'trololol');
+ assert.ok(this.foo === 'foo');
+
+ console.log(data, this.foo);
+ }
+});
+
+new SuperAwesome();
+// outputs "trololo" after 100 ms

0 comments on commit 82eb37a

Please sign in to comment.
Something went wrong with that request. Please try again.