mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-27 21:44:22 -04:00
Publish tests.
This commit is contained in:
parent
5a8ecd593d
commit
c396800dfa
40 changed files with 21478 additions and 1 deletions
111
test/tests/unit/core/notify.js
Normal file
111
test/tests/unit/core/notify.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var ID = 'core/notify';
|
||||
var DEPS = ['$'];
|
||||
|
||||
describe('module "' + ID + '"', function () {
|
||||
|
||||
before(function () {
|
||||
|
||||
this.definition = modulejs._private.definitions[ID];
|
||||
|
||||
this.applyFn = function () {
|
||||
|
||||
return this.definition.fn($);
|
||||
};
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
|
||||
util.restoreHtml();
|
||||
});
|
||||
|
||||
describe('definition', function () {
|
||||
|
||||
it('is defined', function () {
|
||||
|
||||
assert.isPlainObject(this.definition);
|
||||
});
|
||||
|
||||
it('has correct id', function () {
|
||||
|
||||
assert.strictEqual(this.definition.id, ID);
|
||||
});
|
||||
|
||||
it('requires correct', function () {
|
||||
|
||||
assert.deepEqual(this.definition.deps, DEPS);
|
||||
});
|
||||
|
||||
it('args for each request', function () {
|
||||
|
||||
assert.strictEqual(this.definition.deps.length, this.definition.fn.length);
|
||||
});
|
||||
|
||||
it('has no instance', function () {
|
||||
|
||||
assert.notProperty(modulejs._private.instances, ID);
|
||||
});
|
||||
|
||||
it('inits without errors', function () {
|
||||
|
||||
this.applyFn();
|
||||
});
|
||||
});
|
||||
|
||||
describe('application', function () {
|
||||
|
||||
it('returns plain object with 1 property', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.isPlainObject(instance);
|
||||
assert.lengthOfKeys(instance, 1);
|
||||
});
|
||||
|
||||
it('adds HTML', function () {
|
||||
|
||||
this.applyFn();
|
||||
assert.lengthOf($('#notify'), 1);
|
||||
assert.lengthOf($('#notify:visible'), 0);
|
||||
assert.strictEqual($('#notify').text(), '');
|
||||
});
|
||||
});
|
||||
|
||||
describe('publics', function () {
|
||||
|
||||
it('.set() is function', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
assert.ok(_.isFunction(instance.set));
|
||||
});
|
||||
|
||||
it('.set() works', function () {
|
||||
|
||||
var instance = this.applyFn();
|
||||
|
||||
instance.set();
|
||||
assert.lengthOf($('#notify:visible'), 0);
|
||||
assert.strictEqual($('#notify').text(), '');
|
||||
|
||||
instance.set('hello');
|
||||
assert.lengthOf($('#notify:visible'), 1);
|
||||
assert.strictEqual($('#notify').text(), 'hello');
|
||||
|
||||
instance.set('world');
|
||||
assert.lengthOf($('#notify:visible'), 1);
|
||||
assert.strictEqual($('#notify').text(), 'world');
|
||||
|
||||
instance.set();
|
||||
// assert.lengthOf($('#notify:visible'), 0);
|
||||
assert.strictEqual($('#notify').text(), 'world');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue