Page MenuHomeWickedGov Phorge

mfExtend.test.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

mfExtend.test.js

let mfExtend;
const
sinon = require( 'sinon' ),
oo = require( '../utils/oo' );
/** @type {sinon.SinonSandbox} */ let sandbox;
QUnit.module( 'MobileFrontend mfExtend.test.js', {
beforeEach: function () {
sandbox = sinon.sandbox.create();
oo.setUp( sandbox, global );
mfExtend = require( '../../../src/mobile.startup/mfExtend' );
},
afterEach: function () {
sandbox.restore();
}
} );
QUnit.test( 'mfExtend() - extending from constructor', function ( assert ) {
function TestChild() {}
function TestPrototype() {}
mfExtend( TestChild, TestPrototype, {} );
assert.true( TestChild.prototype instanceof TestPrototype );
} );
QUnit.test( 'mfExtend() - extending from object', function ( assert ) {
const testPrototype = new TestPrototype();
function TestChild() {}
function TestPrototype() {
this.protoMethod = function () {
return true;
};
}
mfExtend( TestChild, testPrototype );
const testChild = new TestChild();
assert.strictEqual( testChild.protoMethod(), true );
} );
QUnit.test( 'mfExtend() - extending from constructor with overrides', function ( assert ) {
function TestChild() {}
function TestPrototype() {
this.protoMethod = function () {
return true;
};
}
mfExtend( TestChild, TestPrototype, {
protoMethod: function () {
return false;
}
} );
const testChild = new TestChild();
assert.strictEqual( testChild.protoMethod(), false );
} );

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 19, 13:03 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9e/82/4c1537277878f31c83f957e8cd64
Default Alt Text
mfExtend.test.js (1 KB)

Event Timeline