This repository has been archived by the owner on Feb 24, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
describe('baseClass', function() { | ||
|
||
function MyComponent() { | ||
Object.getPrototypeOf(MyComponent.prototype).constructor.apply(this, arguments); // super() | ||
} | ||
|
||
_inherits(MyComponent, $.BaseClass); | ||
|
||
MyComponent.prototype.doSomething = function(value) { | ||
return this.addClass(value); | ||
}; | ||
|
||
it('should allow to extend from baseClass', function() { | ||
var component = new MyComponent('body'); | ||
expect(component instanceof MyComponent).to.be.true; | ||
expect(component instanceof $.BaseClass).to.be.true; | ||
expect(MyComponent.prototype instanceof $.BaseClass).to.be.true; | ||
}); | ||
|
||
it('should extend properly from baseClass', function() { | ||
var expected = getRndStr(), | ||
component = new MyComponent('body'); | ||
component.doSomething(expected); | ||
expect(component.find).to.be.a('function'); | ||
expect(document.body.className).to.contain(expected); | ||
}); | ||
|
||
it('should accept Nodes, just like $()', function() { | ||
var expected = $(document.body), | ||
actual = new MyComponent(document.body); | ||
expect(actual).to.have.same.elements(expected); | ||
}); | ||
|
||
it('should be chainable', function() { | ||
var className = getRndStr(), | ||
expected = new MyComponent(document.body), | ||
actual = expected.doSomething(className).addClass(className); | ||
expect(actual).to.equal(expected); | ||
expect(document.body.className).to.contain(className); | ||
}); | ||
|
||
}); |