UNPKG

@orcden/od-component-test-suite

Version:
1,041 lines (901 loc) 53 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["ODComponentTestSuite"] = factory(); else root["ODComponentTestSuite"] = factory(); })(this, function() { return /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 72: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "TestCafeComponentTestSuite": () => /* reexport */ TestCafeComponentTestSuite }); // EXTERNAL MODULE: external "testcafe" var external_testcafe_ = __webpack_require__(652); // EXTERNAL MODULE: external "regenerator-runtime/runtime" var runtime_ = __webpack_require__(835); // CONCATENATED MODULE: ./src/lib/testcafe/common/ComponentModel.js class ComponentModel { constructor( config ) { this._componentData = config; if( !this._validateConfig() ) { console.log( 'ERROR: INVALID CONFIGURATION' ); return; } this._component = (0,external_testcafe_.Selector)( this.componentSelector ).addCustomDOMProperties( this._buildCustomProps() ); let tag = this.componentTag this._componentClassIsDefined = (0,external_testcafe_.ClientFunction)( () =>{ customElements.get( tag ) !== undefined; }, { dependencies: { tag } } ); let component = this.component; let shadowSelector = this.shadowSelector; this._innerElement = (0,external_testcafe_.Selector)( () => component().shadowRoot.querySelector( shadowSelector ), { dependencies: { component, shadowSelector } } ); let selector = this.componentSelector; this._setComponentProperty = (0,external_testcafe_.ClientFunction)( ( name, value ) => { document.querySelector( selector )[name] = value; }, {dependencies: { selector }} ); this._setComponentAttribute = (0,external_testcafe_.ClientFunction)( ( name, value ) => { document.querySelector( selector ).setAttribute( name, value ); }, {dependencies: { selector }} ); } //Configs get testServer() { return this._componentData.testServer; } get componentName() { return this._componentData.name; } get componentTag() { return this._componentData.componentTag } get componentSelector() { return this._componentData.componentSelector; } get hasShadow() { return this._componentData.hasShadow; } get shadowSelector() { return this._componentData.shadowSelector; } get properties() { return this._componentData.properties; } //Selectors get component() { return this._component; } get innerElement() { return this._innerElement; } //Client Functions async getComponentClassIsDefined() { return await this._componentClassIsDefined(); } async setComponentProperty( t, name, value ) { let boundC = this._setComponentProperty.with( { boundTestRun: t } ); await boundC( name, value ); } async setComponentAttribute( t, name, value ) { let boundC = this._setComponentAttribute.with( { boundTestRun: t } ); await boundC( name, value ); } //Test Methods async testAttributeNotExists( t, name, message ) { let boundS = this.component.with( { boundTestRun: t } ); await t .expect( boundS.withAttribute( name ).exists ).notOk( message ); } async testAttributeExists( t, name, message ) { let boundS = this.component.with( { boundTestRun: t } ); let exists = await boundS.withAttribute( name ).exists await t .expect( exists ).ok( message ); } async testAttributeValue( t, name, value, message ) { let boundS = this.component.with( { boundTestRun: t } ); await t .expect( boundS.withAttribute( name, value ).exists ).ok( message ); } async testPropertyValue( t, name, expected, message ) { let boundS = this.component.with( { boundTestRun: t } ); let value = boundS[name]; await t .expect( value ).eql( expected, message ); } //Private _validateConfig() { let valid = true; if( !this._validateCommonConfigs() ) { valid = false; } if( !this.properties || !this.properties.length || this.properties.length === 0 ) { return valid; } this.properties.forEach( p => { if( !this._validateProperty( p ) ) { valid = false; } } ); return valid; } _validateCommonConfigs() { let valid = true; if( !this.componentName || !this.testServer || !this.componentSelector ) { console.log( "ERROR: PLEASE ENSURE CONFIGURATION CONTAINS NAME, SERVER, AND SELECTOR" ); valid = false; } if( this.hasShadow && !this.shadowSelector ) { console.log( "ERROR: NO SELECTOR PROVIDED FOR SHADOW DOM" ); valid = false; } return valid; } _validateProperty( p ) { let valid = true; if( !this._validatePropertyCommon( p ) ) { valid = false; } if( !this._validatePropertyDefault( p ) ) { valid = false; } if( !this._validatePropertyValidValues( p ) ) { valid = false; } if( !this._validatePropertyAttributes( p ) ) { valid = false; } return valid; } _validatePropertyCommon( p ) { let valid = true; if( p.name === undefined || p.type === undefined || p.default === undefined ) { console.log( "ERROR: PLEASE ENSURE NAME, TYPE, AND DEFAULT IS PROVIDED FOR PROPERTY: ", p ); valid = false; } if( typeof p.name !== 'string' ) { console.log( "ERROR: NAME SHOULD BE A STRING FOR PROPERTY: ", p ); valid = false; } if( p.type !== Boolean && p.type !== Number && p.type !== String && p.type !== Array && p.type !== Object ) { console.log( "ERROR: INCORRECT TYPE PROVIDED FOR PROPERTY: ", p ); valid = false; } return valid; } _validatePropertyDefault( p ) { let valid = true; switch ( p.type ) { case Number: if( typeof p.default !== 'number' ) { console.log( "ERROR: DEFAUL SHOULD BE A NUMBER FOR PROPERTY: ", p ); valid = false; } break; case String: if( typeof p.default !== 'string' && p.default !== null ) { console.log( "ERROR: DEFAULT SHOULD BE A STRING/NULL FOR PROPERTY: ", p ); valid = false; } break; case Boolean: if( typeof p.default !== 'boolean' ) { console.log( "ERROR: DEFAULT SHOULD BE A BOOLEAN FOR PROPERTY: ", p ); valid = false; } break; default: break; } return valid; } _validatePropertyValidValues( p ) { let valid = true; if( ( p.type === Number || p.type === String ) ) { if( p.validValue === undefined ) { console.log( "ERROR: NO VALID VALUE PROVIDED FOR PROPERTY: ", p ); valid = false; } if( p.type === Number && typeof p.validValue !== 'number' ) { console.log( "ERROR: VALID VALUE SHOULD BE A NUMBER FOR PROPERTY: ", p ); valid = false; } else if( p.type === String && typeof p.validValue !== 'string' ) { console.log( "ERROR: VALID VALUE SHOULD BE A STRING FOR PROPERTY: ", p ); valid = false; } } return valid; } _validatePropertyAttributes( p ) { let valid = true; if( ( p.type === Number || p.type === String || p.type === Boolean ) ) { } return valid; } _buildCustomProps() { let lambdaBody = "return {"; this.properties.forEach( ( p ) => { lambdaBody = lambdaBody + p.name + ": el => el." + p.name; if( p !== this.properties[this.properties.length - 1] ) { lambdaBody = lambdaBody + ","; } } ); lambdaBody = lambdaBody + "};"; let lambda = Function( lambdaBody ); return lambda(); } } // CONCATENATED MODULE: ./src/lib/testcafe/common/CommonComponent.js class CommonComponentTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { fixture( this._model.componentName + ' All Common Webcomponents Tests' ) .page( this._model.testServer ); this._runWebcomponentsTests(); if( !this._model.hasShadow ) { return; } this._runShadowDOMTests(); } runWebcomponentsTests() { fixture( this._model.componentName + ' Webcomponents Support Tests' ) .page( this._model.testServer ); this._runWebcomponentsTests(); } _runWebcomponentsTests() { test( 'Webcomponents Support & Imports Correctly', async t => { let classIsDefined = await this._model.getComponentClassIsDefined(); await t .expect( classIsDefined ).notEql( false, this._model.componentTag + ' is defined' ); } ); } runShadowDOMTests() { if( !this._model.hasShadow ) { return; } fixture( this._model.componentName + 'Shadow DOM Support Tests' ) .page( this._model.testServer ); this._runShadowDOMTests(); } _runShadowDOMTests() { test( 'Shadow DOM Support', async ( t ) => { await t .expect( this._model.component.exists ).ok( 'Custom element is available' ) .expect( this._model.innerElement.exists ).ok( 'HTML is available inside shadow DOM' ); } ); } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/properties/PropertyDefaults.js class PropertyDefaultsUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runPropertyDefaultsUnitTests(); } runPropertyDefaultsUnitTests() { this._runPropertyDefaultsUnitTests(); } _runPropertyDefaultsUnitTests() { fixture( this._model.componentName + ' All Property Defaults Unit Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; let type = 'string'; if( prop.type === Boolean ) type = 'boolean'; if( prop.type === Number ) type = 'number'; test( 'Unit Tests - Properties - ' + prop.name + ' - ' + type + ' - Defaults', async t => { await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "' + prop.name + '" default ' + prop.default ); } ); } } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/attributes/AttributeDefaults.js class AttributeDefaultUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runAttributeDefaultsUnitTests(); } runAttributeDefaultsUnitTests() { this._runAttributeDefaultsUnitTests(); } _runAttributeDefaultsUnitTests() { fixture( this._model.componentName + ' All Attribute Defaults Unit Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; switch ( prop.type ) { case Boolean: this._testBoolean( prop.attributeName, prop.default.toString() ); break; case Number: this._testNumber( prop.attributeName, prop.default.toString() ); break; case String: this._testString( prop.attributeName, prop.default ); break; default: break; } } } _testBoolean( name, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - boolean - defaults', async t => { if( defaultV === 'true' ) { await this._model.testAttributeExists( t, name, 'Attribute "' + name + '" default - present' ); } else { await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" default - not present' ); } } ); } _testNumber( name, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - number - defaults', async t => { await this._model.testAttributeValue( t, name, defaultV, 'Attribute "' + name + '" default ' + defaultV ); } ); } _testString( name, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - string - defaults', async t => { if( defaultV !== null ) { await this._model.testAttributeValue( t, name, defaultV, 'Attribute "' + name + '" default ' + defaultV ); } else { await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" default - not present' ); } } ); } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/properties/PropertyInvalid.js class PropertyInvalidUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runPropertyInvalidUnitTests(); } runPropertyInvalidUnitTests() { this._runPropertyInvalidUnitTests(); } _runPropertyInvalidUnitTests() { fixture( this._model.componentName + ' All Property Invalid Unit Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; let type = 'string'; if( prop.type === Boolean ) type = 'boolean'; if( prop.type === Number ) type = 'number'; test( 'Unit Tests - Properties - ' + prop.name + ' - ' + type + ' - invalid types', async t => { if( prop.type !== Object ) { await this._model.setComponentProperty( t, prop.name, {} ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set {} - object does not update' ); } if( prop.type !== Array ) { await this._model.setComponentProperty( t, prop.name, [] ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set [] - array does not update' ); } if( prop.type !== Boolean ) { await this._model.setComponentProperty( t, prop.name, true ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set true - boolean does not update' ); } if( prop.type !== String ) { await this._model.setComponentProperty( t, prop.name, 'test' ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set \'test\' - invalid string does not update' ); } if( prop.type !== Number ) { await this._model.setComponentProperty( t, prop.name, 1 ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set 1 - number does not update' ); } if( prop.type !== Object && prop.type !== Array && prop.type !== String ) { await this._model.setComponentProperty( t, prop.name, null ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set null - null does not update' ); } if( prop.type === Boolean ) { let invert = !prop.default; invert = invert.toString(); await this._model.setComponentProperty( t, prop.name, invert ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set \'' + invert + '\' - valid string does not update' ); } if( prop.type === Number ) { let test = prop.validValue.toString(); await this._model.setComponentProperty( t, prop.name, test ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set \'' + test + '\' - valid string does not update' ); } await this._model.setComponentProperty( t, prop.name, undefined ); await this._model.testPropertyValue( t, prop.name, prop.default, 'Property "'+ prop.name +'" - set undefined - undefined does not update' ); } ); } } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/attributes/AttributeInvalid.js class AttributeInvalidNUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { fixture( this._model.componentName + ' All Attribute Invalid Unit Tests' ) .page( this._model.testServer ); this._runAttributeInvalidSBUnitTests(); this._runAttributeInvalidNUnitTests(); } runAttributeInvalidNUnitTests() { fixture( this._model.componentName + ' Number Attribute Invalid Unit Tests' ) .page( this._model.testServer ); this._runAttributeInvalidNUnitTests(); } runAttributeInvalidSBUnitTests() { fixture( this._model.componentName + ' String & Boolean Attribute Invalid Unit Tests' ) .page( this._model.testServer ); this._runAttributeInvalidSBUnitTests(); } _runAttributeInvalidNUnitTests() { for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; if( prop.type === Number ) { test( 'Unit Tests - Attributes - ' + prop.attributeName + ' - number - invalid types', async t => { let expected = await this._model.component[prop.name]; expected = expected.toString(); await this._model.setComponentAttribute( t, prop.attributeName, 'test' ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set \'test\' - invalid string does not update' ); await this._model.setComponentAttribute( t, prop.attributeName, null ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set null - null does not update' ); await this._model.setComponentAttribute( t, prop.attributeName, {} ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set {} - object does not update' ); await this._model.setComponentAttribute( t, prop.attributeName, [] ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set [] - array does not update' ); await this._model.setComponentAttribute( t, prop.attributeName, undefined ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set undefined - undefined does not update' ); } ); } } } _runAttributeInvalidSBUnitTests() { for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; if( prop.type === String || prop.type === Boolean ) { let type = 'string'; if( prop.type === Boolean ) type = 'boolean'; test( 'Unit Tests - Attributes - ' + prop.attributeName + ' - ' + type + ' - invalid types', async t => { let expected = await this._model.component[prop.name]; expected = expected.toString(); this._testAttribute( t, prop, expected, 1, 'number' ); this._testAttribute( t, prop, expected, {}, 'object' ); this._testAttribute( t, prop, expected, [], 'array' ); this._testAttribute( t, prop, expected, undefined, 'undefined' ); if( prop.type === Boolean ) { await this._model.setComponentAttribute( t, prop.attributeName, 'test' ); if( expected === 'true' ) { await this._model.testAttributeExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" - set \'test\' - invalid string does not update' ); } else { await this._model.testAttributeNotExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" - set \'test\' - invalid string does not update' ); } } else { await this._model.setComponentAttribute( t, prop.attributeName, true ); if( expected !== 'null' ) { await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" - set true - boolean does not update' ); } else { await this._model.testAttributeNotExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" - set true - boolean does not update' ); } } } ); } } } async _testAttribute( t, prop, expected, setTo, testType ) { await this._model.setComponentAttribute( t, prop.attributeName, setTo ); let message = 'Attribute "' + prop.attributeName + '" - set ' + setTo + ' - ' + testType + ' does not update' if( this._checkNotExisted( prop.type, expected ) ) { await this._model.testAttributeNotExists( t, prop.attributeName, message ); } else { if( prop.type === Boolean ) { await this._model.testAttributeExists( t, prop.attributeName, message ); } else { await this._model.testAttributeValue( t, prop.attributeName, expected, message ); } } } _checkNotExisted( type, expected ) { return ( type === Boolean && expected === 'false' ) || ( type === String && expected === 'null' ) } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/properties/PropertyBehaviour.js class PropertyBehaviourUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runPropertyBehaviourUnitTests(); } runPropertyBehaviourUnitTests() { this._runPropertyBehaviourUnitTests(); } _runPropertyBehaviourUnitTests() { fixture( this._model.componentName + ' All Property Behaviour Unit Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; switch ( prop.type ) { case Boolean: this._testBoolean( prop.name, prop.default ); break; case String: this._testString( prop.name, prop.validValue, prop.default ); break; case Number: this._testNumber( prop.name, prop.validValue, prop.default ); break; default: break; } } } _testBoolean( name, defaultV ) { test( 'Unit Tests - Properties - ' + name + ' - boolean - behaviour', async t => { await this._model.setComponentProperty( t, name, true ); await this._model.testPropertyValue( t, name, true, 'Property "' + name + '" - accepts true' ); await this._model.setComponentProperty( t, name, false ); await this._model.testPropertyValue( t, name, false, 'Property "' + name + '" - accepts false' ); await this._model.setComponentProperty( t, name, defaultV ); } ); } _testString( name, valid, defaultV ) { test( 'Unit Tests - Properties - ' + name + ' - string - behaviour', async t => { await this._model.setComponentProperty( t, name, valid ); await this._model.testPropertyValue( t, name, valid, 'Property "' + name + '" - accepts \'' + valid + '\'' ); await this._model.setComponentProperty( t, name, null ); await this._model.testPropertyValue( t, name, null, 'Property "' + name + '" - accepts null' ); await this._model.setComponentProperty( t, name, valid ); await this._model.setComponentProperty( t, name, 'null' ); await this._model.testPropertyValue( t, name, null, 'Property "' + name + '" - accepts \'null\'' ); await this._model.setComponentProperty( t, name, defaultV ); } ); } _testNumber( name, valid, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - number - behaviour', async t => { await this._model.setComponentProperty( t, name, valid ); await this._model.testPropertyValue( t, name, valid, 'Property "' + name + '" - accepts ' + valid ); await this._model.setComponentProperty( t, name, defaultV ); } ); } } // CONCATENATED MODULE: ./src/lib/testcafe/unit/attributes/AttributeBehaviour.js class AttributeBehaviourUnitTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runAttributeBehaviourUnitTests(); } runAttributeBehaviourUnitTests() { this._runAttributeBehaviourUnitTests(); } _runAttributeBehaviourUnitTests() { fixture( this._model.componentName + ' All Attribute Behaviour Unit Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; console.log( prop ) switch ( prop.type ) { case Boolean: this._testBoolean( prop.attributeName, prop.default ); break; case Number: this._testNumber( prop.attributeName, prop.validValue, prop.default ); break; case String: this._testString( prop.attributeName, prop.validValue, prop.default ); break; default: break; } } } _testBoolean( name, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - boolean - behaviour', async t => { await this._model.setComponentAttribute( t, name, true ); await this._model.testAttributeExists( t, name, 'Attribute "' + name + '" - accepts true' ); await this._model.setComponentAttribute( t, name, false ); await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" - accepts false - attribute not present' ); await this._model.setComponentAttribute( t, name, 'true' ); await this._model.testAttributeExists( t, name, 'Attribute "' + name + '" - accepts \'true\'' ); await this._model.setComponentAttribute( t, name, 'false' ); await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" - accepts \'false\' - attribute not present' ); await this._model.setComponentAttribute( t, name, defaultV ); } ); } _testString( name, valid, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - string - behaviour', async t => { await this._model.setComponentAttribute( t, name, valid ); await this._modal.testAttributeValue( t, name, valid, 'Attribute "' + name + '" - accepts \'' + valid + '\'' ); await this._model.setComponentAttribute( t, name, null ); await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" - accepts null - attribute not present' ); await this._model.setComponentAttribute( t, name, valid ); await this._model.setComponentAttribute( t, name, 'null' ); await this._model.testAttributeNotExists( t, name, 'Attribute "' + name + '" - accepts \'null\' - attribute not present' ); await this._model.setComponentAttribute( t, name, defaultV ); } ); } _testNumber( name, valid, defaultV ) { test( 'Unit Tests - Attributes - ' + name + ' - number - behaviour', async t => { await this._model.setComponentAttribute( t, name, valid ); await this._model.testAttributeValue( t, name, valid.toString(), 'Attribute "' + name + '" - accepts ' + valid ); await this._model.setComponentAttribute( t, name, defaultV ); await this._model.setComponentAttribute( t, name, valid.toString() ); await this._model.testAttributeValue( t, name, valid.toString(), 'Attribute "' + name + '" - accepts \'' + valid + '\'' ); await this._model.setComponentAttribute( t, name, defaultV ); } ); } } // CONCATENATED MODULE: ./src/lib/testcafe/integration/AttributePropertyInvalid.js class AttributePropertyInvalidIntegrationTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { fixture( this._model.componentName + ' All Attribute/Property Invalid Integration Tests' ) .page( this._model.testServer ); this._runAttributePropertyCommonInvalidIntegrationTests(); this._runAttributePropertyNInvalidIntegrationTests(); this._runAttributePropertySBInvalidIntegrationTests(); } runAttributePropertyCommonInvalidIntegrationTests() { fixture( this._model.componentName + ' Common Attribute/Property Invalid Integration Tests' ) .page( this._model.testServer ); this._runAttributePropertyCommonInvalidIntegrationTests(); } _runAttributePropertyCommonInvalidIntegrationTests() { for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; if( prop.type === Boolean || prop.type === Number || prop.type === String ) { test( 'Integration Tests - ' + prop.name + ' - ' + prop.attributeName + ' - common - invalid values', async t => { let expected = await this._model.component[prop.name]; if( prop.type !== Boolean ) { await this._model.setComponentAttribute( t, prop.attributeName, true ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - boolean' ); } if( prop.type !== Number ) { await this._model.setComponentAttribute( t, prop.attributeName, 1 ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - number' ); } if( prop.type !== String ) { await this._model.setComponentAttribute( t, prop.attributeName, 'test' ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - string' ); await this._model.setComponentAttribute( t, prop.attributeName, null ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - null' ); } await this._model.setComponentAttribute( t, prop.attributeName, {} ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - object' ); await this._model.setComponentAttribute( t, prop.attributeName, [] ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - array' ); await this._model.setComponentAttribute( t, prop.attributeName, undefined ); await this._model.testPropertyValue( t, prop.name, expected, 'Property "' + prop.name + '" does not update and does not return invalid attribute value - undefined' ); } ); } } } runAttributePropertyNInvalidIntegrationTests() { fixture( this._model.componentName + ' Number Attribute/Property Invalid Integration Tests' ) .page( this._model.testServer ); this._runAttributePropertyNInvalidIntegrationTests(); } _runAttributePropertyNInvalidIntegrationTests() { for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; if( prop.type === Number ) { test( 'Integration Tests - ' + prop.name + ' - ' + prop.attributeName + ' - number - invalid values', async t => { let expected = await this._model.component[prop.name]; expected = expected.toString(); await this._model.setComponentProperty( t, prop.name, prop.validValue.toString() ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - valid string' ); await this._model.setComponentProperty( t, prop.name, 'test' ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - invalid string' ); await this._model.setComponentProperty( t, prop.name, null ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - null' ); await this._model.setComponentProperty( t, prop.name, {} ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - object' ); await this._model.setComponentProperty( t, prop.name, [] ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - array' ); await this._model.setComponentProperty( t, prop.name, undefined ); await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - undefined' ); } ); } } } runAttributePropertySBInvalidIntegrationTests() { fixture( this._model.componentName + ' String/Number Attribute/Property Invalid Integration Tests' ) .page( this._model.testServer ); this._runAttributePropertySBInvalidIntegrationTests(); } _runAttributePropertySBInvalidIntegrationTests() { for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; if( prop.type === String || prop.type === Boolean ) { let type = 'string'; if( prop.type === Boolean ) type = 'boolean'; test( 'Integration Tests - ' + prop.name + ' - ' + prop.attributeName + ' - ' + type + ' - invalid values', async t => { let expected = await this._model.component[prop.name]; expected = expected.toString(); this._testAttribute( t, prop, expected, 1, 'number' ); this._testAttribute( t, prop, expected, {}, 'object' ); this._testAttribute( t, prop, expected, [], 'array' ); this._testAttribute( t, prop, expected, undefined, 'undefined' ); if( prop.type === Boolean ) { await this._model.setComponentProperty( t, prop.name, 'test' ); if( expected === 'true' ) { await this._model.testAttributeExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - invalid string' ); } else { await this._model.testAttributeNotExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - invalid string' ); } let invert = !prop.default; invert = invert.toString(); await this._model.setComponentProperty( t, prop.name, invert ); if( expected === 'true' ) { await this._model.testAttributeExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - valid string' ); } else { await this._model.testAttributeNotExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - valid string' ); } } else { await this._model.setComponentProperty( t, prop.name, true ); if( expected !== 'null' ) { await this._model.testAttributeValue( t, prop.attributeName, expected, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - boolean' ); } else { await this._model.testAttributeExists( t, prop.attributeName, 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - boolean' ); } } } ); } } } async _testAttribute( t, prop, expected, setTo, testType ) { await this._model.setComponentProperty( t, prop.name, setTo ); let message = 'Attribute "' + prop.attributeName + '" does not update and does not return invalid property value - ' + testType; if( this._checkNotExisted( prop.type, expected ) ) { await this._model.testAttributeNotExists( t, prop.attributeName, message ); } else { if( prop.type === Boolean ) { await this._model.testAttributeExists( t, prop.attributeName, message ); } else { await this._model.testAttributeValue( t, prop.attributeName, expected, message ); } } } _checkNotExisted( type, expected ) { return ( type === Boolean && expected === 'false' ) || ( type === String && expected === 'null' ) } } // CONCATENATED MODULE: ./src/lib/testcafe/integration/AttributePropertyBehaviour.js class AttributePropertyBehaviourIntegrationTests { constructor( componentModel ) { this._model = componentModel; } runAllTests() { this._runAttributePropertyBehaviourUnitTests(); } runAttributePropertyBehaviourUnitTests() { this._runAttributePropertyBehaviourUnitTests(); } _runAttributePropertyBehaviourUnitTests() { fixture( this._model.componentName + ' All Attribute/Property Behaviour Integration Tests' ) .page( this._model.testServer ); for ( let i = 0; i < this._model.properties.length; i++ ) { let prop = this._model.properties[i]; switch ( prop.type ) { case Boolean: this._testBoolean( prop.name, prop.attributeName, prop.default ); break; case String: this._testString( prop.name, prop.attributeName, prop.validValue, prop.default ); break; case Number: this._testNumber( prop.name, prop.attributeName, prop.validValue, prop.default ); break; default: break; } } } _testBoolean( name, attrName, defaultV ) { test( 'Integration Tests - ' + name + ' - boolean - behaviour', async t => { await this._model.setComponentProperty( t, name, true ); await this._model.testAttributeExists( t, attrName, 'Attribute "' + name + '" updates and returns property value - true' ); await this._model.setComponentProperty( t, name, false ); await this._model.testAttributeNotExists( t, attrName, 'Attribute "' + name + '" updates and returns property value - false' ); await this._model.setComponentAttribute( t, attrName, true ); await this._model.testPropertyValue( t, name, true, 'Property "' + name + '" updates and returns attribute value - true' ); await this._model.setComponentAttribute( t, attrName, false ); await this._model.testPropertyValue( t, name, false, 'Property "' + name + '" updates and returns attribute value - false' ); await this._model.setComponentAttribute( t, attrName, 'true' ); await this._model.testPropertyValue( t, name, true, 'Property "' + name + '" updates and returns attribute value - \'true\'' ); await this._model.setComponentAttribute( t, attrName, 'false' ); await this._model.testPropertyValue( t, name, false, 'Property "' + name + '" updates and returns attribute value - \'false\'' ); await this._model.setComponentProperty( t, name, defaultV ); } ); } _testString( name, attrName, valid, defaultV ) { test( 'Integration Tests - ' + name + ' - string - behaviour', async t => { await this._model.setComponentProperty( t, name, valid ); await this._model.testAttributeValue( t, attrName, valid, 'Attribute "' + name + '" updates and returns property value - ' + valid ); await this._model.setComponentProperty( t, name, null ); await this._model.testAttributeNotExists( t, attrName, 'Attribute "' + name + '" updates and returns property value - null' ); await this._model.setComponentAttribute( t, attrName, valid ); await this._model.setComponentProperty( t, name, 'null' ); await this._model.testAttributeNotExists( t, attrName, 'Attribute "' + name + '" updates and returns property value - \'null\'' ); await this._model.setComponentProperty( t, name, defaultV ); await this._model.setComponentAttribute( t, attrName, valid ); await this._model.testPropertyValue( t, name, valid, 'Property "' + name + '" updates and returns attribute value - ' + valid ); await this._model.setComponentAttribute( t, attrName, null ); await this._model.testPropertyValue( t, name, null, 'Property "' + name + '" updates and returns attribute value - null' ); await this._model.setComponentProperty( t, name, valid ); await this._model.setComponentAttribute( t, attrName, 'null' ); await this._model.testPropertyValue( t, name, null, 'Property "' + name + '" updates and returns attribute value - \'null\'' ); await this._model.setComponentAttribute( t, attrName, defaultV ); } ); } _testNumber( name, attrName, valid, defaultV ) { test( 'Integration Tests - ' + name + ' - number - behaviour', async t => { await this._model.setComponentProperty( t, name, valid ); await this._model.testAttributeValue( t, attrName, valid.toString(), 'Attribute "' + name + '" updates and returns property value - ' + valid ); await this._model.setComponentProperty( t, name, defaultV ); await this._model.setComponentAttribute( t, attrName, valid ); await this._model.testPropertyValue( t, name, valid, 'Property "' + name + '" updates and returns attribute value - ' + valid ); await this._model.setComponentAttribute( t, attrName, defaultV ); await this._model.setComponentAttribute( t, attrName, valid.toString() ); await this._model.testPropertyValue( t, name, valid, 'Property "' + name + '" updates and returns attribute value - \'' + valid + '\'' ); await this._model.setComponentAttribute( t, attrName, defaultV ); } ); } } // CONCATENATED MODULE: ./src/lib/testcafe/main.js class TestCafeComponentTestSuite { constructor( config ) { this._model = new ComponentModel( config ); this._commonComponentsTests = new CommonComponentTests( this.model ); this._propertyDefaultsUnitTests = new PropertyDefaultsUnitTests( this.model ); this._attributeDefaultsUnitTests = new AttributeDefaultUnitTests( this.model ); this._propertyInvalidUnitTests = new PropertyInvalidUnitTests( this.model ); this._attributeInvalidUnitTests = new AttributeInvalidNUnitTests( this.model ); this._propertyBehaviourUnitTests = new PropertyBehaviourUnitTests( this.model ); this._attributeBehaviourUnitTests = new AttributeBehaviourUnitTests( this.model ); this._attributePropertyInvalidIntegrationTests = new AttributePropertyInvalidIntegrationTests( this.model ); this._attributePropertyBehaviourIntegrationTests = new AttributePropertyBehaviourIntegrationTests( this.model ); } get model() { return this._model; } get commonComponentTests() { return this._commonComponentsTests; } get propertyDefaultsUnitTests() { return this._propertyDefaultsUnitTests; } get attributeDefaultsUnitTests() { return this._attributeDefaultsUnitTests; } get propertyInvalidUnitTests() { return this._propertyInvalidUnitTests; } get attributeInvalidUnitTests() { return this._attributeInvalidUnitTests; } get propertyBehaviourUnitTests() { return this._propertyBehaviourUnitTests; } get attributeBehaviourUnitTests() { return this._attributeBehaviourUnitTests; } get attributePropertyInvalidIntegrationTests() { return this._attributePropertyInvalidIntegrationTests; } get attributePropertyBehaviourIntegrationTests() { return this._attributePropertyBehaviourIntegrationTests; } runAllTests() { this.commonComponentTests.runAllTests(); if( this._model.properties && this._model.properties.length && this._model.properties.length > 0 ) { this.propertyDefaultsUnitTests.runAllTests(); this.attributeDefaultsUnitTests.runAllTests(); this.propertyInvalidUnitTests.runAllTests(); this.attributeInvalidUni