diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/AlertFixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/AlertFixture.js index d3fa11019..45307d3f5 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/AlertFixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/AlertFixture.js @@ -1,63 +1,65 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var Fixture = require('br/test/Fixture'); + /** + * @name br.test.AlertFixture * @class * The AlertFixture allows for testing of browser alerts. * @interface */ -br.test.AlertFixture = function() -{ - +function AlertFixture() { }; +br.inherit(AlertFixture, Fixture); -br.Core.inherit(br.test.AlertFixture, br.test.Fixture); - -br.test.AlertFixture.prototype.setUp = function() -{ +AlertFixture.prototype.setUp = function() { this.m_pAlertStack = []; this.m_fOriginalWindowAlertFunction = window.alert; - - var oThis = this; - window.alert = function(sAlert) - { - oThis.m_pAlertStack.push(sAlert); + + var self = this; + window.alert = function(alertMessage) { + self.m_pAlertStack.push(alertMessage); }; }; -br.test.AlertFixture.prototype.tearDown = function() -{ +AlertFixture.prototype.tearDown = function() { window.alert = this.m_fOriginalWindowAlertFunction; - assertTrue("there were alerts triggered that were not expected in the test", this.m_pAlertStack.length === 0); + assertTrue('there were alerts triggered that were not expected in the test', this.m_pAlertStack.length === 0); }; -br.test.AlertFixture.prototype.doGiven = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "given is not supported by AlertFixture"); +AlertFixture.prototype.doGiven = function(propertyNameName, value) { + throw new Errors.InvalidTestError('given is not supported by AlertFixture'); }; -br.test.AlertFixture.prototype.doWhen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "when is not supported by AlertFixture"); +AlertFixture.prototype.doWhen = function(propertyNameName, value) { + throw new Errors.InvalidTestError('when is not supported by AlertFixture'); }; -br.test.AlertFixture.prototype.doThen = function(sPropertyName, vValue) -{ +AlertFixture.prototype.doThen = function(propertyNameName, value) { if (this.m_pAlertStack.length < 1) { - fail("no alerts were triggered"); + fail('no alerts were triggered'); } - assertEquals("expected alert message '" + vValue + "', but was '" + this.m_pAlertStack[0] + "'", vValue, this.m_pAlertStack[0]); + + assertEquals( + "expected alert message '" + value + "', but was '" + this.m_pAlertStack[0] + "'", + value, + this.m_pAlertStack[0] + ); + this.m_pAlertStack.shift(); }; -br.test.AlertFixture.prototype.addSubFixtures = function(oFixtureRegistry) -{ +AlertFixture.prototype.addSubFixtures = function(fixtureRegistry) { }; - -br.test.AlertFixture.prototype.canHandleExactMatch = function() -{ +AlertFixture.prototype.canHandleExactMatch = function() { return true; }; -br.test.AlertFixture.prototype.canHandleProperty = function(sProperty) -{ +AlertFixture.prototype.canHandleProperty = function(propertyName) { return false; }; + +module.exports = AlertFixture; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Fixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Fixture.js index a36878ecf..5d306f505 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Fixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Fixture.js @@ -1,91 +1,89 @@ +'use strict'; + +var Errors = require('br/Errors'); + /** + * @name br.test.Fixture * @interface * @class - * Fixture is the interface for individual fixtures added to the GWTTestRunner. The purpose of - * a Fixture is to enable tests to manipulate and access a specific area of the system under tests using the - * GWT (given-when-then) BDD format. + * Fixture is the interface for individual fixtures added to the GWTTestRunner. The purpose of a Fixture + * is to enable tests to manipulate and access a specific area of the system under tests using the GWT + * (given-when-then) BDD format. */ -br.test.Fixture = function() -{ -}; +function Fixture() { +} /** - * This method is called just before a GWT test. This optional interface method can be implemented if the fixture - * is required to correctly set up the system-under-test before each test. + * This method is called just before a GWT test. This optional interface method can be implemented if the fixture is + * required to correctly set up the system-under-test before each test. */ -br.test.Fixture.prototype.setUp = function() -{ +Fixture.prototype.setUp = function() { // optional interface method }; /** - * This method is called just after a GWT test. This optional interface method can be implemented if the fixture - * is required to correctly tear down the system-under-test after each test or to reset any state held in the fixture's - * implementation. + * This method is called just after a GWT test. This optional interface method can be implemented if the fixture is + * required to correctly tear down the system-under-test after each test or to reset any state held in the fixture's + * implementation. */ -br.test.Fixture.prototype.tearDown = function() -{ +Fixture.prototype.tearDown = function() { // optional interface method }; /** * This optional interface method can be implemented by a Fixture for a complex system which can be conceptually - * decomposed into separate sub-systems, enabling the fixture to delegate the handling of some fixture properties - * to the sub-fixtures. This method is called by the GWTTestRunner. - * - * @param {br.test.FixtureRegistry} oFixtureRegistry The registry to which the fixtures should be registered. + * decomposed into separate sub-systems, enabling the fixture to delegate the handling of some fixture properties to + * the sub-fixtures. This method is called by the GWTTestRunner. + * + * @param {br.test.FixtureRegistry} fixtureRegistry The registry to which the fixtures should be registered. */ -br.test.Fixture.prototype.addSubFixtures = function(oFixtureRegistry) -{ +Fixture.prototype.addSubFixtures = function(fixtureRegistry) { // optional interface method }; -br.test.Fixture.prototype.canHandleExactMatch = function() -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "Fixture.canHandleExactMatch() has not been implemented."); +Fixture.prototype.canHandleExactMatch = function() { + throw new Errors.UnimplementedInterfaceError('Fixture.canHandleExactMatch() has not been implemented.'); }; /** - * This method is called by the GWTTestRunner to check whether a property used in a GWT test is supported by - * the fixture. - * - * @param {String} sProperty the property name to check. - * @returns {Boolean} true if the fixture handles the property; false otherwise + * This method is called by the GWTTestRunner to check whether a property used in a GWT test is supported by the + * fixture. + * + * @param {String} propertyName the property name to check. + * @returns {Boolean} true if the fixture handles the property; false otherwise. */ -br.test.Fixture.prototype.canHandleProperty = function(sProperty) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "Fixture.canHandleProperty() has not been implemented."); +Fixture.prototype.canHandleProperty = function(propertyName) { + throw new Errors.UnimplementedInterfaceError('Fixture.canHandleProperty() has not been implemented.'); }; /** * This method is called in order to manipulate a property on the system under test in a given clause. - * - * @param {String} sPropertyName The property to be changed. - * @param {String} vValue The new value of the property. + * + * @param {String} propertyName The property to be changed. + * @param {String} value The new value of the property. */ -br.test.Fixture.prototype.doGiven = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "Fixture.doGiven() has not been implemented."); +Fixture.prototype.doGiven = function(propertyName, value) { + throw new Errors.UnimplementedInterfaceError('Fixture.doGiven() has not been implemented.'); }; /** * This method is called in order to manipulate a property on the system under test in a when clause. - * - * @param {String} sPropertyName The property to be changed. - * @param {String} vValue The new value of the property. + * + * @param {String} propertyName The property to be changed. + * @param {String} value The new value of the property. */ -br.test.Fixture.prototype.doWhen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "Fixture.doWhen() has not been implemented."); +Fixture.prototype.doWhen = function(propertyName, value) { + throw new Errors.UnimplementedInterfaceError('Fixture.doWhen() has not been implemented.'); }; /** * This method is called in order to assert a property's value on the system under test. - * - * @param {String} sPropertyName The property name to assert. - * @param {String} vValue The value to assert. + * + * @param {String} propertyName The property name to assert. + * @param {String} value The value to assert. */ -br.test.Fixture.prototype.doThen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "Fixture.doThen() has not been implemented."); +Fixture.prototype.doThen = function(propertyName, value) { + throw new Errors.UnimplementedInterfaceError('Fixture.doThen() has not been implemented.'); }; + +module.exports = Fixture; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureFactory.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureFactory.js index e52dfe9bf..b9c3af4bd 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureFactory.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureFactory.js @@ -1,22 +1,27 @@ +'use strict'; + +var Errors = require('br/Errors'); + /** - * Constructs a FixtureFactory . + * @name br.test.FixtureFactory + * Constructs a FixtureFactory. * @constructor * @interface * @class - * An implementing FixtureFactory can have an optional setUp method which will be called - * before each test is executed and can be used to reset the state of a test and its stubs. + * An implementing FixtureFactory can have an optional setUp method which will be called before each test + * is executed and can be used to reset the state of a test and its stubs. */ -br.test.FixtureFactory = function() -{ +function FixtureFactory() { }; /** - * This method is called once by the test-runner after the FixtureFactory is constructed. The implementation - * should add to the test runner all the fixtures that are needed by the tests. - * - * @param {br.test.FixtureRegistry} oFixtureRegistry The registry to which the fixtures should be registered. + * This method is called once by the test-runner after the FixtureFactory is constructed. The implementation should add + * to the test runner all the fixtures that are needed by the tests. + * + * @param {br.test.FixtureRegistry} fixtureRegistry The registry to which the fixtures should be registered. */ -br.test.FixtureFactory.prototype.addFixtures = function(oFixtureRegistry) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "FixtureFactory.addFixtures() has not been implemented."); +FixtureFactory.prototype.addFixtures = function(fixtureRegistry) { + throw new Errors.UnimplementedInterfaceError('FixtureFactory.addFixtures() has not been implemented.'); }; + +module.exports = FixtureFactory; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureRegistry.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureRegistry.js index 070793f1d..1bdcba11f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureRegistry.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/FixtureRegistry.js @@ -1,19 +1,21 @@ +'use strict'; + /** + * @name br.test.FixtureRegistry * @class - * The FixtureRegistry allows for registration of fixtures for a - * specified scope. + * The FixtureRegistry allows for registration of fixtures for a specified scope. * @interface */ -br.test.FixtureRegistry = function() -{ +function FixtureRegistry() { }; /** - * Adds a fixture to the registry. + * Adds a fixture to the registry. * - * @param {String} sScope The scope to which the fixture should be registered. - * @param {br.test.Fixture} oFixture The fixture to register. + * @param {String} scope The scope to which the fixture should be registered. + * @param {br.test.Fixture} fixture The fixture to register. */ -br.test.FixtureRegistry.prototype.addFixture = function(sScope, oFixture) -{ +FixtureRegistry.prototype.addFixture = function(scope, fixture) { }; + +module.exports = FixtureRegistry; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtFailureMessage.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtFailureMessage.js index d4e244d52..b08fa1b00 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtFailureMessage.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtFailureMessage.js @@ -1,20 +1,25 @@ -/** - * @private - */ -br.test.GwtFailureMessage = function() { - _errorMsg = ""; - _statck = ""; -} -br.test.GwtFailureMessage.prototype.setMessage = function(sMsg) { - this._errorMsg = sMsg; +'use strict'; + +/** @private */ +function GwtFailureMessage() { + this._errorMsg = ''; + this._statck = ''; } -br.test.GwtFailureMessage.prototype.getMessage = function() { + +GwtFailureMessage.prototype.setMessage = function(message) { + this._errorMsg = message; +}; + +GwtFailureMessage.prototype.getMessage = function() { return this._errorMsg; -} -br.test.GwtFailureMessage.prototype.setStack = function(sStack) { - this._statck = sStack; -} -br.test.GwtFailureMessage.prototype.getStack = function() { +}; + +GwtFailureMessage.prototype.setStack = function(stack) { + this._statck = stack; +}; + +GwtFailureMessage.prototype.getStack = function() { return this._statck; -} +}; +module.exports = GwtFailureMessage; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtTestRunner.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtTestRunner.js index 68ddaed48..7f5418b9c 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtTestRunner.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/GwtTestRunner.js @@ -1,12 +1,21 @@ -br.Core.thirdparty("jasmine"); +'use strict'; + +require('jasmine'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var TestFixture = require('br/test/TestFixture'); +var TimeFixture = require('br/test/TimeFixture'); +var TimeUtility = require('br/test/TimeUtility'); +var FixtureFactory = require('br/test/FixtureFactory'); +var FixtureRegistry = require('br/test/FixtureRegistry'); /** * @private * @constructor - * * @implements br.test.FixtureRegistry */ -br.test.GwtTestRunner = function(sFixtureFactoryClass) { +function GwtTestRunner(sFixtureFactoryClass) { var Utility = require('br/core/Utility'); this.m_pFixtures = []; @@ -14,47 +23,47 @@ br.test.GwtTestRunner = function(sFixtureFactoryClass) { var fFixtureFactoryClass; try { fFixtureFactoryClass = Utility.locate(sFixtureFactoryClass); - } catch(e) { - throw new br.Errors.CustomError("InvalidFactoryError", "An error occured in br.test.GwtTestRunner when creating the fixture factory " + + } catch (e) { + throw new Errors.CustomError("InvalidFactoryError", "An error occured in br.test.GwtTestRunner when creating the fixture factory " + "(" + sFixtureFactoryClass + "): " + e.message); } if (typeof fFixtureFactoryClass === 'undefined') { - throw new br.Errors.CustomError("InvalidFactoryError", "Fixture factory class '" + sFixtureFactoryClass + "' does not exist."); + throw new Errors.CustomError("InvalidFactoryError", "Fixture factory class '" + sFixtureFactoryClass + "' does not exist."); } try { this.m_oFixtureFactory = new fFixtureFactoryClass(); - } catch(e) { - throw new br.Errors.CustomError("InvalidFactoryError", "An error occured in br.test.GwtTestRunner when creating the fixture factory " + + } catch (e) { + throw new Errors.CustomError("InvalidFactoryError", "An error occured in br.test.GwtTestRunner when creating the fixture factory " + "(" + sFixtureFactoryClass + "): " + e.message); } - if(!br.Core.fulfills(this.m_oFixtureFactory, br.test.FixtureFactory)) { - throw new br.Errors.CustomError("InvalidFactoryError", "The provided fixture factory (" + sFixtureFactoryClass + + if (!br.fulfills(this.m_oFixtureFactory, FixtureFactory)) { + throw new Errors.CustomError("InvalidFactoryError", "The provided fixture factory (" + sFixtureFactoryClass + ") does not implement br.test.FixtureFactory"); } this.m_oFixtureFactory.addFixtures(this); - this.addFixture("test", new br.test.TestFixture(this)); - this.addFixture("time", new br.test.TimeFixture(br.test.TimeUtility)); - - this.m_fDoGiven = br.test.GwtTestRunner.createTestMethod(this, "doGiven"), - this.m_fDoWhen = br.test.GwtTestRunner.createTestMethod(this, "doWhen"), - this.m_fDoThen = br.test.GwtTestRunner.createTestMethod(this, "doThen"), - this.m_fDoAnd = br.test.GwtTestRunner.createTestMethod(this, "doAnd"); - this.m_fStartingContinuesFrom = br.test.GwtTestRunner.createTestMethod(this, "startingContinuesFrom"); - this.m_fFinishedContinuesFrom = br.test.GwtTestRunner.createTestMethod(this, "finishedContinuesFrom"); + this.addFixture("test", new TestFixture(this)); + this.addFixture("time", new TimeFixture(TimeUtility)); + + this.m_fDoGiven = GwtTestRunner.createTestMethod(this, "doGiven"), + this.m_fDoWhen = GwtTestRunner.createTestMethod(this, "doWhen"), + this.m_fDoThen = GwtTestRunner.createTestMethod(this, "doThen"), + this.m_fDoAnd = GwtTestRunner.createTestMethod(this, "doAnd"); + this.m_fStartingContinuesFrom = GwtTestRunner.createTestMethod(this, "startingContinuesFrom"); + this.m_fFinishedContinuesFrom = GwtTestRunner.createTestMethod(this, "finishedContinuesFrom"); }; -br.Core.inherit(br.test.GwtTestRunner, br.test.FixtureRegistry); +br.inherit(GwtTestRunner, FixtureRegistry); -br.test.GwtTestRunner.m_mTests = {}; -br.test.GwtTestRunner.m_mSuites = {}; -br.test.GwtTestRunner.INIT_PHASE = 1; -br.test.GwtTestRunner.GIVEN_PHASE = 2; -br.test.GwtTestRunner.WHEN_PHASE = 3; -br.test.GwtTestRunner.THEN_PHASE = 4; +GwtTestRunner.m_mTests = {}; +GwtTestRunner.m_mSuites = {}; +GwtTestRunner.INIT_PHASE = 1; +GwtTestRunner.GIVEN_PHASE = 2; +GwtTestRunner.WHEN_PHASE = 3; +GwtTestRunner.THEN_PHASE = 4; // *** Static Methods *** @@ -62,60 +71,43 @@ br.test.GwtTestRunner.THEN_PHASE = 4; /** * Static method that needs to be called before any Jasmine tests will execute. */ -br.test.GwtTestRunner.initialize = function() -{ - if(!window.fixtures) - { - window.fixtures = br.test.GwtTestRunner.createTestMethod(br.test.GwtTestRunner, "initializeTest"); +GwtTestRunner.initialize = function() { + if (!window.fixtures) { + window.fixtures = GwtTestRunner.createTestMethod(GwtTestRunner, "initializeTest"); } }; -/** - * @private - */ -br.test.GwtTestRunner.createTestMethod = function(oTestRunner, sMethod) -{ - return function(sStatement) - { +/** @private */ +GwtTestRunner.createTestMethod = function(oTestRunner, sMethod) { + return function(sStatement) { oTestRunner[sMethod](sStatement); }; }; -/** - * @private - */ -br.test.GwtTestRunner.createProxyDescribeFunction = function(fOrigDescribeFunction, bIsXDescribe) -{ - return function(description, closure) - { +/** @private */ +GwtTestRunner.createProxyDescribeFunction = function(fOrigDescribeFunction, bIsXDescribe) { + return function(description, closure) { var pInvalidChars = ["\\","/",":","*","?","<",">"] - for (var i = 0; i < pInvalidChars.length; i++) - { + for (var i = 0; i < pInvalidChars.length; i++) { var cInvalidChar = pInvalidChars[i]; - if (description.indexOf(cInvalidChar) > -1) - { - throw new br.Errors.CustomError("InvalidSuiteError", "Invalid character '" + cInvalidChar + "' in test suite '"+ description + "'."); + if (description.indexOf(cInvalidChar) > -1) { + throw new Errors.CustomError("InvalidSuiteError", "Invalid character '" + cInvalidChar + "' in test suite '"+ description + "'."); } } - if (br.test.GwtTestRunner.m_mSuites[description]) - { - throw new br.Errors.CustomError("InvalidSuiteError", "The test suite '" + description + "' has already been defined."); - } - else - { - br.test.GwtTestRunner.m_mSuites[description] = closure; + if (GwtTestRunner.m_mSuites[description]) { + throw new Errors.CustomError("InvalidSuiteError", "The test suite '" + description + "' has already been defined."); + } else { + GwtTestRunner.m_mSuites[description] = closure; var jasmineDescribeReturnValue = fOrigDescribeFunction.call(this, description, closure); - if(bIsXDescribe) - { + if (bIsXDescribe) { var fOrigIt = it; var fOrigFixtures = fixtures; var fOrigGetEnv = jasmine.getEnv; - try - { - it = br.test.GwtTestRunner.capturingItFunction; + try { + it = GwtTestRunner.capturingItFunction; fixtures = function() {}; jasmine.getEnv = function() { @@ -129,9 +121,7 @@ br.test.GwtTestRunner.createProxyDescribeFunction = function(fOrigDescribeFuncti }; closure(); - } - finally - { + } finally { it = fOrigIt; fixtures = fOrigFixtures; jasmine.getEnv = fOrigGetEnv; @@ -143,24 +133,17 @@ br.test.GwtTestRunner.createProxyDescribeFunction = function(fOrigDescribeFuncti }; }; -/** - * @private - */ -br.test.GwtTestRunner.createProxyItFunction = function(fOrigItFunction) -{ - return function(description, closure) - { +/** @private */ +GwtTestRunner.createProxyItFunction = function(fOrigItFunction) { + return function(description, closure) { var sSuiteFullName = jasmine.getEnv().currentSuite.getFullName(); var sSuiteNamespacedTestName = sSuiteFullName + "::" + description; - if (br.test.GwtTestRunner.m_mTests[sSuiteNamespacedTestName] && !description.match("encountered a declaration exception")) - { - throw new br.Errors.CustomError("DuplicateTestError", "The test '" + sSuiteNamespacedTestName + "' has already been defined."); - } - else - { + if (GwtTestRunner.m_mTests[sSuiteNamespacedTestName] && !description.match("encountered a declaration exception")) { + throw new Errors.CustomError("DuplicateTestError", "The test '" + sSuiteNamespacedTestName + "' has already been defined."); + } else { closure.suiteName = sSuiteFullName; - br.test.GwtTestRunner.m_mTests[sSuiteNamespacedTestName] = closure; + GwtTestRunner.m_mTests[sSuiteNamespacedTestName] = closure; var jasmineItReturnValue = fOrigItFunction.call(this, description, closure); return jasmineItReturnValue; @@ -171,121 +154,100 @@ br.test.GwtTestRunner.createProxyItFunction = function(fOrigItFunction) // *** FixtureRegistry Interface *** -br.test.GwtTestRunner.prototype.addFixture = function(sScope, oFixture) -{ +GwtTestRunner.prototype.addFixture = function(sScope, oFixture) { + var SubFixtureRegistry = require('br/test/SubFixtureRegistry'); + this.m_pFixtures.push({scopeMatcher:new RegExp("^" + sScope + "(\\..+|$)"), scopeLength:sScope.length + 1, fixture:oFixture}); - oFixture.addSubFixtures(new br.test.SubFixtureRegistry(this, sScope)); + oFixture.addSubFixtures(new SubFixtureRegistry(this, sScope)); }; // *** Public Methods *** -/** - * @private - */ -br.test.GwtTestRunner.initializeTest = function(sFixtureFactoryClass) -{ - var oTestRunner = new br.test.GwtTestRunner(sFixtureFactoryClass); +/** @private */ +GwtTestRunner.initializeTest = function(sFixtureFactoryClass) { + var oTestRunner = new GwtTestRunner(sFixtureFactoryClass); beforeEach(this.createTestMethod(oTestRunner, "startTest")); afterEach(this.createTestMethod(oTestRunner, "endTest")); }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.startTest = function() -{ +/** @private */ +GwtTestRunner.prototype.startTest = function() { require("br/ServiceRegistry").clear(); - given = this.m_fDoGiven; - when = this.m_fDoWhen; - then = this.m_fDoThen; - and = this.m_fDoAnd; - startingContinuesFrom = this.m_fStartingContinuesFrom; - finishedContinuesFrom = this.m_fFinishedContinuesFrom; + window.given = this.m_fDoGiven; + window.when = this.m_fDoWhen; + window.then = this.m_fDoThen; + window.and = this.m_fDoAnd; + window.startingContinuesFrom = this.m_fStartingContinuesFrom; + window.finishedContinuesFrom = this.m_fFinishedContinuesFrom; this.m_bTestFailed = false; - this.m_nTestPhase = br.test.GwtTestRunner.INIT_PHASE; + this.m_nTestPhase = GwtTestRunner.INIT_PHASE; - if(this.m_oFixtureFactory.setUp) { + if (this.m_oFixtureFactory.setUp) { try { this.m_oFixtureFactory.setUp(); - } - catch(e) { - throw new br.Errors.CustomError("TestSetUpError", e.message, - "Error occured in br.test.GwtTestRunner.prototype.startTest() calling this.m_oFixtureFactory.setUp()"); + } catch (e) { + throw new Errors.CustomError("TestSetUpError", e.message, + "Error occured in GwtTestRunner.prototype.startTest() calling this.m_oFixtureFactory.setUp()"); } } - for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) - { + for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) { var oFixture = this.m_pFixtures[i].fixture; try { oFixture.setUp(); } - catch(e) { - throw new br.Errors.CustomError("TestSetUpError", e.message, - "Error occured in br.test.GwtTestRunner.prototype.startTest() calling oFixture.setUp()"); + catch (e) { + throw new Errors.CustomError("TestSetUpError", e.message, + "Error occured in GwtTestRunner.prototype.startTest() calling oFixture.setUp()"); } } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.endTest = function() -{ - for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) - { +/** @private */ +GwtTestRunner.prototype.endTest = function() { + for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) { var oFixture = this.m_pFixtures[i].fixture; try { oFixture.tearDown(); } - catch(e) { - throw new br.Errors.CustomError("TestTearDownError", e.message, - "Error occured in br.test.GwtTestRunner.prototype.endTest() calling oFixture.tearDown()"); + catch (e) { + throw new Errors.CustomError("TestTearDownError", e.message, + "Error occured in GwtTestRunner.prototype.endTest() calling oFixture.tearDown()"); } } - if (document.body.hasChildNodes()) - { - for (var i = 0, j = document.body.childNodes.length; i < j; i++) - { + if (document.body.hasChildNodes()) { + for (var i = 0, j = document.body.childNodes.length; i < j; i++) { document.body.removeChild(document.body.childNodes[0]); } } - if(!this.m_bTestFailed && ((this.m_nTestPhase == br.test.GwtTestRunner.GIVEN_PHASE) || - (this.m_nTestPhase == br.test.GwtTestRunner.WHEN_PHASE))) - { - throw new br.Errors.CustomError("UnterminatedTestError", "Tests must finish with one or more 'THEN' statements"); + if (!this.m_bTestFailed && ((this.m_nTestPhase == GwtTestRunner.GIVEN_PHASE) || + (this.m_nTestPhase == GwtTestRunner.WHEN_PHASE))) { + throw new Errors.CustomError("UnterminatedTestError", "Tests must finish with one or more 'THEN' statements"); } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.startingContinuesFrom = function(description) -{ - this.m_nTestPhase = br.test.GwtTestRunner.INIT_PHASE; +/** @private */ +GwtTestRunner.prototype.startingContinuesFrom = function(description) { + this.m_nTestPhase = GwtTestRunner.INIT_PHASE; var sSuiteNamespacedTestName; - if(description.match(/::/)) - { + if (description.match(/::/)) { sSuiteNamespacedTestName = description; - } - else - { + } else { var sSuiteFullName = (this.currentSuiteName) ? this.currentSuiteName : jasmine.getEnv().currentSpec.suite.getFullName(); sSuiteNamespacedTestName = sSuiteFullName + "::" + description; } - var fTest = br.test.GwtTestRunner.m_mTests[sSuiteNamespacedTestName]; + var fTest = GwtTestRunner.m_mTests[sSuiteNamespacedTestName]; - if(!fTest) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "attempt to continue from a test that doesn't exist: '" + sSuiteNamespacedTestName + "'"); + if (!fTest) { + throw new Errors.InvalidTestError("attempt to continue from a test that doesn't exist: '" + sSuiteNamespacedTestName + "'"); } this.currentSuiteName = fTest.suiteName; @@ -293,106 +255,72 @@ br.test.GwtTestRunner.prototype.startingContinuesFrom = function(description) this.currentSuiteName = null; }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.finishedContinuesFrom = function() -{ - this.m_nTestPhase = br.test.GwtTestRunner.GIVEN_PHASE; +/** @private */ +GwtTestRunner.prototype.finishedContinuesFrom = function() { + this.m_nTestPhase = GwtTestRunner.GIVEN_PHASE; }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.doGiven = function(sStatement) -{ - var TimeUtility = br.test.TimeUtility; - try - { +/** @private */ +GwtTestRunner.prototype.doGiven = function(sStatement) { + try { TimeUtility.captureTimerFunctions(); - var oStatement = this._parseStatement(sStatement, br.test.GwtTestRunner.GIVEN_PHASE); + var oStatement = this._parseStatement(sStatement, GwtTestRunner.GIVEN_PHASE); oStatement.fixture.doGiven(oStatement.propertyName, oStatement.propertyValue); TimeUtility.nextStep(); - } - catch(e) - { + } catch (e) { this._handleError(e); - } - finally - { + } finally { TimeUtility.releaseTimerFunctions(); } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.doWhen = function(sStatement) -{ - var TimeUtility = br.test.TimeUtility; - try - { +/** @private */ +GwtTestRunner.prototype.doWhen = function(sStatement) { + try { TimeUtility.captureTimerFunctions(); - var oStatement = this._parseStatement(sStatement, br.test.GwtTestRunner.WHEN_PHASE); + var oStatement = this._parseStatement(sStatement, GwtTestRunner.WHEN_PHASE); oStatement.fixture.doWhen(oStatement.propertyName, oStatement.propertyValue); TimeUtility.nextStep(); - } - catch(e) - { + } catch (e) { this._handleError(e); - } - finally - { + } finally { TimeUtility.releaseTimerFunctions(); } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.doThen = function(sStatement) -{ - var TimeUtility = br.test.TimeUtility; +/** @private */ +GwtTestRunner.prototype.doThen = function(sStatement) { - try - { + try { TimeUtility.captureTimerFunctions(); - var oStatement = this._parseStatement(sStatement, br.test.GwtTestRunner.THEN_PHASE); + var oStatement = this._parseStatement(sStatement, GwtTestRunner.THEN_PHASE); oStatement.fixture.doThen(oStatement.propertyName, oStatement.propertyValue); TimeUtility.nextStep(); - } - catch(e) - { + } catch (e) { this._handleError(e); - } - finally - { + } finally { TimeUtility.releaseTimerFunctions(); } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype.doAnd = function(sStatement, oMessage) -{ - switch(this.m_nTestPhase) - { - case br.test.GwtTestRunner.GIVEN_PHASE: +/** @private */ +GwtTestRunner.prototype.doAnd = function(sStatement, oMessage) { + switch (this.m_nTestPhase) { + case GwtTestRunner.GIVEN_PHASE: this.doGiven(sStatement); break; - case br.test.GwtTestRunner.WHEN_PHASE: + case GwtTestRunner.WHEN_PHASE: this.doWhen(sStatement); break; - case br.test.GwtTestRunner.THEN_PHASE: + case GwtTestRunner.THEN_PHASE: this.doThen(sStatement, oMessage); break; @@ -401,72 +329,43 @@ br.test.GwtTestRunner.prototype.doAnd = function(sStatement, oMessage) } }; - -// *** Private Methods *** - -/** - * @private - */ -br.test.GwtTestRunner.prototype._handleError = function(e) -{ +/** @private */ +GwtTestRunner.prototype._handleError = function(e) { this.m_bTestFailed = true; - if(e.getMessage) - { + if (e.getMessage) { fail(e.getMessage()); - } - else - { + } else { throw(e); } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype._updatePhase = function(nPhase, sStatement) -{ - if(nPhase == br.test.GwtTestRunner.GIVEN_PHASE) - { - if(this.m_nTestPhase == br.test.GwtTestRunner.INIT_PHASE) - { - this.m_nTestPhase = br.test.GwtTestRunner.GIVEN_PHASE; - } - else if(this.m_nTestPhase != br.test.GwtTestRunner.GIVEN_PHASE) - { +/** @private */ +GwtTestRunner.prototype._updatePhase = function(nPhase, sStatement) { + if (nPhase == GwtTestRunner.GIVEN_PHASE) { + if (this.m_nTestPhase == GwtTestRunner.INIT_PHASE) { + this.m_nTestPhase = GwtTestRunner.GIVEN_PHASE; + } else if (this.m_nTestPhase != GwtTestRunner.GIVEN_PHASE) { this._throwError("InvalidPhaseError", sStatement, "'GIVEN' statements must occur before 'WHEN' and 'THEN' statements."); } - } - else if(nPhase == br.test.GwtTestRunner.WHEN_PHASE) - { - if(this.m_nTestPhase == br.test.GwtTestRunner.GIVEN_PHASE) - { - this.m_nTestPhase = br.test.GwtTestRunner.WHEN_PHASE; - } - else if(this.m_nTestPhase != br.test.GwtTestRunner.WHEN_PHASE) - { + } else if (nPhase == GwtTestRunner.WHEN_PHASE) { + if (this.m_nTestPhase == GwtTestRunner.GIVEN_PHASE) { + this.m_nTestPhase = GwtTestRunner.WHEN_PHASE; + } else if (this.m_nTestPhase != GwtTestRunner.WHEN_PHASE) { this._throwError("InvalidPhaseError", sStatement, "'WHEN' statements must occur after 'GIVEN' statements, but before 'THEN' statements."); } - } - else if(nPhase == br.test.GwtTestRunner.THEN_PHASE) - { - if((this.m_nTestPhase == br.test.GwtTestRunner.GIVEN_PHASE) || - (this.m_nTestPhase == br.test.GwtTestRunner.WHEN_PHASE)) - { - this.m_nTestPhase = br.test.GwtTestRunner.THEN_PHASE; - } - else if(this.m_nTestPhase != br.test.GwtTestRunner.THEN_PHASE) - { + } else if (nPhase == GwtTestRunner.THEN_PHASE) { + if ((this.m_nTestPhase == GwtTestRunner.GIVEN_PHASE) || + (this.m_nTestPhase == GwtTestRunner.WHEN_PHASE)) { + this.m_nTestPhase = GwtTestRunner.THEN_PHASE; + } else if (this.m_nTestPhase != GwtTestRunner.THEN_PHASE) { this._throwError("InvalidPhaseError", sStatement, "'THEN' statements must occur after 'GIVEN' and 'WHEN' statements."); } } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype._parseStatement = function(sStatement, nPhase) -{ +/** @private */ +GwtTestRunner.prototype._parseStatement = function(sStatement, nPhase) { var newlinePlaceholder = ""; @@ -480,60 +379,48 @@ br.test.GwtTestRunner.prototype._parseStatement = function(sStatement, nPhase) */ var pStatement = /(.+)(\=\>|\=)(.+)/i.exec(sStatement); - for (var i = 0; i < pStatement.length; i++) - { + for (var i = 0; i < pStatement.length; i++) { pStatement[i] = (pStatement[i].trim()); } - if(!pStatement || (pStatement.length != 4) || !pStatement[1] || !pStatement[2] || !pStatement[3]) - { + if (!pStatement || (pStatement.length != 4) || !pStatement[1] || !pStatement[2] || !pStatement[3]) { this._throwError("IllegalStatementError", sStatement, "Statement should have the form . "); } - var oStatement = - { + var oStatement = { property:(pStatement[1].trim()), operator:pStatement[2], propertyValue:this._getTypedPropertyValue(pStatement[3].replace(newlinePlaceholder,"\n")) }; - if(nPhase === br.test.GwtTestRunner.WHEN_PHASE && oStatement.operator != "=>") - { + if (nPhase === GwtTestRunner.WHEN_PHASE && oStatement.operator != "=>") { this._throwError("IllegalStatementError", sStatement, "'When Statements should use => as an Operator"); } - if(oStatement.propertyValue === null) - { + if (oStatement.propertyValue === null) { this._throwError("InvalidPropertyValueError", sStatement, "'" + oStatement.propertyValue + "' is not a valid type (only strings, numbers, booleans and undefined are supported)"); } this._addFixtureToStatement(oStatement); - if(!oStatement.fixture) - { + if (!oStatement.fixture) { this._throwError("InvalidFixtureNameError", sStatement, "No Fixture has been specified matching '" + oStatement.propertyName + "'"); } return oStatement; }; -/** - * @private - */ -br.test.GwtTestRunner.prototype._addFixtureToStatement = function(oStatement) -{ - for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) - { +/** @private */ +GwtTestRunner.prototype._addFixtureToStatement = function(oStatement) { + for(var i = 0, l = this.m_pFixtures.length; i < l; ++i) { var oNextFixture = this.m_pFixtures[i]; - if(oStatement.property.match(oNextFixture.scopeMatcher)) - { + if (oStatement.property.match(oNextFixture.scopeMatcher)) { var sFixtureProperty = oStatement.property.substr(oNextFixture.scopeLength); var bCanHandleProperty = (sFixtureProperty.length > 0) ? oNextFixture.fixture.canHandleProperty(sFixtureProperty) : oNextFixture.fixture.canHandleExactMatch(); - if(bCanHandleProperty) - { + if (bCanHandleProperty) { oStatement.fixture = oNextFixture.fixture; oStatement.propertyName = sFixtureProperty; break; @@ -542,40 +429,25 @@ br.test.GwtTestRunner.prototype._addFixtureToStatement = function(oStatement) } }; -/** - * @private - */ -br.test.GwtTestRunner.prototype._getTypedPropertyValue = function(sValue) -{ +/** @private */ +GwtTestRunner.prototype._getTypedPropertyValue = function(sValue) { var vValue = null; - if(sValue == "true") - { + if (sValue == "true") { vValue = true; - } - else if(sValue == "false") - { + } else if (sValue == "false") { vValue = false; - } - else if(sValue == "undefined") - { + } else if (sValue == "undefined") { vValue = undefined; - } - else if(sValue.match(/^'[.\s\S]*'$/)) - { + } else if (sValue.match(/^'[.\s\S]*'$/)) { vValue = sValue.substr(1, sValue.length - 2); - } - else if(!isNaN(sValue)) - { + } else if (!isNaN(sValue)) { vValue = Number(sValue); - } - else if(sValue.match(/^\[.*\]$/)) - { + } else if (sValue.match(/^\[.*\]$/)) { var pItems = sValue.substr(1, sValue.length - 2).split(/ *, */); vValue = []; - for(var i = 0, l = pItems.length; i < l; ++i) - { + for(var i = 0, l = pItems.length; i < l; ++i) { vValue[i] = this._getTypedPropertyValue(pItems[i]); } } @@ -583,26 +455,20 @@ br.test.GwtTestRunner.prototype._getTypedPropertyValue = function(sValue) return vValue; }; -/** - * @private - */ -br.test.GwtTestRunner.prototype._throwError = function(sType, sStatement, sMessage) -{ - throw new br.Errors.CustomError(sType, "Error handling statement '" + sStatement + "':\n\t" + sMessage); +/** @private */ +GwtTestRunner.prototype._throwError = function(sType, sStatement, sMessage) { + throw new Errors.CustomError(sType, "Error handling statement '" + sStatement + "':\n\t" + sMessage); }; +// JASMINE OVERRIDES. +if (window.jasmine) { + describe = GwtTestRunner.createProxyDescribeFunction(describe); + xdescribe = GwtTestRunner.createProxyDescribeFunction(xdescribe, true); -/* **************************** - * JASMINE OVERRIDES. - * ****************************/ - -if(window.jasmine) -{ - describe = br.test.GwtTestRunner.createProxyDescribeFunction(describe); - xdescribe = br.test.GwtTestRunner.createProxyDescribeFunction(xdescribe, true); + jasmine.Env.prototype.it = GwtTestRunner.createProxyItFunction(jasmine.Env.prototype.it); + jasmine.Env.prototype.xit = GwtTestRunner.createProxyItFunction(jasmine.Env.prototype.xit); - jasmine.Env.prototype.it = br.test.GwtTestRunner.createProxyItFunction(jasmine.Env.prototype.it); - jasmine.Env.prototype.xit = br.test.GwtTestRunner.createProxyItFunction(jasmine.Env.prototype.xit); - - br.test.GwtTestRunner.capturingItFunction = br.test.GwtTestRunner.createProxyItFunction(function() {}); + GwtTestRunner.capturingItFunction = GwtTestRunner.createProxyItFunction(function() {}); } + +module.exports = GwtTestRunner; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/SubFixtureRegistry.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/SubFixtureRegistry.js index 618e8af7f..3939bfbdf 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/SubFixtureRegistry.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/SubFixtureRegistry.js @@ -1,20 +1,25 @@ +'use strict'; + +var br = require('br/Core'); +var FixtureRegistry = require('br/test/FixtureRegistry'); + /** + * @name br.test.SubFixtureRegistry * @constructor * @private * * @implements br.test.FixtureRegistry */ -br.test.SubFixtureRegistry = function(oParentFixtureRegistry, sScope) -{ - this.m_oParentFixtureRegistry = oParentFixtureRegistry; - this.m_sScope = sScope; +function SubFixtureRegistry(parentFixtureRegistry, scope) { + this.m_oParentFixtureRegistry = parentFixtureRegistry; + this.m_sScope = scope; }; -br.Core.inherit(br.test.SubFixtureRegistry, br.test.FixtureRegistry); +br.inherit(SubFixtureRegistry, FixtureRegistry); -//*** FixtureRegistry Interface *** - -br.test.SubFixtureRegistry.prototype.addFixture = function(sScope, oFixture) -{ - this.m_oParentFixtureRegistry.addFixture(this.m_sScope + "." + sScope, oFixture); +/** @see br.test.FixtureRegistry#addFixture */ +SubFixtureRegistry.prototype.addFixture = function(scope, fixture) { + this.m_oParentFixtureRegistry.addFixture(this.m_sScope + '.' + scope, fixture); }; + +module.exports = SubFixtureRegistry; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TestFixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TestFixture.js index df74213dc..9c2dfa823 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TestFixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TestFixture.js @@ -1,42 +1,39 @@ -/** - * @private - * - * @implements br.test.Fixture - */ -br.test.TestFixture = function(oGwtTestRunner) -{ - this.m_oGwtTestRunner = oGwtTestRunner; -}; +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var Fixture = require('br/test/Fixture'); +var ViewFixture = require('br/test/ViewFixture'); -br.Core.inherit(br.test.TestFixture, br.test.Fixture); +/** @private */ +function TestFixture(gwtTestRunner) { + this.m_oGwtTestRunner = gwtTestRunner; +} +br.inherit(TestFixture, Fixture); -br.test.TestFixture.prototype.canHandleExactMatch = function() -{ +TestFixture.prototype.canHandleExactMatch = function() { return false; }; -br.test.TestFixture.prototype.canHandleProperty = function(sProperty) -{ - return sProperty == "continuesFrom"; +TestFixture.prototype.canHandleProperty = function(property) { + return property == 'continuesFrom'; }; -br.test.TestFixture.prototype.addSubFixtures = function(oFixtureRegistry) -{ - oFixtureRegistry.addFixture("page", new br.test.ViewFixture("body")); +TestFixture.prototype.addSubFixtures = function(fixtureRegistry) { + fixtureRegistry.addFixture('page', new ViewFixture('body')); }; -br.test.TestFixture.prototype.doGiven = function(sPropertyName, vValue) -{ - startingContinuesFrom(vValue); +TestFixture.prototype.doGiven = function(propertyName, value) { + startingContinuesFrom(value); finishedContinuesFrom(); }; -br.test.TestFixture.prototype.doWhen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "when is not supported by TestFixture"); +TestFixture.prototype.doWhen = function(propertyName, value) { + throw new Errors.InvalidTestError('when is not supported by TestFixture'); +}; + +TestFixture.prototype.doThen = function(propertyName, value) { + throw new Errors.InvalidTestError('then is not supported by TestFixture'); }; -br.test.TestFixture.prototype.doThen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "then is not supported by TestFixture"); -}; \ No newline at end of file +module.exports = TestFixture; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeFixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeFixture.js index 6be5cb795..77c8c5694 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeFixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeFixture.js @@ -1,115 +1,111 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var Fixture = require('br/test/Fixture'); + /** + * @name br.test.TimeFixture * @class * - * TimeFixture allows you to control when callbacks passed to window.setTimeout() and window.setInterval() are executed.
- * Currently setInterval() is not fully supported. It only fires once instead of repeating.
- *
- * timeMode property
- * There are two modes supported by the TimeFixture: - *
    - *
  • 'NextStep' (default) - will automatically fire all timers at the end of each 'given, when or then' step (including 'and' steps)
  • - *
  • 'Manual' - will stop the automatic-firing of timers on each 'given, when or then' step
  • - *
+ * TimeFixture allows you to control when callbacks passed to window.setTimeout() and window.setInterval() + * are executed.
+ * Currently setInterval() is not fully supported. It only fires once instead of repeating.

+ * timeMode property
+ * There are two modes supported by the TimeFixture: + *
    + *
  • 'NextStep' (default) - will automatically fire all timers at the end of each 'given, when or then' step + * (including 'and' steps)
  • + *
  • 'Manual' - will stop the automatic-firing of timers on each 'given, when or then' step
  • + *
* - * passedBy property
- * When in 'Manual' mode, 'passedBy' is defined in milliseconds. Any function(s) registered to wait for a period less than - * (or equal to) the stated 'passedBy' value are then executed in ascending time order.
- *
- * Example using 'NextStep' mode (default):
+ * passedBy property
+ * When in 'Manual' mode, 'passedBy' is defined in milliseconds. Any function(s) registered to wait for a period less + * than (or equal to) the stated 'passedBy' value are then executed in ascending time order.

+ * Example using 'NextStep' mode (default):
+ * + * given("time.timeMode = 'NextStep'")
+ * and(...)
+ * // All timed events fired for the 'and' step above
+ * and(...)
+ * // All timed events fired for the 'and' step above
+ * when(...)
+ * // All timed events set up in the "when" step are fired
+ * then(...)
+ *
+ *
+ * Example using 'Manual' mode:
* - * given("time.timeMode = 'NextStep'")
- * and(...)
- * // All timed events fired for the 'and' step above
- * and(...)
- * // All timed events fired for the 'and' step above
- * when(...)
- * // All timed events set up in the "when" step are fired
- * then(...)
+ * given("time.timeMode = 'Manual'")
+ * and(...)
+ * when(...)
+ * and("time.passedBy => 2000")
+ * // timed events from the 'given' and 'when' steps set to execute 2 seconds in the future are fired
+ * then(...)
*
- *
- * Example using 'Manual' mode:
- * - * given("time.timeMode = 'Manual'")
- * and(...)
- * when(...)
- * and("time.passedBy => 2000")
- * // timed events from the 'given' and 'when' steps set to execute 2 seconds in the future are fired
- * then(...)
- *
* * @implements br.test.Fixture */ -br.test.TimeFixture = function(oTimeUtility) -{ - this.m_oTimeUtility = oTimeUtility; +function TimeFixture(timeUtility) { + this.m_oTimeUtility = timeUtility; }; +br.inherit(TimeFixture, Fixture); -br.Core.inherit(br.test.TimeFixture, br.test.Fixture); - -br.test.TimeFixture.prototype.canHandleExactMatch = function() -{ +TimeFixture.prototype.canHandleExactMatch = function() { return false; }; -br.test.TimeFixture.prototype.tearDown = function() -{ +TimeFixture.prototype.tearDown = function() { this.m_oTimeUtility.reset(); }; -br.test.TimeFixture.prototype.canHandleProperty = function(sProperty) -{ - return sProperty === "timeMode" || sProperty === "passedBy"; +TimeFixture.prototype.canHandleProperty = function(propertyName) { + return propertyName === 'timeMode' || propertyName === 'passedBy'; }; -br.test.TimeFixture.prototype.addSubFixtures = function(oFixtureRegistry) -{ +TimeFixture.prototype.addSubFixtures = function(fixtureRegistry) { }; /** - * - * @param {String} sPropertyName The property name (e.g. 'time.timeMode' or 'time.passedBy') - * @param {Variant} vValue The value to set - * * @see br.test.Fixture#doGiven + * @param {String} propertyName The property name (e.g. 'time.timeMode' or 'time.passedBy'). + * @param {Variant} value The value to set. */ -br.test.TimeFixture.prototype.doGiven = function(sPropertyName, vValue) -{ - this._configureTimeUtility(sPropertyName, vValue); +TimeFixture.prototype.doGiven = function(propertyName, value) { + this._configureTimeUtility(propertyName, value); }; /** - * @param {String} sPropertyName The property name (e.g. 'time.timeMode' or 'time.passedBy') - * @param {Variant} vValue The value to set - * * @see br.test.Fixture#doWhen + * @param {String} propertyName The property name (e.g. 'time.timeMode' or 'time.passedBy'). + * @param {Variant} value The value to set. */ -br.test.TimeFixture.prototype.doWhen = function(sPropertyName, vValue) -{ - this._configureTimeUtility(sPropertyName, vValue); +TimeFixture.prototype.doWhen = function(propertyName, value) { + this._configureTimeUtility(propertyName, value); }; /** * TimeFixture does not support doThen. * - * @param {String} sPropertyName The property name - * @param {Variant} vValue The value to set + * @param {String} propertyName The property name. + * @param {Variant} value The value to set. * * @see br.test.Fixture#doThen */ -br.test.TimeFixture.prototype.doThen = function(sPropertyName, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "then is not supported by TimeFixture"); +TimeFixture.prototype.doThen = function(propertyName, value) { + throw new Errors.InvalidTestError('then is not supported by TimeFixture'); }; -br.test.TimeFixture.prototype._configureTimeUtility = function(sPropertyName, vValue) -{ - switch(sPropertyName) - { - case "timeMode": - this.m_oTimeUtility.setTimeMode(vValue); +/** @private */ +TimeFixture.prototype._configureTimeUtility = function(propertyName, value) { + switch (propertyName) { + case 'timeMode': + this.m_oTimeUtility.setTimeMode(value); break; - case "passedBy": - this.m_oTimeUtility.executeCapturedFunctions(vValue); + case 'passedBy': + this.m_oTimeUtility.executeCapturedFunctions(value); break; } -}; \ No newline at end of file +}; + +module.exports = TimeFixture; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeUtility.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeUtility.js index 4540dd8e2..1ab4f8352 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeUtility.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/TimeUtility.js @@ -1,126 +1,109 @@ +'use strict'; + +var Errors = require('br/Errors'); + /** * @private * Utility class containing static methods that can be useful for controlling time in tests. */ -br.test.TimeUtility = {}; +var TimeUtility = {}; /** @private */ -br.test.TimeUtility.TIMER_ID = 0; +TimeUtility.TIMER_ID = 0; /** @private */ -br.test.TimeUtility.MANUAL_TIME_MODE = "Manual"; +TimeUtility.MANUAL_TIME_MODE = 'Manual'; /** @private */ -br.test.TimeUtility.NEXT_STEP_TIME_MODE = "NextStep"; +TimeUtility.NEXT_STEP_TIME_MODE = 'NextStep'; /** @private */ -br.test.TimeUtility.timeMode = br.test.TimeUtility.NEXT_STEP_TIME_MODE; +TimeUtility.timeMode = TimeUtility.NEXT_STEP_TIME_MODE; /** @private */ -br.test.TimeUtility.pCapturedTimerFunctionArgs = []; +TimeUtility.pCapturedTimerFunctionArgs = []; /** @private */ -br.test.TimeUtility._bHasReplacedTimerFunctions = false; +TimeUtility._bHasReplacedTimerFunctions = false; /** @private */ -br.test.TimeUtility.bCaptureTimeoutAndIntervals = true; +TimeUtility.bCaptureTimeoutAndIntervals = true; /** @private */ -br.test.TimeUtility.fCapturedTimersSort = function(oFirstFunction, oSecondFunction) { - return oFirstFunction[1] - oSecondFunction[1]; +TimeUtility.fCapturedTimersSort = function(firstFunction, secondFunction) { + return firstFunction[1] - secondFunction[1]; }; /** - * Reset this TimeUtility to its original state. Useful for testing. - * * @private + * Reset this TimeUtility to its original state. Useful for testing. */ -br.test.TimeUtility.reset = function() -{ +TimeUtility.reset = function() { this.timeMode = this.NEXT_STEP_TIME_MODE; this.bCaptureTimeoutAndIntervals = true; - + this.clearCapturedFunctions(); this.releaseTimerFunctions(); }; /** - * Overrides the default setTimeout and setInterval methods. - * This allows the storing of all functions passed in to those methods. - * - * @static + * Overrides the default setTimeout and setInterval methods. This allows the storing of all + * functions passed in to those methods. */ -br.test.TimeUtility.captureTimerFunctions = function() -{ - if(this.bCaptureTimeoutAndIntervals && this._bHasReplacedTimerFunctions == false) - { +TimeUtility.captureTimerFunctions = function() { + if (this.bCaptureTimeoutAndIntervals && this._bHasReplacedTimerFunctions === false) { this.ORIGINAL_SETTIMEOUT_FUNCTION = window.setTimeout; this.ORIGINAL_SETINTERVAL_FUNCTION = window.setInterval; this.ORIGINAL_CLEARTIMEOUT_FUNCTION = window.clearTimeout; this.ORIGINAL_CLEARINTERVAL_FUNCTION = window.clearInterval; - - window.setTimeout = br.test.TimeUtility.fCaptureArguments; - window.setInterval = br.test.TimeUtility.fCaptureArguments; - window.clearTimeout = br.test.TimeUtility.fClearTimer; - window.clearInterval = br.test.TimeUtility.fClearTimer; - + + window.setTimeout = TimeUtility.fCaptureArguments; + window.setInterval = TimeUtility.fCaptureArguments; + window.clearTimeout = TimeUtility.fClearTimer; + window.clearInterval = TimeUtility.fClearTimer; + this._bHasReplacedTimerFunctions = true; } }; /** - * @static - * @return {Array} A list of argument objects that were passed into setTimeout - * and setInterval. + * @return {Array} A list of argument objects that were passed into setTimeout and + * setInterval. */ -br.test.TimeUtility.getCapturedFunctions = function() -{ - var pCapturedFunctions = this.pCapturedTimerFunctionArgs.slice(); - return pCapturedFunctions.sort(this.fCapturedTimersSort); +TimeUtility.getCapturedFunctions = function() { + var capturedFunctions = this.pCapturedTimerFunctionArgs.slice(); + + return capturedFunctions.sort(this.fCapturedTimersSort); }; -/** - * @private - */ -br.test.TimeUtility.clearCapturedFunctions = function() -{ +/** @private */ +TimeUtility.clearCapturedFunctions = function() { this.pCapturedTimerFunctionArgs.length = 0; }; /** - * Execute all captured functions that are set to be triggered within the passed in millisecond time value. - * - * If no value is passed, this will execute all captured functions. - * - * @static + * Execute all captured functions that are set to be triggered within the passed in millisecond time value. If no value + * is passed, this will execute all captured functions. */ -br.test.TimeUtility.executeCapturedFunctions = function(nMsToExecuteTo) -{ +TimeUtility.executeCapturedFunctions = function(nMsToExecuteTo) { + var capturedFunction; + this.pCapturedTimerFunctionArgs.sort(this.fCapturedTimersSort); - - for(var i = 0; i < this.pCapturedTimerFunctionArgs.length; i++) - { - var pCapturedFunction = this.pCapturedTimerFunctionArgs[i]; - - if(nMsToExecuteTo == null || pCapturedFunction[1] <= nMsToExecuteTo) - { - pCapturedFunction[0](); - this.pCapturedTimerFunctionArgs.splice(i, 1); - i--; - } - else - { - pCapturedFunction[1] -= nMsToExecuteTo; + + for (var idx = 0; idx < this.pCapturedTimerFunctionArgs.length; idx++) { + capturedFunction = this.pCapturedTimerFunctionArgs[idx]; + + if (nMsToExecuteTo == null || capturedFunction[1] <= nMsToExecuteTo) { + capturedFunction[0](); + this.pCapturedTimerFunctionArgs.splice(idx, 1); + idx--; + } else { + capturedFunction[1] -= nMsToExecuteTo; } } }; /** - * Execute all captured functions if we are in NEXT_STEP_TIME_MODE. - * - * All functions will be cleared even if an error is thrown, although not - * all functions will be executed. - * - * Returns false if we are not in NEXT_STEP_TIME_MODE - * - * @static + * Execute all captured functions if we are in NEXT_STEP_TIME_MODE. All functions will be cleared even if an error is + * thrown, although not all functions will be executed. Returns false if we are not in NEXT_STEP_TIME_MODE + */ -br.test.TimeUtility.nextStep = function() { +TimeUtility.nextStep = function() { if (this.timeMode === this.NEXT_STEP_TIME_MODE) { try { this.executeCapturedFunctions(); @@ -135,32 +118,25 @@ br.test.TimeUtility.nextStep = function() { /** * Sets the timer mode which controls when captured timeouts and intervals run. - * - * @static */ -br.test.TimeUtility.setTimeMode = function(sTimeMode) -{ - if(sTimeMode === this.MANUAL_TIME_MODE || sTimeMode === this.NEXT_STEP_TIME_MODE) - { - this.timeMode = sTimeMode; - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Incorrect time mode ("+sTimeMode+") set on TimeUtility."); +TimeUtility.setTimeMode = function(timeMode) { + if (timeMode === this.MANUAL_TIME_MODE || timeMode === this.NEXT_STEP_TIME_MODE) { + this.timeMode = timeMode; + } else { + throw new Errors.InvalidTestError('Incorrect time mode (' + timeMode + ') set on TimeUtility.'); } }; /** @private */ -br.test.TimeUtility.releaseTimerFunctions = function() -{ +TimeUtility.releaseTimerFunctions = function() { if (this._bHasReplacedTimerFunctions) { window.setTimeout = this.ORIGINAL_SETTIMEOUT_FUNCTION; window.setInterval = this.ORIGINAL_SETINTERVAL_FUNCTION; window.clearTimeout = this.ORIGINAL_CLEARTIMEOUT_FUNCTION; window.clearInterval = this.ORIGINAL_CLEARINTERVAL_FUNCTION; - + this._bHasReplacedTimerFunctions = false; - + delete this.ORIGINAL_SETTIMEOUT_FUNCTION; delete this.ORIGINAL_SETINTERVAL_FUNCTION; delete this.ORIGINAL_CLEARTIMEOUT_FUNCTION; @@ -169,23 +145,23 @@ br.test.TimeUtility.releaseTimerFunctions = function() }; /** @private */ -br.test.TimeUtility.fCaptureArguments = function() -{ - arguments.nTimerId = br.test.TimeUtility.TIMER_ID++; - - br.test.TimeUtility.pCapturedTimerFunctionArgs.push(arguments); - +TimeUtility.fCaptureArguments = function() { + arguments.nTimerId = TimeUtility.TIMER_ID++; + + TimeUtility.pCapturedTimerFunctionArgs.push(arguments); + return arguments.nTimerId; }; /** @private */ -br.test.TimeUtility.fClearTimer = function(nTimerId) -{ - var pCapturedFunctions = br.test.TimeUtility.pCapturedTimerFunctionArgs; - - pCapturedFunctions = pCapturedFunctions.filter(function(oFunction, nIndex, pFunctions){ - return oFunction.nTimerId !== nTimerId; +TimeUtility.fClearTimer = function(timerId) { + var capturedFunctions = TimeUtility.pCapturedTimerFunctionArgs; + + capturedFunctions = capturedFunctions.filter(function(capturedFunction){ + return capturedFunction.nTimerId !== timerId; }); - - br.test.TimeUtility.pCapturedTimerFunctionArgs = pCapturedFunctions; -}; \ No newline at end of file + + TimeUtility.pCapturedTimerFunctionArgs = capturedFunctions; +}; + +module.exports = TimeUtility; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Utils.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Utils.js index 6591be4cf..fbc4f0e5f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Utils.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/Utils.js @@ -1,36 +1,42 @@ +'use strict'; + /* global br, require, presenter_ko, jQuery */ -br.Core.thirdparty('jquery'); -br.Core.thirdparty('presenter-knockout'); +require('jquery'); +require('presenter-knockout'); + +var Errors = require('br/Errors'); /** + * @name br.test.Utils * @class * Utility class containing static methods that can be useful for tests. */ -br.test.Utils = function() {}; +function Utils() { +}; -br.test.Utils.pLoadedAndAttachedCSSElements = []; +Utils.pLoadedAndAttachedCSSElements = []; /** * Fires a DOM Event in a cross Browser compatible way. * * @static - * @param {DOM Element} element The DOM Element the Event is fired from - * @param {String} eventString The Event to be fired without 'on', e.g. 'click', 'keydown' - * @param {String} [character] A character associated with typing events + * @param {DOM Element} element The DOM Element the Event is fired from. + * @param {String} eventString The Event to be fired without 'on', e.g. 'click', 'keydown'. + * @param {String} [character] A character associated with typing events. */ -br.test.Utils.fireDomEvent = function(element, eventString, character) { +Utils.fireDomEvent = function(element, eventString, character) { var evt; if (document.createEventObject) { evt = jQuery.Event(eventString); if (character) { - evt.which = br.test.Utils.getKeyCodeForChar(character); + evt.which = Utils.getKeyCodeForChar(character); } jQuery(element).trigger(evt); } else if (document.createEvent) { //FF, WEBKIT etc.. evt = document.createEvent('HTMLEvents'); if (typeof character !== 'undefined') { - evt.which = br.test.Utils.getKeyCodeForChar(character); + evt.which = Utils.getKeyCodeForChar(character); } evt.initEvent(eventString, true, true); return !element.dispatchEvent(evt); @@ -41,15 +47,12 @@ br.test.Utils.fireDomEvent = function(element, eventString, character) { * Returns the Keycode of a letter. * * @static - * @param {String} character a single Character to get the Keycode for + * @param {String} character a single Character to get the Keycode for. * @returns {Number} keyCode The key code for the specified char. */ -br.test.Utils.getKeyCodeForChar = function(character) { +Utils.getKeyCodeForChar = function(character) { if (character.toString().length !== 1){ - throw br.Errors.CustomError( - br.Errors.INVALID_TEST, - 'getKeyCodeForChar Error! ' + character + ' should only be a single Character' - ); + throw Errors.InvalidTestError('getKeyCodeForChar Error! ' + character + ' should only be a single Character'); } return character.charCodeAt(0); @@ -59,14 +62,14 @@ br.test.Utils.getKeyCodeForChar = function(character) { * Fires a DOM KeyboardEvent in a cross Browser compatible way. * * @static - * @param {DOM Element} element The DOM Element the Event is fired from - * @param {String} eventString The Event to be fired without 'on', e.g. 'keydown' + * @param {DOM Element} element The DOM Element the Event is fired from. + * @param {String} eventString The Event to be fired without 'on', e.g. 'keydown'. * @param {String} character a character associated with typing events. * @param {Map} options a map of values, passed in to initKeyboardEvent, associated with typing events. */ -br.test.Utils.fireKeyEvent = function(element, eventString, character, options) { - var keyCode = br.test.Utils.getKeyCodeForChar(character), - args = br.test.Utils._mergeDefaultKeyEventArgumentsWithArgumentsMap(options || {}), +Utils.fireKeyEvent = function(element, eventString, character, options) { + var keyCode = Utils.getKeyCodeForChar(character), + args = Utils._mergeDefaultKeyEventArgumentsWithArgumentsMap(options || {}), evt; if (document.createEvent) { @@ -75,16 +78,50 @@ br.test.Utils.fireKeyEvent = function(element, eventString, character, options) if (evt.initKeyboardEvent) { if (navigator.userAgent.indexOf('WebKit') !== -1) { - //https://bugs.webkit.org/show_bug.cgi?id=16735 Due to bug in Webkit and Chrome we must use keyIdentifier instead of keycode - which is the standard anyway. + //https://bugs.webkit.org/show_bug.cgi?id=16735 Due to bug in Webkit and Chrome we must use + // keyIdentifier instead of keycode - which is the standard anyway. + //Webkit. - evt.initKeyboardEvent(eventString, args.canBubble, args.cancelable, args.view, args.keyIdentifier, 0, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey); + evt.initKeyboardEvent( + eventString, + args.canBubble, + args.cancelable, + args.view, + args.keyIdentifier, + 0, + args.ctrlKey, + args.altKey, + args.shiftKey, + args.metaKey + ); } else { //IE. - evt.initKeyboardEvent(eventString, args.canBubble, args.cancelable, args.view, args.key, 0, args.modifiersListArg, 0, 'en-US'); + evt.initKeyboardEvent( + eventString, + args.canBubble, + args.cancelable, + args.view, + args.key, + 0, + args.modifiersListArg, + 0, + 'en-US' + ); } } else if (evt.initKeyEvent) { //Gecko. - evt.initKeyEvent(eventString, args.canBubble, args.cancelable, args.view, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, keyCode, 0); + evt.initKeyEvent( + eventString, + args.canBubble, + args.cancelable, + args.view, + args.ctrlKey, + args.altKey, + args.shiftKey, + args.metaKey, + keyCode, + 0 + ); } return !element.dispatchEvent(evt); @@ -108,22 +145,35 @@ br.test.Utils.fireKeyEvent = function(element, eventString, character, options) * Fires a DOM MouseEvents in a cross Browser compatible way. * * @static - * @param {DOM Element} element The DOM Element the Event is fired from - * @param {String} eventString The Event to be fired without 'on', e.g. 'click' + * @param {DOM Element} element The DOM Element the Event is fired from. + * @param {String} eventString The Event to be fired without 'on', e.g. 'click'. * @param {Map} options a map of values, passed in to initMouseEvent, associated with mouse events. */ -br.test.Utils.fireMouseEvent = function(element, eventString, options) { - var args = br.test.Utils.fireMouseEvent._mergeDefaultMouseEventArgumentsWithArgumentsMap(options || {}), +Utils.fireMouseEvent = function(element, eventString, options) { + var args = Utils.fireMouseEvent._mergeDefaultMouseEventArgumentsWithArgumentsMap(options || {}), evt; if (document.createEvent) { - evt = br.test.Utils.fireMouseEvent._getMouseEventDOMStandard(eventString, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, - args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget); + evt = Utils.fireMouseEvent._getMouseEventDOMStandard( + eventString, + args.canBubble, + args.cancelable, + args.view, + args.detail, + args.screenX, + args.screenY, + args.clientX, + args.clientY, + args.ctrlKey, + args.altKey, + args.shiftKey, + args.metaKey, + args.button, + args.relatedTarget + ); element.dispatchEvent(evt); - } else if (element.fireEvent) { - - if (br.test.Utils._isClickEventWithNoEventOptionsAndKOIsAvailable(eventString, element, options)) { + if (Utils._isClickEventWithNoEventOptionsAndKOIsAvailable(eventString, element, options)) { /* * The reason for this KO call is due to jQuery not behaving like a browser and only setting a checked value * after calling the event handlers. This code should only run in IE8 (element.fireEvent check above). @@ -131,11 +181,25 @@ br.test.Utils.fireMouseEvent = function(element, eventString, options) { * There is a comment in the KO code which explains why this is required. */ presenter_ko.utils.triggerEvent(element, eventString); - } else if (br.test.Utils._isClickEventWithNoEventOptions(eventString, element, options)) { + } else if (Utils._isClickEventWithNoEventOptions(eventString, element, options)) { jQuery(element).click(); } else { - evt = br.test.Utils.fireMouseEvent._getMouseEventIENonStandard(args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, - args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget); + evt = Utils.fireMouseEvent._getMouseEventIENonStandard( + args.canBubble, + args.cancelable, + args.view, + args.detail, + args.screenX, + args.screenY, + args.clientX, + args.clientY, + args.ctrlKey, + args.altKey, + args.shiftKey, + args.metaKey, + args.button, + args.relatedTarget + ); element.fireEvent('on' + eventString, evt); } } @@ -148,10 +212,11 @@ br.test.Utils.fireMouseEvent = function(element, eventString, options) { * @static * @param {Array} cssFiels list of css file URLs to be loaded into the test page. */ -br.test.Utils.loadCSSAndAttachToPage = function(cssFiles) { +Utils.loadCSSAndAttachToPage = function(cssFiles) { var FileUtility = require('br/core/File'), elHead = document.getElementsByTagName('head')[0], cssCode, cssEl; + for (var i = 0, len = cssFiles.length; i < len; ++i) { cssCode = FileUtility.readFileSync(cssFiles[i]); cssEl = document.createElement('style'); @@ -169,7 +234,7 @@ br.test.Utils.loadCSSAndAttachToPage = function(cssFiles) { } } - br.test.Utils.pLoadedAndAttachedCSSElements.push(elHead.appendChild(cssEl)); + Utils.pLoadedAndAttachedCSSElements.push(elHead.appendChild(cssEl)); } }; @@ -180,8 +245,8 @@ br.test.Utils.loadCSSAndAttachToPage = function(cssFiles) { * @static * @param {Array} cssFiles list of css file URLs to be loaded into the test page. */ -br.test.Utils.removeLoadedAndAttachedCSSFromPage = function() { - var cssElements = br.test.Utils.pLoadedAndAttachedCSSElements, +Utils.removeLoadedAndAttachedCSSFromPage = function() { + var cssElements = Utils.pLoadedAndAttachedCSSElements, cssEl; while (cssElements.length) { @@ -196,7 +261,7 @@ br.test.Utils.removeLoadedAndAttachedCSSFromPage = function() { * @static * @param {DOM Element} element The DOM Element the Event is fired from */ -br.test.Utils.fireScrollEvent = function(element) { +Utils.fireScrollEvent = function(element) { if (document.createEvent) { // FF var evt = document.createEvent('HTMLEvents'); @@ -209,7 +274,7 @@ br.test.Utils.fireScrollEvent = function(element) { }; /** @private */ -br.test.Utils.fireMouseEvent._mergeDefaultMouseEventArgumentsWithArgumentsMap = function(config) { +Utils.fireMouseEvent._mergeDefaultMouseEventArgumentsWithArgumentsMap = function(config) { return { canBubble : config.canBubble !== false ? true : false, cancelable : config.cancelable !== false ? true : false, @@ -229,14 +294,14 @@ br.test.Utils.fireMouseEvent._mergeDefaultMouseEventArgumentsWithArgumentsMap = }; /** @private */ -br.test.Utils.fireMouseEvent._getMouseEventDOMStandard = function(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) { +Utils.fireMouseEvent._getMouseEventDOMStandard = function(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) { var evt = document.createEvent('MouseEvents'); evt.initMouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget); return evt; }; /** @private */ -br.test.Utils.fireMouseEvent._getMouseEventIENonStandard = function(canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) { +Utils.fireMouseEvent._getMouseEventIENonStandard = function(canBubble, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) { //create an IE event object var customEvent = document.createEventObject(); @@ -278,7 +343,7 @@ br.test.Utils.fireMouseEvent._getMouseEventIENonStandard = function(canBubble, c }; /** @private */ -br.test.Utils._mergeDefaultKeyEventArgumentsWithArgumentsMap = function(config) { +Utils._mergeDefaultKeyEventArgumentsWithArgumentsMap = function(config) { return { canBubble : config.canBubble !== false ? true : false, cancelable : config.cancelable !== false ? true : false, @@ -294,12 +359,14 @@ br.test.Utils._mergeDefaultKeyEventArgumentsWithArgumentsMap = function(config) }; /** @private */ -br.test.Utils._isClickEventWithNoEventOptions = function(eventString, element, options) { +Utils._isClickEventWithNoEventOptions = function(eventString, element, options) { var Utility = require('br/core/Utility'); return eventString === 'click' && element.click && Utility.isEmpty(options); }; /** @private */ -br.test.Utils._isClickEventWithNoEventOptionsAndKOIsAvailable = function(eventString, element, options) { - return br.test.Utils._isClickEventWithNoEventOptions(eventString, element, options) && presenter_ko && presenter_ko.utils; +Utils._isClickEventWithNoEventOptionsAndKOIsAvailable = function(eventString, element, options) { + return Utils._isClickEventWithNoEventOptions(eventString, element, options) && presenter_ko && presenter_ko.utils; }; + +module.exports = Utils; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/ViewFixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/ViewFixture.js index a7b179043..f294690a8 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/ViewFixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/ViewFixture.js @@ -1,18 +1,26 @@ -br.Core.thirdparty("jquery"); -br.Core.thirdparty("es5-shim"); +'use strict'; + +require('jquery'); +require('es5-shim'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var Fixture = require('br/test/Fixture'); /** + * @name br.test.ViewFixture * @class - *

The ViewFixture enables interacting with the rendered view via ViewFixtureHandlers. - * An element in the view can be selected with jQuery selectors. In Given and When phases the selected element - * in the view as well as its desired value will be passed as arguments to the set() method of a - * ViewFixtureHandler which will update the element accordingly. In the Then phase the same arguments will be - * passed to the get() method of a ViewFixtureHandler, which will then inspect the selected view - * element and return a value of a particular property of this element to the ViewFixture. The ViewFixture - * should mainly be used to check that the bindings between view elements in templates and the corresponding presentation - * model properties have been specified correctly. A test might set a value on the view element in the Given or When phases and - * then check in the Then phase that this value has been updated after updating the relevant presentation model property.

- * + *

The ViewFixture enables interacting with the rendered view via ViewFixtureHandlers. An + * element in the view can be selected with jQuery selectors. In Given and When phases the selected element in the + * view as well as its desired value will be passed as arguments to the set() method of a + * ViewFixtureHandler which will update the element accordingly. In the Then phase the same arguments + * will be passed to the get() method of a ViewFixtureHandler, which will then inspect the + * selected view element and return a value of a particular property of this element to the ViewFixture. + * The ViewFixture should mainly be used to check that the bindings between view elements in templates + * and the corresponding presentation model properties have been specified correctly. A test might set a value on the + * view element in the Given or When phases and then check in the Then phase that this value has been updated after + * updating the relevant presentation model property.

+ * *

Assuming that the ViewFixture has been added with the identifier view as a subfixture * of the ComponentFixture which has the identifier form, then the ViewFixture * can be used in the following way in a test: @@ -22,97 +30,131 @@ br.Core.thirdparty("es5-shim"); *

*

* In the above example the jQuery selector for the element in the view is - * .spotGeneralSummary [identifier=\'dealSubmittedFor\'] and it must be specified within parentheses. - * The following part of the statement, .text = 'test phrase', specifies the ViewFixtureHandler + * .spotGeneralSummary [identifier=\'dealSubmittedFor\'] and it must be specified within parentheses. The + * following part of the statement, .text = 'test phrase', specifies the ViewFixtureHandler * (Text) and the value ('test phrase') which will be passed to it. The Text - * ViewFixtureHandler will then get the text value of the selected view element and return this value - * to the ViewFixture. The test will pass if the text value of the selected view element is indeed equal - * to 'test phrase'. + * ViewFixtureHandler will then get the text value of the selected view element and return this value to + * the ViewFixture. The test will pass if the text value of the selected view element is indeed equal to + * 'test phrase'. *

- * + * * @implements br.test.Fixture - * - * @constructor - * Constructs a br.test.ViewFixture. - * @param {String} sViewSelector (optional) CSS selector to identify the parent view element for this fixture * + * @constructor + * Constructs a br.test.ViewFixture. + * @param {String} viewSelector (optional) CSS selector to identify the parent view element for this fixture */ -br.test.ViewFixture = function(sViewSelector) -{ - this.m_sViewSelector = sViewSelector || null; +function ViewFixture(viewSelector) { + this.m_sViewSelector = viewSelector || null; + + var Blurred = require('br/test/viewhandler/Blurred'); + var Checked = require('br/test/viewhandler/Checked'); + var ChildrenCount = require('br/test/viewhandler/ChildrenCount'); + var ClassName = require('br/test/viewhandler/ClassName'); + var Clicked = require('br/test/viewhandler/Clicked'); + var BackgroundImage = require('br/test/viewhandler/BackgroundImage'); + var DoesNotHaveClass = require('br/test/viewhandler/DoesNotHaveClass'); + var Enabled = require('br/test/viewhandler/Enabled'); + var FocusIn = require('br/test/viewhandler/FocusIn'); + var FocusOut = require('br/test/viewhandler/FocusOut'); + var Focused = require('br/test/viewhandler/Focused'); + var HasClass = require('br/test/viewhandler/HasClass'); + var Height = require('br/test/viewhandler/Height'); + var IsVisible = require('br/test/viewhandler/IsVisible'); + var MouseDown = require('br/test/viewhandler/MouseDown'); + var MouseMove = require('br/test/viewhandler/MouseMove'); + var MouseOut = require('br/test/viewhandler/MouseOut'); + var MouseOver = require('br/test/viewhandler/MouseOver'); + var MouseUp = require('br/test/viewhandler/MouseUp'); + var OnKeyUp = require('br/test/viewhandler/OnKeyUp'); + var Options = require('br/test/viewhandler/Options'); + var Readonly = require('br/test/viewhandler/Readonly'); + var RightClicked = require('br/test/viewhandler/RightClicked'); + var ScrolledHorizontal = require('br/test/viewhandler/ScrolledHorizontal'); + var ScrolledVertical = require('br/test/viewhandler/ScrolledVertical'); + var Selected = require('br/test/viewhandler/Selected'); + var Text = require('br/test/viewhandler/Text'); + var TypedValue = require('br/test/viewhandler/TypedValue'); + var Value = require('br/test/viewhandler/Value'); + var Width = require('br/test/viewhandler/Width'); + var BorderWidth = require('br/test/viewhandler/BorderWidth'); + var BorderColor = require('br/test/viewhandler/BorderColor'); + var TopMarginWidth = require('br/test/viewhandler/TopMarginWidth'); + var BottomMarginWidth = require('br/test/viewhandler/BottomMarginWidth'); + var RightMarginWidth = require('br/test/viewhandler/RightMarginWidth'); + var LeftMarginWidth = require('br/test/viewhandler/LeftMarginWidth'); + var Color = require('br/test/viewhandler/Color'); + var OnKeyDown = require('br/test/viewhandler/OnKeyDown'); + var Top = require('br/test/viewhandler/Top'); + this.m_mViewHandlers = { - blurred: new br.test.viewhandler.Blurred(), - checked: new br.test.viewhandler.Checked(), - childrenCount: new br.test.viewhandler.ChildrenCount(), - className: new br.test.viewhandler.ClassName(), - clicked: new br.test.viewhandler.Clicked(), - backgroundImage: new br.test.viewhandler.BackgroundImage(), - doesNotHaveClass: new br.test.viewhandler.DoesNotHaveClass(), - enabled: new br.test.viewhandler.Enabled(), - focusIn: new br.test.viewhandler.FocusIn(), - focusOut: new br.test.viewhandler.FocusOut(), - focused: new br.test.viewhandler.Focused(), - hasClass: new br.test.viewhandler.HasClass(), - height: new br.test.viewhandler.Height(), - isVisible: new br.test.viewhandler.IsVisible(), - mouseDown: new br.test.viewhandler.MouseDown(), - mouseMove: new br.test.viewhandler.MouseMove(), - mouseOut: new br.test.viewhandler.MouseOut(), - mouseOver: new br.test.viewhandler.MouseOver(), - mouseUp: new br.test.viewhandler.MouseUp(), - onKeyUp: new br.test.viewhandler.OnKeyUp(), - options: new br.test.viewhandler.Options(), - readonly: new br.test.viewhandler.Readonly(), - rightClicked: new br.test.viewhandler.RightClicked(), - scrolledHorizontal: new br.test.viewhandler.ScrolledHorizontal(), - scrolledVertical: new br.test.viewhandler.ScrolledVertical(), - selected: new br.test.viewhandler.Selected(), - text: new br.test.viewhandler.Text(), - typedValue: new br.test.viewhandler.TypedValue(), - value: new br.test.viewhandler.Value(), - width: new br.test.viewhandler.Width(), - borderWidth: new br.test.viewhandler.BorderWidth(), - borderColor: new br.test.viewhandler.BorderColor(), - topMarginWidth: new br.test.viewhandler.TopMarginWidth(), - bottomMarginWidth: new br.test.viewhandler.BottomMarginWidth(), - rightMarginWidth: new br.test.viewhandler.RightMarginWidth(), - leftMarginWidth: new br.test.viewhandler.LeftMarginWidth(), - color: new br.test.viewhandler.Color(), - onKeyDown: new br.test.viewhandler.OnKeyDown(), - top: new br.test.viewhandler.Top() + blurred: new Blurred(), + checked: new Checked(), + childrenCount: new ChildrenCount(), + className: new ClassName(), + clicked: new Clicked(), + backgroundImage: new BackgroundImage(), + doesNotHaveClass: new DoesNotHaveClass(), + enabled: new Enabled(), + focusIn: new FocusIn(), + focusOut: new FocusOut(), + focused: new Focused(), + hasClass: new HasClass(), + height: new Height(), + isVisible: new IsVisible(), + mouseDown: new MouseDown(), + mouseMove: new MouseMove(), + mouseOut: new MouseOut(), + mouseOver: new MouseOver(), + mouseUp: new MouseUp(), + onKeyUp: new OnKeyUp(), + options: new Options(), + readonly: new Readonly(), + rightClicked: new RightClicked(), + scrolledHorizontal: new ScrolledHorizontal(), + scrolledVertical: new ScrolledVertical(), + selected: new Selected(), + text: new Text(), + typedValue: new TypedValue(), + value: new Value(), + width: new Width(), + borderWidth: new BorderWidth(), + borderColor: new BorderColor(), + topMarginWidth: new TopMarginWidth(), + bottomMarginWidth: new BottomMarginWidth(), + rightMarginWidth: new RightMarginWidth(), + leftMarginWidth: new LeftMarginWidth(), + color: new Color(), + onKeyDown: new OnKeyDown(), + top: new Top() }; -}; +} +br.inherit(ViewFixture, Fixture); -br.Core.inherit(br.test.ViewFixture, br.test.Fixture); +ViewFixture.prototype.setUp = function() { + var viewElements; -br.test.ViewFixture.prototype.setUp = function() -{ - if(this.m_sViewSelector) - { - var pViewElements = jQuery(this.m_sViewSelector); - this._verifyOnlyOneElementSelected(pViewElements, this.m_sViewSelector); - this.setViewElement(pViewElements[0]); + if (this.m_sViewSelector) { + viewElements = jQuery(this.m_sViewSelector); + this._verifyOnlyOneElementSelected(viewElements, this.m_sViewSelector); + this.setViewElement(viewElements[0]); } }; -br.test.ViewFixture.prototype.tearDown = function() -{ +ViewFixture.prototype.tearDown = function() { this.m_eViewElement = null; - - if(this.m_oBlurHandler) - { + + if (this.m_oBlurHandler) { this.m_oBlurHandler.destroy(); } }; /** * Allows custom view handlers to be added. - * * @param {Map} viewHandlersMap A map of handler name to handler class constructor reference. - * * @throws {br.Errors.InvalidParametersError} If an attempt is made to override an existing handler. */ -br.test.ViewFixture.prototype.addViewHandlers = function(viewHandlersMap) { +ViewFixture.prototype.addViewHandlers = function(viewHandlersMap) { var keys = Object.keys(viewHandlersMap), existingHandlers = []; @@ -124,7 +166,7 @@ br.test.ViewFixture.prototype.addViewHandlers = function(viewHandlersMap) { }, this); if (existingHandlers.length > 0) { - throw new br.Errors.InvalidParametersError( + throw new Errors.InvalidParametersError( 'The following view handlers were not added to the registry as they already exist: ' + existingHandlers.join(',') ); @@ -135,130 +177,112 @@ br.test.ViewFixture.prototype.addViewHandlers = function(viewHandlersMap) { }, this); }; -br.test.ViewFixture.prototype.setViewElement = function(eViewElement) -{ - this.m_eViewElement = eViewElement; - this.m_oBlurHandler = new br.test.viewhandler.BlurHandler(eViewElement); +ViewFixture.prototype.setViewElement = function(viewElement) { + var BlurHandler = require('br/test/viewhandler/BlurHandler'); + + this.m_eViewElement = viewElement; + this.m_oBlurHandler = new BlurHandler(viewElement); }; -br.test.ViewFixture.prototype.getViewElement = function() -{ +ViewFixture.prototype.getViewElement = function() { return this.m_eViewElement; }; -br.test.ViewFixture.prototype.setViewElementWithoutAttachingBlurHandler = function(eViewElement) -{ - this.m_eViewElement = eViewElement; +ViewFixture.prototype.setViewElementWithoutAttachingBlurHandler = function(viewElement) { + this.m_eViewElement = viewElement; }; -br.test.ViewFixture.prototype.setComponent = function(oComponent) -{ - this.m_oComponent = oComponent; +ViewFixture.prototype.setComponent = function(Component) { + this.m_oComponent = Component; }; -br.test.ViewFixture.prototype.getComponent = function() -{ +ViewFixture.prototype.getComponent = function() { return this.m_oComponent; }; -// *** Fixture interface *** - -br.test.ViewFixture.prototype.canHandleProperty = function(sProperty) -{ +ViewFixture.prototype.canHandleProperty = function(propertyName) { return true; }; -br.test.ViewFixture.prototype.canHandleExactMatch = function() -{ +ViewFixture.prototype.canHandleExactMatch = function() { return false; }; -br.test.ViewFixture.prototype.doGivenAndDoWhen = function(sProperty, vValue) -{ - var oHandler = this._getHandler(sProperty, vValue); - - if(oHandler.property == "count") - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'count' property can only be used in then statements."); - } - else - { - oHandler.viewFixtureHandler.set(oHandler.selectedElement, vValue); +ViewFixture.prototype.doGivenAndDoWhen = function(propertyName, value) { + var handler = this._getHandler(propertyName, value); + + if (handler.property === 'count') { + throw new Errors.InvalidTestError('The "count" property can only be used in then statements.'); + } else { + handler.viewFixtureHandler.set(handler.selectedElement, value); } }; -br.test.ViewFixture.prototype.doGiven = br.test.ViewFixture.prototype.doGivenAndDoWhen; -br.test.ViewFixture.prototype.doWhen = br.test.ViewFixture.prototype.doGivenAndDoWhen; - -br.test.ViewFixture.prototype.doThen = function(sProperty, vValue) -{ - var oHandler = this._getHandler(sProperty, vValue); - - if(oHandler.property == "count") - { - assertEquals("'count' should be " + vValue, vValue, oHandler.elements.length); - } - else - { - assertEquals("'" + oHandler.property + "' should be " + vValue, - vValue, oHandler.viewFixtureHandler.get(oHandler.selectedElement, vValue)); + +ViewFixture.prototype.doGiven = ViewFixture.prototype.doGivenAndDoWhen; +ViewFixture.prototype.doWhen = ViewFixture.prototype.doGivenAndDoWhen; + +ViewFixture.prototype.doThen = function(propertyName, Value) { + var handler = this._getHandler(propertyName, Value); + + if (handler.property === 'count') { + assertEquals('"count" should be ' + Value, Value, handler.elements.length); + } else { + assertEquals( + '"' + handler.property + '" should be ' + Value, + Value, + handler.viewFixtureHandler.get(handler.selectedElement, Value) + ); } }; -br.test.ViewFixture.prototype._getHandler = function(sProperty, vValue) -{ - var oHandler = {}; - - oHandler.property = this._getPropertyName(sProperty); - oHandler.elements = this._getViewElements(sProperty); - - if(oHandler.property != "count") - { - oHandler.viewFixtureHandler = this._getViewHandler(oHandler.property); - - if(oHandler.elements.length == 1) - { - oHandler.selectedElement = oHandler.elements[0]; - } - else - { - this._verifyOnlyOneElementSelected(oHandler.elements, oHandler.property); +/** @private */ +ViewFixture.prototype._getHandler = function(propertyName, value) { + var handler = {}; + + handler.property = this._getPropertyName(propertyName); + handler.elements = this._getViewElements(propertyName); + + if (handler.property !== 'count') { + handler.viewFixtureHandler = this._getViewHandler(handler.property); + + if (handler.elements.length === 1) { + handler.selectedElement = handler.elements[0]; + } else { + this._verifyOnlyOneElementSelected(handler.elements, handler.property); } } - - return oHandler; + + return handler; }; -br.test.ViewFixture.prototype._getPropertyName = function (sProperty) -{ - return sProperty.match(/[^\.]*$/)[0]; +/** @private */ +ViewFixture.prototype._getPropertyName = function (propertyName) { + return propertyName.match(/[^\.]*$/)[0]; }; -br.test.ViewFixture.prototype._getViewElements = function(sProperty) -{ - var sSelector = sProperty.match(/\((.*)\)\.[^.]+/)[1]; - return jQuery(this.m_eViewElement).find(sSelector); +/** @private */ +ViewFixture.prototype._getViewElements = function(propertyName) { + var selector = propertyName.match(/\((.*)\)\.[^.]+/)[1]; + return jQuery(this.m_eViewElement).find(selector); }; -br.test.ViewFixture.prototype._verifyOnlyOneElementSelected = function(pElements, sSelector) -{ - if (pElements.length === 0) - { - throw "No view element found for '" + sSelector + "'"; - } - else if (pElements.length > 1) - { - throw "More than one view element found for '" + sSelector + "'"; +/** @private */ +ViewFixture.prototype._verifyOnlyOneElementSelected = function(elements, selector) { + if (elements.length === 0) { + throw 'No view element found for "' + selector + '"'; + } else if (elements.length > 1) { + throw 'More than one view element found for "' + selector + '"'; } }; -br.test.ViewFixture.prototype._getViewHandler = function(sPropertyName) -{ - var oHandler = this.m_mViewHandlers[sPropertyName]; - - if(!oHandler) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Undefined view fixture handler '" + sPropertyName + "'"); +ViewFixture.prototype._getViewHandler = function(propertyName) { + var handler = this.m_mViewHandlers[propertyName]; + + if (!handler) { + throw new Errors.InvalidTestError('Undefined view fixture handler "' + propertyName + '"'); } - - return oHandler; + + return handler; }; + +module.exports = ViewFixture; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BackgroundImage.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BackgroundImage.js index 7ee206ff4..c921c6210 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BackgroundImage.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BackgroundImage.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.BackgroundImage * @class * BackgroundImage ViewFixtureHandler can be used to test the background image value. * Example usage: @@ -11,19 +18,17 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.BackgroundImage = function() -{ -}; +function BackgroundImage() { +} +br.implement(BackgroundImage, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.BackgroundImage, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.BackgroundImage.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "BackgroundImage can't be used in a Given or When clause."); +BackgroundImage.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("BackgroundImage can't be used in a Given or When clause."); }; -br.test.viewhandler.BackgroundImage.prototype.get = function(eElement) -{ +BackgroundImage.prototype.get = function(eElement) { var sProperty = "div." + eElement.className; return jQuery(sProperty)[0].style.backgroundImage }; + +module.exports = BackgroundImage; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BlurHandler.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BlurHandler.js index 3159f6248..c8238f2f0 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BlurHandler.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BlurHandler.js @@ -1,27 +1,27 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); /** * @private */ -br.test.viewhandler.BlurHandler = function(eViewElement) -{ +function BlurHandler(eViewElement) { this.m_fOnBlur = this._onBlur.bind(this); this.m_eViewElement = eViewElement; this.m_sOnBlurListenerId = jQuery(this.m_eViewElement).on("blur", this.m_fOnBlur); }; -br.test.viewhandler.BlurHandler.prototype.destroy = function() -{ +BlurHandler.prototype.destroy = function() { jQuery(this.m_eViewElement).off("blur", this.m_fOnBlur); }; -br.test.viewhandler.BlurHandler.prototype._onBlur = function(oEvent) -{ +BlurHandler.prototype._onBlur = function(oEvent) { var eElement = oEvent.target || oEvent.srcElement; - if(eElement.fireOnChange) - { + if (eElement.fireOnChange) { delete eElement.fireOnChange; jQuery(eElement).trigger("change"); } }; + +module.exports = BlurHandler; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Blurred.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Blurred.js index 7ec6e25ea..73c24270f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Blurred.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Blurred.js @@ -1,6 +1,14 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Focused = require('br/test/viewhandler/Focused'); /** + * @name br/test.viewhandler.Blurred * @class * Blurred ViewFixtureHandler can be used to trigger blur or focus events on the view element. * Example usage: @@ -11,49 +19,39 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Blurred = function() -{ -}; - -br.Core.implement(br.test.viewhandler.Blurred, br.test.viewhandler.ViewFixtureHandler); +function Blurred() { +} +br.implement(Blurred, ViewFixtureHandler); -br.test.viewhandler.Blurred.prototype.set = function(eElement, vValue) -{ - if( !br.test.viewhandler.Focused.isFocusableElement(eElement) || eElement.disabled ) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'blurred' property is not available on non-focusable or disabled elements."); +Blurred.prototype.set = function(eElement, vValue) { + if ( !Focused.isFocusableElement(eElement) || eElement.disabled ) { + throw new Errors.InvalidTestError("The 'blurred' property is not available on non-focusable or disabled elements."); } - if(vValue === true) - { + if (vValue === true) { eElement.blur(); jQuery(eElement).trigger("blur"); - if(eElement.tagName.toLowerCase() == "input") + if (eElement.tagName.toLowerCase() == "input") { jQuery(eElement).trigger("change"); } - } - else if(vValue === false) - { + } else if (vValue === false) { eElement.focus(); - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'blurred' property only takes boolean values."); + } else { + throw new Errors.InvalidTestError("The 'blurred' property only takes boolean values."); } }; -br.test.viewhandler.Blurred.prototype.get = function(eElement) -{ - if(!br.test.viewhandler.Focused.isFocusableElement(eElement)) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'blurred' property is not available on non-focusable elements."); +Blurred.prototype.get = function(eElement) { + if (!Focused.isFocusableElement(eElement)) { + throw new Errors.InvalidTestError("The 'blurred' property is not available on non-focusable elements."); } - if(eElement === document.activeElement) - { + if (eElement === document.activeElement) { return false; } return true; }; + +module.exports = Blurred; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderColor.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderColor.js index 50662325e..e43e40464 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderColor.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderColor.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.BorderColor * @class * BorderColor ViewFixtureHandler can be used to test the border color of an element. * Example usage: @@ -11,26 +18,21 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.BorderColor = function() -{ -}; +function BorderColor() { +} +br.implement(BorderColor, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.BorderColor, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.BorderColor.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "BorderWidth can't be used in a Given or When clause."); +BorderColor.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("BorderWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.BorderColor.prototype.get = function(eElement) -{ +BorderColor.prototype.get = function(eElement) { var sColor = (jQuery(eElement)[0].style.borderColor).toLowerCase(); var digits = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(sColor); var sHexColor; - if (digits) - { + if (digits) { var red = parseInt(digits[1]); var green = parseInt(digits[2]); var blue = parseInt(digits[3]); @@ -38,15 +40,12 @@ br.test.viewhandler.BorderColor.prototype.get = function(eElement) var rgb = 1 << 24 | blue | (green << 8) | (red << 16); sHexColor = '#' + rgb.toString(16).substr(1); - } - else if (sColor.match(/^#[0-9a-f]{6}/i)) - { + } else if (sColor.match(/^#[0-9a-f]{6}/i)) { sHexColor = sColor; - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Color format was not expected"); + } else { + throw new Errors.InvalidTestError("Color format was not expected"); } return sHexColor.toUpperCase(); }; +module.exports = BorderColor; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderWidth.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderWidth.js index 5e829ed5c..8bd8a780f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderWidth.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BorderWidth.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.BorderWidth * @class * BorderWidth ViewFixtureHandler can be used to test the border width of an element. * Example usage: @@ -11,18 +18,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.BorderWidth = function() -{ -}; +function BorderWidth() { +} +br.implement(BorderWidth, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.BorderWidth, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.BorderWidth.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "BorderWidth can't be used in a Given or When clause."); +BorderWidth.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("BorderWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.BorderWidth.prototype.get = function(eElement) -{ +BorderWidth.prototype.get = function(eElement) { return parseInt(jQuery(eElement)[0].style.borderWidth); }; + +module.exports = BorderWidth; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BottomMarginWidth.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BottomMarginWidth.js index 668ced60e..61a21ff06 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BottomMarginWidth.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/BottomMarginWidth.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.BottomMarginWidth * @class * BottomMarginWidth ViewFixtureHandler can be used to test the bottom margin width of an element. * Example usage: @@ -11,22 +18,20 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.BottomMarginWidth = function() -{ -}; +function BottomMarginWidth() { +} +br.implement(BottomMarginWidth, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.BottomMarginWidth, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.BottomMarginWidth.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "BottomMarginWidth can't be used in a Given or When clause."); +BottomMarginWidth.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("BottomMarginWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.BottomMarginWidth.prototype.get = function(eElement) -{ +BottomMarginWidth.prototype.get = function(eElement) { var sMargin = jQuery(eElement)[0].style.margin; var pWidthValues = sMargin.match(/\d+/g); return pWidthValues.length == 4 ? pWidthValues[2] : pWidthValues[0] ; }; + +module.exports = BottomMarginWidth; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Checked.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Checked.js index 1c38c2c7d..4bf191f06 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Checked.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Checked.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.Checked * @class * Checked ViewFixtureHandler can be used to trigger checked property of a checkbox or a radiobutton. * Example usage: @@ -8,33 +16,28 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Checked = function() -{ -}; +function Checked() { +} +br.implement(Checked, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Checked, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Checked.prototype.get = function(eElement) -{ - if (eElement.checked === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Only checkboxes and radio buttons have the 'checked' property."); +Checked.prototype.get = function(eElement) { + if (eElement.checked === undefined) { + throw new Errors.InvalidTestError("Only checkboxes and radio buttons have the 'checked' property."); } return eElement.checked; }; -br.test.viewhandler.Checked.prototype.set = function(eElement, vValue) -{ - if (eElement.checked === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Only checkboxes and radio buttons can have the 'checked' property set."); +Checked.prototype.set = function(eElement, vValue) { + if (eElement.checked === undefined) { + throw new Errors.InvalidTestError("Only checkboxes and radio buttons can have the 'checked' property set."); } - if (!(vValue === true || vValue === false)) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "the 'checked' property can only be set to true or false."); + if (!(vValue === true || vValue === false)) { + throw new Errors.InvalidTestError("the 'checked' property can only be set to true or false."); } - br.test.Utils.fireDomEvent(eElement, 'click'); - br.test.Utils.fireDomEvent(eElement, 'change'); + Utils.fireDomEvent(eElement, 'click'); + Utils.fireDomEvent(eElement, 'change'); eElement.checked = vValue; }; + +module.exports = Checked; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ChildrenCount.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ChildrenCount.js index 7a4e33939..180700e9c 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ChildrenCount.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ChildrenCount.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.ChildrenCount * @class * ChildrenCount ViewFixtureHandler can be used to get number of child elements for a view element. * Example usage: @@ -10,18 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.ChildrenCount = function() -{ -}; +function ChildrenCount() { +} +br.implement(ChildrenCount, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.ChildrenCount, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.ChildrenCount.prototype.get = function(eElement) -{ +ChildrenCount.prototype.get = function(eElement) { return jQuery(eElement).children().length; }; -br.test.viewhandler.ChildrenCount.prototype.set = function(eElement, vValue) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "ChildrenCount value can not be set on an object and therefore should only be used in a then clause."); +ChildrenCount.prototype.set = function(eElement, vValue) { + throw new Errors.InvalidTestError("ChildrenCount value can not be set on an object and therefore should only be used in a then clause."); }; + +module.exports = ChildrenCount; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ClassName.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ClassName.js index efe063719..9aef42260 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ClassName.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ClassName.js @@ -1,4 +1,11 @@ +'use strict' + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); + /** + * @name br.test.viewhandler.ClassName * @class * ClassName ViewFixtureHandler can be used to get a class of a view element. * Example usage: @@ -7,22 +14,20 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.ClassName = function() -{ -}; +function ClassName() { +} +br.implement(ClassName, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.ClassName, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.ClassName.prototype.get = function(eElement) -{ +ClassName.prototype.get = function(eElement) { return eElement.className; }; -br.test.viewhandler.ClassName.prototype.set = function(eElement, vValue) -{ +ClassName.prototype.set = function(eElement, vValue) { if (typeof vValue !== "string") { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "className can only be set to a String."); + throw new Errors.InvalidTestError("className can only be set to a String."); } else { eElement.className = vValue; } }; + +module.exports = ClassName; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Clicked.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Clicked.js index 914db0153..47acb2eef 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Clicked.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Clicked.js @@ -1,6 +1,14 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); /** + * @name br.test.viewhandler.Clicked * @class * Clicked ViewFixtureHandler can be used to trigger a click on a view element. * Example usage: @@ -10,25 +18,21 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Clicked = function() -{ -}; - -br.Core.implement(br.test.viewhandler.Clicked, br.test.viewhandler.ViewFixtureHandler); +function Clicked() { +} +br.implement(Clicked, ViewFixtureHandler); - -br.test.viewhandler.Clicked.prototype.set = function(eElement, mArgs) -{ +Clicked.prototype.set = function(eElement, mArgs) { var jq_Element = jQuery(eElement); - + if ( jq_Element.hasClass("disabled") || jq_Element.is(":disabled") ) { return; } - + if (document.activeElement && document.activeElement != eElement && document.activeElement.tagName && document.activeElement.tagName.toLowerCase() != 'body') { - jq_activeElement = jQuery(document.activeElement) + var jq_activeElement = jQuery(document.activeElement) jq_activeElement.trigger('focusout'); var active_nodeName = jq_activeElement[0].nodeName.toLowerCase(); @@ -37,10 +41,10 @@ br.test.viewhandler.Clicked.prototype.set = function(eElement, mArgs) jq_activeElement.trigger('change'); } } - + var element_nodeName = jq_Element[0].nodeName.toLowerCase(); var element_inputType = (jq_Element.attr('type')) ? jq_Element.attr('type').toLowerCase() : ""; - + jq_Element.trigger('focusin'); jq_Element.trigger('focus'); try { @@ -50,25 +54,25 @@ br.test.viewhandler.Clicked.prototype.set = function(eElement, mArgs) eElement.setActive() } } - - br.test.Utils.fireMouseEvent(eElement, 'click', mArgs); - + + Utils.fireMouseEvent(eElement, 'click', mArgs); + if ( element_nodeName == 'select' || ( element_nodeName == 'input' && element_inputType != 'submit' ) ) { jq_Element.trigger('change'); } - + if ( ( (element_nodeName == 'input' && element_inputType == 'submit') || element_nodeName == 'button') ) { - elementParentForm = jq_Element.parents('form') + var elementParentForm = jq_Element.parents('form') if (elementParentForm != null && (elementParentForm.attr('action') != null || elementParentForm.attr('onsubmit') != null)) { elementParentForm.trigger('submit'); } } - }; -br.test.viewhandler.Clicked.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Clicked can't be used in a then clause."); +Clicked.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("Clicked can't be used in a then clause."); }; + +module.exports = Clicked; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Color.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Color.js index f1bd2fa7d..d673fdd60 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Color.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Color.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Color * @class * Color ViewFixtureHandler can be used to test the bottom margin width of an element. * Example usage: @@ -11,26 +18,21 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Color = function() -{ -}; +function Color() { +} +br.implement(Color, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Color, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Color.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Color can't be used in a Given or When clause."); +Color.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("Color can't be used in a Given or When clause."); }; -br.test.viewhandler.Color.prototype.get = function(eElement) -{ +Color.prototype.get = function(eElement) { var sColor = (jQuery(eElement)[0].style.color).toLowerCase(); var digits = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(sColor); var sHexColor; - if (digits) - { + if (digits) { var red = parseInt(digits[1]); var green = parseInt(digits[2]); var blue = parseInt(digits[3]); @@ -38,15 +40,12 @@ br.test.viewhandler.Color.prototype.get = function(eElement) var rgb = 1 << 24 | blue | (green << 8) | (red << 16); sHexColor = '#' + rgb.toString(16).substr(1); - } - else if (sColor.match(/^#[0-9a-f]{6}/i)) - { + } else if (sColor.match(/^#[0-9a-f]{6}/i)) { sHexColor = sColor; - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Color format was not expected"); + } else { + throw new Errors.InvalidTestError("Color format was not expected"); } return sHexColor.toUpperCase(); }; +module.exports = Color; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/DoesNotHaveClass.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/DoesNotHaveClass.js index a4b50ff29..4bed85464 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/DoesNotHaveClass.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/DoesNotHaveClass.js @@ -1,4 +1,11 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); + /** + * @name br.test.viewhandler.DoesNotHaveClass * @class * DoesNotHaveClass ViewFixtureHandler can be used to verify that a view element * does not have a particular class. Example usage: @@ -8,23 +15,20 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.DoesNotHaveClass = function() -{ -}; +function DoesNotHaveClass() { +} +br.implement(DoesNotHaveClass, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.DoesNotHaveClass, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.DoesNotHaveClass.prototype.get = function(eElement, sClassName) -{ - if(eElement.className.match("(^| )" + sClassName + "($| )")) { +DoesNotHaveClass.prototype.get = function(eElement, sClassName) { + if (eElement.className.match("(^| )" + sClassName + "($| )")) { return null; - } - else { + } else { return sClassName; } }; -br.test.viewhandler.DoesNotHaveClass.prototype.set = function(eElement, sClassName) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "doesNotHaveClass can't be used in a Given or When clause."); +DoesNotHaveClass.prototype.set = function(eElement, sClassName) { + throw new Errors.InvalidTestError("doesNotHaveClass can't be used in a Given or When clause."); }; + +module.exports = DoesNotHaveClass; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Enabled.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Enabled.js index 0a98f8a49..eb60d6e55 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Enabled.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Enabled.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Enabled * @class * Enabled ViewFixtureHandler can be used to enable and disable a view element * by setting the disabled attribute. @@ -11,47 +18,41 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Enabled = function(){ -}; - -br.Core.implement(br.test.viewhandler.Enabled, br.test.viewhandler.ViewFixtureHandler); +function Enabled(){ +} +br.implement(Enabled, ViewFixtureHandler); -br.test.viewhandler.Enabled.prototype.get = function(eElement) -{ +Enabled.prototype.get = function(eElement) { - var pElementsToTest = jQuery(eElement).add(jQuery(eElement).parents()); + var pElementsToTest = jQuery(eElement).add(jQuery(eElement).parents()); - for(var i = 0; i < pElementsToTest.length; i++) + for (var i = 0; i < pElementsToTest.length; i++) - { - var eElementToTest = jQuery(pElementsToTest[i]); - if(eElementToTest.is(":disabled")) - { - return false; - } - } - return true; + { + var eElementToTest = jQuery(pElementsToTest[i]); + if (eElementToTest.is(":disabled")) + { + return false; + } + } + return true; }; -br.test.viewhandler.Enabled.prototype.set = function(eElement, vValue) -{ +Enabled.prototype.set = function(eElement, vValue) { // Using strict equality to detect non-boolean vValue's - if (vValue === true) - { + if (vValue === true) { // Disabled elements make their descendants disabled too, so if someone // tries to enable such a child, FAIL. if (jQuery(eElement).parents(":disabled").length > 0) { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Can not enable element with a disabled ancestor.") + throw new Errors.InvalidTestError("Can not enable element with a disabled ancestor.") } eElement.disabled = false; - } - else if (vValue === false) - { + } else if (vValue === false) { eElement.disabled = true; - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "enabled can only be set with a boolean value."); + } else { + throw new Errors.InvalidTestError("enabled can only be set with a boolean value."); } }; + +module.exports = Enabled; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusIn.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusIn.js index e8b865f4b..a9aabd252 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusIn.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusIn.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.FocusIn * @class * FocusIn ViewFixtureHandler can be used to trigger focusin on a view element. * Example usage: @@ -10,19 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.FocusIn = function() -{ -}; +function FocusIn() { +} +br.implement(FocusIn, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.FocusIn, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.FocusIn.prototype.set = function(eElement) -{ +FocusIn.prototype.set = function(eElement) { jQuery(eElement).trigger('focusin'); }; -br.test.viewhandler.FocusIn.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The focusIn event cannot be used in a doGiven or doThen"); +FocusIn.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The focusIn event cannot be used in a doGiven or doThen"); }; + +module.exports = FocusIn; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusOut.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusOut.js index 7228fa10e..3daa63f62 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusOut.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/FocusOut.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.FocusOut * @class * FocusOut ViewFixtureHandler can be used to trigger focusout on a view element. * Example usage: @@ -10,19 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.FocusOut = function() -{ -}; +function FocusOut() { +} +br.implement(FocusOut, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.FocusOut, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.FocusOut.prototype.set = function(eElement) -{ +FocusOut.prototype.set = function(eElement) { jQuery(eElement).trigger('focusout'); }; -br.test.viewhandler.FocusOut.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The focusOut event cannot be used in a doGiven or doThen"); +FocusOut.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The focusOut event cannot be used in a doGiven or doThen"); }; + +module.exports = FocusOut; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Focused.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Focused.js index 148352cb2..71dc98b89 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Focused.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Focused.js @@ -1,4 +1,11 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); + /** + * @name br.test.viewhandler.Focused * @class * Focused ViewFixtureHandler can be used to trigger focus and blur on a view element. * Example usage: @@ -8,51 +15,40 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Focused = function() -{ -}; - -br.Core.implement(br.test.viewhandler.Focused, br.test.viewhandler.ViewFixtureHandler); +function Focused() { +} +br.implement(Focused, ViewFixtureHandler); -br.test.viewhandler.Focused.focusableElements = {"A" : true, "BODY" : true, "BUTTON" : true, "FRAME" : true, "IFRAME" : true, "IMG" : true, "INPUT" : true, "ISINDEX" : true, +Focused.focusableElements = {"A" : true, "BODY" : true, "BUTTON" : true, "FRAME" : true, "IFRAME" : true, "IMG" : true, "INPUT" : true, "ISINDEX" : true, "OBJECT" : true, "SELECT" : true, "TEXTAREA" : true}; -br.test.viewhandler.Focused.isFocusableElement = function(eElement) -{ +Focused.isFocusableElement = function(eElement) { return (eElement.tabIndex > 0) || ((eElement.tabIndex === 0) && this.focusableElements[eElement.tagName]); }; -br.test.viewhandler.Focused.prototype.set = function(eElement, vValue) -{ - if( !br.test.viewhandler.Focused.isFocusableElement(eElement) || eElement.disabled ) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'focused' property is not available on non-focusable or disabled elements."); +Focused.prototype.set = function(eElement, vValue) { + if ( !Focused.isFocusableElement(eElement) || eElement.disabled ) { + throw new Errors.InvalidTestError("The 'focused' property is not available on non-focusable or disabled elements."); } - if(vValue === true) - { + if (vValue === true) { eElement.focus(); - } - else if(vValue === false) - { + } else if (vValue === false) { eElement.blur(); - } - else - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'focused' property only takes boolean values."); + } else { + throw new Errors.InvalidTestError("The 'focused' property only takes boolean values."); } }; -br.test.viewhandler.Focused.prototype.get = function(eElement) -{ - if(!br.test.viewhandler.Focused.isFocusableElement(eElement)) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'focused' property is not available on non-focusable elements."); +Focused.prototype.get = function(eElement) { + if (!Focused.isFocusableElement(eElement)) { + throw new Errors.InvalidTestError("The 'focused' property is not available on non-focusable elements."); } - if(eElement === document.activeElement) - { + if (eElement === document.activeElement) { return true; } return false; }; + +module.exports = Focused; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/HasClass.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/HasClass.js index 45cb5a841..572de5b59 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/HasClass.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/HasClass.js @@ -1,4 +1,11 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); + /** + * @name br.test.viewhandler.HasClass * @class * HasClass ViewFixtureHandler can be used to verify that a view element * has a particular class. Example usage: @@ -8,23 +15,20 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.HasClass = function() -{ -}; +function HasClass() { +} +br.implement(HasClass, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.HasClass, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.HasClass.prototype.get = function(eElement, sClassName) -{ - if(eElement.className.match("(^| )" + sClassName + "($| )")) { +HasClass.prototype.get = function(eElement, sClassName) { + if (eElement.className.match("(^| )" + sClassName + "($| )")) { return sClassName; - } - else { + } else { return null; } }; -br.test.viewhandler.HasClass.prototype.set = function(eElement, sClassName) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "hasClass can't be used in a Given or When clause."); +HasClass.prototype.set = function(eElement, sClassName) { + throw new Errors.InvalidTestError("hasClass can't be used in a Given or When clause."); }; + +module.exports = HasClass; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Height.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Height.js index c860d5244..84028321a 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Height.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Height.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Height * @class * Height ViewFixtureHandler can be used to get height of a view element. * Example usage: @@ -10,19 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Height = function() -{ -}; +function Height() { +} +br.implement(Height, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Height, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.Height.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The Height attribute for a element cannot be set directly and should be set via the viewModel."); +Height.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("The Height attribute for a element cannot be set directly and should be set via the viewModel."); }; -br.test.viewhandler.Height.prototype.get = function(eElement) -{ +Height.prototype.get = function(eElement) { return jQuery(eElement).height(); }; + +module.exports = Height; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/IsVisible.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/IsVisible.js index d3c281874..2242a9986 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/IsVisible.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/IsVisible.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.IsVisible * @class * IsVisible ViewFixtureHandler can be used to check if a view element is visible. * Example usage: @@ -10,19 +17,15 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.IsVisible = function() -{ -}; +function IsVisible() { +} +br.implement(IsVisible, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.IsVisible, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.IsVisible.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Visibility can't be used in a Given or When clause."); +IsVisible.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("Visibility can't be used in a Given or When clause."); }; -br.test.viewhandler.IsVisible.prototype.get = function(eElement) -{ +IsVisible.prototype.get = function(eElement) { // Definition of invisible from jQuery API ... // Elements can be considered hidden for several reasons: // @@ -37,3 +40,5 @@ br.test.viewhandler.IsVisible.prototype.get = function(eElement) var sVisibility = jQuery(eElement).css("visibility"); return jQuery(eElement).is(":visible") && sVisibility != 'hidden'; }; + +module.exports = IsVisible; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/LeftMarginWidth.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/LeftMarginWidth.js index adf34c5e9..8e1b765d0 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/LeftMarginWidth.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/LeftMarginWidth.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.LeftMarginWidth * @class * LeftMarginWidth ViewFixtureHandler can be used to test the left margin width of an element. * Example usage: @@ -11,22 +18,20 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.LeftMarginWidth = function() -{ -}; +function LeftMarginWidth() { +} +br.implement(LeftMarginWidth, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.LeftMarginWidth, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.LeftMarginWidth.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "LeftMarginWidth can't be used in a Given or When clause."); +LeftMarginWidth.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("LeftMarginWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.LeftMarginWidth.prototype.get = function(eElement) -{ +LeftMarginWidth.prototype.get = function(eElement) { var sMargin = jQuery(eElement)[0].style.margin; var pWidthValues = sMargin.match(/\d+/g); return pWidthValues.length == 4 ? pWidthValues[3] : pWidthValues.length == 2 ? pWidthValues[1] : pWidthValues[0] ; }; + +module.exports = LeftMarginWidth; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseDown.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseDown.js index fd8932b4c..7140c5347 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseDown.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseDown.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.MouseDown * @class * MouseDown ViewFixtureHandler can be used to trigger mousedown event for a view element. * Example usage: @@ -8,19 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.MouseDown = function() -{ -}; +function MouseDown() { +} +br.implement(MouseDown, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.MouseDown, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.MouseDown.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireMouseEvent(eElement, 'mousedown', mValues); +MouseDown.prototype.set = function(eElement, mValues) { + Utils.fireMouseEvent(eElement, 'mousedown', mValues); }; -br.test.viewhandler.MouseDown.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The mouseDown event cannot be used in a doGiven or doThen"); +MouseDown.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The mouseDown event cannot be used in a doGiven or doThen"); }; + +module.exports = MouseDown; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseMove.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseMove.js index 231bf14dc..e68e9eefe 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseMove.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseMove.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.MouseMove * @class * MouseMove ViewFixtureHandler can be used to trigger mousemove event for a view element. * Example usage: @@ -8,19 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.MouseMove = function() -{ -}; +function MouseMove() { +} +br.implement(MouseMove, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.MouseMove, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.MouseMove.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireMouseEvent(eElement, 'mousemove', mValues); +MouseMove.prototype.set = function(eElement, mValues) { + Utils.fireMouseEvent(eElement, 'mousemove', mValues); }; -br.test.viewhandler.MouseMove.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The mouseMove event cannot be used in a doGiven or doThen"); +MouseMove.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The mouseMove event cannot be used in a doGiven or doThen"); }; + +module.exports = MouseMove; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOut.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOut.js index e336e29b8..375d081fe 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOut.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOut.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.MouseOut * @class * MouseOut ViewFixtureHandler can be used to trigger mouseout event for a view element. * Example usage: @@ -8,19 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.MouseOut = function() -{ -}; +function MouseOut() { +} +br.implement(MouseOut, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.MouseOut, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.MouseOut.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireMouseEvent(eElement, 'mouseout', mValues); +MouseOut.prototype.set = function(eElement, mValues) { + Utils.fireMouseEvent(eElement, 'mouseout', mValues); }; -br.test.viewhandler.MouseOut.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The mouseOut event cannot be used in a doGiven or doThen"); +MouseOut.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The mouseOut event cannot be used in a doGiven or doThen"); }; + +module.exports = MouseOut; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOver.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOver.js index 3e6d86d78..3f8c852e6 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOver.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseOver.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.MouseOver * @class * MouseOver ViewFixtureHandler can be used to trigger mouseover event for a view element. * Example usage: @@ -8,19 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.MouseOver = function() -{ -}; +function MouseOver() { +} +br.implement(MouseOver, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.MouseOver, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.MouseOver.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireMouseEvent(eElement, 'mouseover', mValues); +MouseOver.prototype.set = function(eElement, mValues) { + Utils.fireMouseEvent(eElement, 'mouseover', mValues); }; -br.test.viewhandler.MouseOver.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The mouseOver event cannot be used in a doGiven or doThen"); +MouseOver.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The mouseOver event cannot be used in a doGiven or doThen"); }; + +module.exports = MouseOver; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseUp.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseUp.js index a424eb1d0..3f4f9b4ce 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseUp.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/MouseUp.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.MouseUp * @class * MouseUp ViewFixtureHandler can be used to trigger mouseup event for a view element. * Example usage: @@ -8,19 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.MouseUp = function() -{ -}; +function MouseUp() { +} +br.implement(MouseUp, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.MouseUp, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.MouseUp.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireMouseEvent(eElement, 'mouseup', mValues); +MouseUp.prototype.set = function(eElement, mValues) { + Utils.fireMouseEvent(eElement, 'mouseup', mValues); }; -br.test.viewhandler.MouseUp.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The mouseUp event cannot be used in a doGiven or doThen"); +MouseUp.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The mouseUp event cannot be used in a doGiven or doThen"); }; + +module.exports = MouseUp; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyDown.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyDown.js index a68e9b3a7..ae8303464 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyDown.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyDown.js @@ -1,19 +1,25 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.OnKeyDown * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.OnKeyDown = function() -{ -}; +function OnKeyDown() { +} +br.implement(OnKeyDown, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.OnKeyDown, br.test.viewhandler.ViewFixtureHandler); +OnKeyDown.prototype.set = function(eElement, mValues) { + Utils.fireKeyEvent(eElement, "keydown", mValues, null); +}; -br.test.viewhandler.OnKeyDown.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireKeyEvent(eElement, "keydown", mValues, null); +OnKeyDown.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The keyDown event cannot be used in a doGiven or doThen"); }; -br.test.viewhandler.OnKeyDown.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The keyDown event cannot be used in a doGiven or doThen"); -}; \ No newline at end of file +module.exports = OnKeyDown; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyUp.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyUp.js index 6e2a797de..4c732c1f6 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyUp.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/OnKeyUp.js @@ -1,19 +1,25 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.OnKeyUp * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.OnKeyUp = function() -{ -}; +function OnKeyUp() { +} +br.implement(OnKeyUp, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.OnKeyUp, br.test.viewhandler.ViewFixtureHandler); +OnKeyUp.prototype.set = function(eElement, mValues) { + Utils.fireKeyEvent(eElement, "keyup", mValues.sKey, mValues); +}; -br.test.viewhandler.OnKeyUp.prototype.set = function(eElement, mValues) -{ - br.test.Utils.fireKeyEvent(eElement, "keyup", mValues.sKey, mValues); +OnKeyUp.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The keyUp event cannot be used in a doGiven or doThen"); }; -br.test.viewhandler.OnKeyUp.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The keyUp event cannot be used in a doGiven or doThen"); -}; \ No newline at end of file +module.exports = OnKeyUp; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Options.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Options.js index e748ad455..5dd152d76 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Options.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Options.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Options * @class * Options ViewFixtureHandler can be used to set or get the value of options property * for a SELECT view element. @@ -11,36 +18,28 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Options = function() -{ -}; +function Options() { +} +br.implement(Options, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Options, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Options.prototype.set = function(eElement, pValues) -{ - if (eElement.tagName.toLowerCase() !== "select") - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'options' property is only available for SELECT elements."); +Options.prototype.set = function(eElement, pValues) { + if (eElement.tagName.toLowerCase() !== "select") { + throw new Errors.InvalidTestError("The 'options' property is only available for SELECT elements."); } - if (!(pValues instanceof Array)) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'options' property can only take an Array as its value."); + if (!(pValues instanceof Array)) { + throw new Errors.InvalidTestError("The 'options' property can only take an Array as its value."); } eElement.innerHTML = ""; - for (var idx = 0, max = pValues.length; idx < max; idx++) - { + for (var idx = 0, max = pValues.length; idx < max; idx++) { var eNewOption = document.createElement("option"); eNewOption.innerHTML = pValues[idx].toString(); eElement.appendChild(eNewOption); } }; -br.test.viewhandler.Options.prototype.get = function(eElement) -{ - if (eElement.tagName.toLowerCase() !== "select") - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'options' property is only available for SELECT elements."); +Options.prototype.get = function(eElement) { + if (eElement.tagName.toLowerCase() !== "select") { + throw new Errors.InvalidTestError("The 'options' property is only available for SELECT elements."); } var pOptions = []; jQuery(eElement).find("option").each(function(i,eOption){ @@ -48,3 +47,5 @@ br.test.viewhandler.Options.prototype.get = function(eElement) }); return pOptions; }; + +module.exports = Options; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Readonly.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Readonly.js index 4214f292b..cb9bb18a2 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Readonly.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Readonly.js @@ -1,4 +1,11 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); + /** + * @name br.test.viewhandler.Readonly * @class * ReadOnly ViewFixtureHandler can be used to set or get the readonly attribute of an input view element * Example usage: @@ -8,16 +15,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Readonly = function() -{ -}; -br.Core.implement(br.test.viewhandler.Readonly, br.test.viewhandler.ViewFixtureHandler); -br.test.viewhandler.Readonly.prototype.set = function(eElement, vValue) -{ +function Readonly() { +} +br.implement(Readonly, ViewFixtureHandler); + +Readonly.prototype.set = function(eElement, vValue) { eElement.readOnly= (vValue === true); }; -br.test.viewhandler.Readonly.prototype.get = function(eElement) -{ + +Readonly.prototype.get = function(eElement) { return eElement.readOnly; }; +module.exports = Readonly; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightClicked.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightClicked.js index ed85266ef..f52a753f8 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightClicked.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightClicked.js @@ -1,4 +1,12 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.RightClicked * @class * RightClicked ViewFixtureHandler can be used to trigger contextmenu event for a view element. * Example usage: @@ -8,18 +16,16 @@ * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.RightClicked = function() -{ -}; -br.Core.implement(br.test.viewhandler.RightClicked, br.test.viewhandler.ViewFixtureHandler); +function RightClicked() { +} +br.implement(RightClicked, ViewFixtureHandler); - -br.test.viewhandler.RightClicked.prototype.set = function(eElement) -{ - br.test.Utils.fireMouseEvent(eElement, "contextmenu"); +RightClicked.prototype.set = function(eElement) { + Utils.fireMouseEvent(eElement, "contextmenu"); }; -br.test.viewhandler.RightClicked.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Clicked can't be used in a then clause."); +RightClicked.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("Clicked can't be used in a then clause."); }; + +module.exports = RightClicked; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightMarginWidth.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightMarginWidth.js index 7e8e0976b..7d1f884ca 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightMarginWidth.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/RightMarginWidth.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.RightMarginWidth * @class * RightMarginWidth ViewFixtureHandler can be used to test the right margin width of an element. * Example usage: @@ -11,22 +18,20 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.RightMarginWidth = function() -{ -}; - -br.Core.implement(br.test.viewhandler.RightMarginWidth, br.test.viewhandler.ViewFixtureHandler); +function RightMarginWidth() { +} +br.implement(RightMarginWidth, ViewFixtureHandler); -br.test.viewhandler.RightMarginWidth.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "RightMarginWidth can't be used in a Given or When clause."); +RightMarginWidth.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("RightMarginWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.RightMarginWidth.prototype.get = function(eElement) -{ +RightMarginWidth.prototype.get = function(eElement) { var sMargin = jQuery(eElement)[0].style.margin; - + var pWidthValues = sMargin.match(/\d+/g); - + return pWidthValues.length == 4 ? pWidthValues[1] : pWidthValues.length == 2 ? pWidthValues[1] : pWidthValues[0] ; }; + +module.exports = RightMarginWidth; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledHorizontal.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledHorizontal.js index 9bea50eea..6140dc9b4 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledHorizontal.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledHorizontal.js @@ -1,24 +1,29 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.ScrolledHorizontal * @class * ScrolledHorizontal ViewFixtureHandler can be used to trigger a horizontal scroll on a view element. * * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.ScrolledHorizontal = function() -{ -}; +function ScrolledHorizontal() { +} +br.implement(ScrolledHorizontal, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.ScrolledHorizontal, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.ScrolledHorizontal.prototype.set = function(eElement, nOffset) -{ +ScrolledHorizontal.prototype.set = function(eElement, nOffset) { eElement.scrollLeft += parseFloat(nOffset); - br.test.Utils.fireScrollEvent(eElement); + Utils.fireScrollEvent(eElement); }; -br.test.viewhandler.ScrolledHorizontal.prototype.get = function(eElement) -{ +ScrolledHorizontal.prototype.get = function(eElement) { return eElement.scrollLeft; }; + +module.exports = ScrolledHorizontal; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledVertical.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledVertical.js index ea3e40e2d..6561ebc8c 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledVertical.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ScrolledVertical.js @@ -1,24 +1,29 @@ +'use strict'; + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); + /** + * @name br.test.viewhandler.ScrolledVertical * @class * ScrolledVertical ViewFixtureHandler can be used to trigger a vertical scroll on a view element. * * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.ScrolledVertical = function() -{ -}; +function ScrolledVertical() { +} +br.implement(ScrolledVertical, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.ScrolledVertical, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.ScrolledVertical.prototype.set = function(eElement, nOffset) -{ +ScrolledVertical.prototype.set = function(eElement, nOffset) { eElement.scrollTop += parseFloat(nOffset); - br.test.Utils.fireScrollEvent(eElement); + Utils.fireScrollEvent(eElement); }; -br.test.viewhandler.ScrolledVertical.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "ScrolledVertical can't be used in a then clause."); +ScrolledVertical.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("ScrolledVertical can't be used in a then clause."); }; + +module.exports = ScrolledVertical; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Selected.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Selected.js index a7bfef6a7..a373402eb 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Selected.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Selected.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Selected * @class * Selected ViewFixtureHandler can be used to get or set selected * property of an OPTION view element. @@ -11,32 +18,28 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Selected = function(){ -}; +function Selected(){ +} +br.implement(Selected, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Selected, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Selected.prototype.get = function(eElement) -{ - if (eElement.selected === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Only Option elements have the 'selected' property."); +Selected.prototype.get = function(eElement) { + if (eElement.selected === undefined) { + throw new Errors.InvalidTestError("Only Option elements have the 'selected' property."); } return eElement.selected; }; -br.test.viewhandler.Selected.prototype.set = function(eElement, vValue) -{ - if (eElement.selected === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Only Option elements have their 'selected' property set."); +Selected.prototype.set = function(eElement, vValue) { + if (eElement.selected === undefined) { + throw new Errors.InvalidTestError("Only Option elements have their 'selected' property set."); } - if (!(vValue === true || vValue === false)) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "the 'selected' property can only be set to true or false."); + if (!(vValue === true || vValue === false)) { + throw new Errors.InvalidTestError("the 'selected' property can only be set to true or false."); } if (eElement.selected != vValue) { eElement.selected = vValue; jQuery(eElement).parent('select').trigger("change"); } }; + +module.exports = Selected; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Text.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Text.js index 56209d6c5..0dd5797d5 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Text.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Text.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Text * @class * Text ViewFixtureHandler can be used to set or get text property of a view element. * Example usage: @@ -10,26 +17,22 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Text = function() -{ -}; +function Text() { +} +br.implement(Text, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Text, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Text.prototype.get = function(eElement) -{ - if (eElement.tagName.toLowerCase() === "input") - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Can not use the 'text' property on INPUT elements, try using 'value'."); +Text.prototype.get = function(eElement) { + if (eElement.tagName.toLowerCase() === "input") { + throw new Errors.InvalidTestError("Can not use the 'text' property on INPUT elements, try using 'value'."); } return jQuery(eElement).text(); }; -br.test.viewhandler.Text.prototype.set = function(eElement, vValue) -{ - if (eElement.tagName.toLowerCase() === "input") - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "Can not use the 'text' property on INPUT elements, try using 'value'."); +Text.prototype.set = function(eElement, vValue) { + if (eElement.tagName.toLowerCase() === "input") { + throw new Errors.InvalidTestError("Can not use the 'text' property on INPUT elements, try using 'value'."); } jQuery(eElement).text(vValue); }; + +module.exports = Text; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Top.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Top.js index 2202ab3ce..558b1a116 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Top.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Top.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Top * @class * Top ViewFixtureHandler can be used to get style.top value of a view element. * Example usage: @@ -10,19 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Top = function() -{ -}; +function Top() { +} +br.implement(Top, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Top, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.Top.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The Top attribute for a element cannot be set directly and should be set via the viewModel."); +Top.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("The Top attribute for a element cannot be set directly and should be set via the viewModel."); }; -br.test.viewhandler.Top.prototype.get = function(eElement) -{ +Top.prototype.get = function(eElement) { return jQuery(eElement)[0].style.top; }; + +module.exports = Top; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TopMarginWidth.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TopMarginWidth.js index c37e77f82..69abf1b11 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TopMarginWidth.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TopMarginWidth.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.TopMarginWidth * @class * TopMarginWidth ViewFixtureHandler can be used to test the top margin width of an element. * Example usage: @@ -11,22 +18,20 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.TopMarginWidth = function() -{ -}; +function TopMarginWidth() { +} +br.implement(TopMarginWidth, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.TopMarginWidth, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.TopMarginWidth.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "TopMarginWidth can't be used in a Given or When clause."); +TopMarginWidth.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("TopMarginWidth can't be used in a Given or When clause."); }; -br.test.viewhandler.TopMarginWidth.prototype.get = function(eElement) -{ +TopMarginWidth.prototype.get = function(eElement) { var sMargin = jQuery(eElement)[0].style.margin; pWidthValues = /\d+/.exec(sMargin); return parseInt(pWidthValues); }; + +module.exports = TopMarginWidth; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TypedValue.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TypedValue.js index d35487d47..257074522 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TypedValue.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/TypedValue.js @@ -1,6 +1,14 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); +var Utils = require('br/test/Utils'); /** + * @name br.test.viewhandler.TypedValue * @class * TypedValue ViewFixtureHandler can be used to simulate typing a value into an input view element. * Example usage: @@ -10,45 +18,42 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.TypedValue = function() -{ +function TypedValue() { +} +br.implement(TypedValue, ViewFixtureHandler); + +TypedValue.prototype.get = function(eElement) { + throw new Errors.InvalidTestError("The 'typedValue' property can't be used in a Then clause, try using 'value'."); }; -br.Core.implement(br.test.viewhandler.TypedValue, br.test.viewhandler.ViewFixtureHandler); +TypedValue.prototype.set = function(eElement, sValue) { + if (eElement.value === undefined) + { + throw new Errors.InvalidTestError("The element you tried to use 'typedValue' on doesn't have a value field to simulate typing on."); + } -br.test.viewhandler.TypedValue.prototype.get = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The 'typedValue' property can't be used in a Then clause, try using 'value'."); -}; + //Check whether the last active element wants us to fire a change event. + if (document.activeElement && document.activeElement.bFireChangeEventWhenNextElementIsActivated) + { + delete document.activeElement.bFireChangeEventWhenNextElementIsActivated; + Utils.fireDomEvent(document.activeElement, 'change'); + } + + eElement.focus(); + jQuery(eElement).trigger('focusin'); + + for (var i = 0, max = sValue.length; i < max; ++i) + { + var sKey = sValue.charAt(i); + + Utils.fireKeyEvent(eElement, "keydown", sKey); + eElement.value += sKey; + Utils.fireKeyEvent(eElement, "keypress", sKey); + Utils.fireKeyEvent(eElement, "keyup", sKey); + } -br.test.viewhandler.TypedValue.prototype.set = function(eElement, sValue) -{ - if (eElement.value === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The element you tried to use 'typedValue' on doesn't have a value field to simulate typing on."); - } - - //Check whether the last active element wants us to fire a change event. - if(document.activeElement && document.activeElement.bFireChangeEventWhenNextElementIsActivated) - { - delete document.activeElement.bFireChangeEventWhenNextElementIsActivated; - br.test.Utils.fireDomEvent(document.activeElement, 'change'); - } - - eElement.focus(); - jQuery(eElement).trigger('focusin'); - - for (var i = 0, max = sValue.length; i < max; ++i) - { - var sKey = sValue.charAt(i); - - br.test.Utils.fireKeyEvent(eElement, "keydown", sKey); - eElement.value += sKey; - br.test.Utils.fireKeyEvent(eElement, "keypress", sKey); - br.test.Utils.fireKeyEvent(eElement, "keyup", sKey); - } - - //Request the next active element to fire a change event - eElement.bFireChangeEventWhenNextElementIsActivated = true; + //Request the next active element to fire a change event + eElement.bFireChangeEventWhenNextElementIsActivated = true; }; +module.exports = TypedValue; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Value.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Value.js index 2ed45c88a..66ec38bf6 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Value.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Value.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Value * @class * Value ViewFixtureHandler can be used to set or get value property of a view element. * Example usage: @@ -10,29 +17,25 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Value = function() -{ -}; +function Value() { +} +br.implement(Value, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Value, br.test.viewhandler.ViewFixtureHandler); - -br.test.viewhandler.Value.prototype.get = function(eElement) -{ - if (eElement.value === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The element you tried to use the 'value' property on doesn't have one."); +Value.prototype.get = function(eElement) { + if (eElement.value === undefined) { + throw new Errors.InvalidTestError("The element you tried to use the 'value' property on doesn't have one."); } - elementValue = jQuery(eElement).val(); + var elementValue = jQuery(eElement).val(); return elementValue; }; -br.test.viewhandler.Value.prototype.set = function(eElement, vValue) -{ - if (eElement.value === undefined) - { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The element you tried to use the 'value' property on doesn't have one."); +Value.prototype.set = function(eElement, vValue) { + if (eElement.value === undefined) { + throw new Errors.InvalidTestError("The element you tried to use the 'value' property on doesn't have one."); } try { delete eElement.fireOnChange; } catch (e) { } jQuery(eElement).val(vValue).change(); }; + +module.exports = Value; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ViewFixtureHandler.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ViewFixtureHandler.js index 7b9ca42f4..00beb3eda 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ViewFixtureHandler.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/ViewFixtureHandler.js @@ -1,5 +1,9 @@ +'use strict'; + +var Errors = require('br/Errors'); + /** - * + * @name br.test.viewhandler.ViewFixtureHandler * @class *

Classes implementing ViewFixtureHandler interface are used by ViewFixture to interact * with the elements in the rendered view.

@@ -7,18 +11,16 @@ * @constructor * @interface */ -br.test.viewhandler.ViewFixtureHandler = function() -{ -}; +function ViewFixtureHandler() { +} /** * Updates eElement in a particular way, for example by setting a vValue on one of its properties. * @param {DOMElement} eElement DOM element * @param {Variant} vValue value to be set on eElement */ -br.test.viewhandler.ViewFixtureHandler.prototype.set = function(eElement, vValue) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "This method has not yet been implemented"); +ViewFixtureHandler.prototype.set = function(eElement, vValue) { + throw new Errors.UnimplementedInterfaceError("This method has not yet been implemented"); }; /** @@ -26,7 +28,8 @@ br.test.viewhandler.ViewFixtureHandler.prototype.set = function(eElement, vValue * @param {DOMElement} eElement DOM element * @param {Variant} vValue value to be used when inspecting the element */ -br.test.viewhandler.ViewFixtureHandler.prototype.get = function(eElement, vValue) -{ - throw new br.Errors.CustomError(br.Errors.UNIMPLEMENTED_INTERFACE, "This method has not yet been implemented"); +ViewFixtureHandler.prototype.get = function(eElement, vValue) { + throw new Errors.UnimplementedInterfaceError("This method has not yet been implemented"); }; + +module.exports = ViewFixtureHandler; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Width.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Width.js index 0985a265c..da20cfe73 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Width.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/src/br/test/viewhandler/Width.js @@ -1,6 +1,13 @@ -br.Core.thirdparty("jquery"); +'use strict'; + +require('jquery'); + +var br = require('br/Core'); +var Errors = require('br/Errors'); +var ViewFixtureHandler = require('br/test/viewhandler/ViewFixtureHandler'); /** + * @name br.test.viewhandler.Width * @class * Width ViewFixtureHandler can be used to get width of a view element. * Example usage: @@ -10,19 +17,16 @@ br.Core.thirdparty("jquery"); * @constructor * @implements br.test.viewhandler.ViewFixtureHandler */ -br.test.viewhandler.Width = function() -{ -}; +function Width() { +} +br.implement(Width, ViewFixtureHandler); -br.Core.implement(br.test.viewhandler.Width, br.test.viewhandler.ViewFixtureHandler); - - -br.test.viewhandler.Width.prototype.set = function(eElement) -{ - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "The width attribute for a element cannot be set directly and should be set via the viewModel."); +Width.prototype.set = function(eElement) { + throw new Errors.InvalidTestError("The width attribute for a element cannot be set directly and should be set via the viewModel."); }; -br.test.viewhandler.Width.prototype.get = function(eElement) -{ +Width.prototype.get = function(eElement) { return jQuery(eElement).width(); }; + +module.exports = Width; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/.js-style b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/.js-style similarity index 100% rename from brjs-sdk/workspace/sdk/libs/javascript/br-test/.js-style rename to brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/.js-style diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/TestLoadedDummyFixture.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/TestLoadedDummyFixture.js index 8b31f5da1..f6c6bda3a 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/TestLoadedDummyFixture.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/TestLoadedDummyFixture.js @@ -1,10 +1,12 @@ - +var br = require('br/Core'); +var Errors = require('br/Errors'); +var Fixture = require('br/test/Fixture'); TestLoadedDummyFixture = function() { }; -br.Core.inherit(TestLoadedDummyFixture, br.test.Fixture); +br.inherit(TestLoadedDummyFixture, Fixture); TestLoadedDummyFixture.prototype.canHandleProperty = function() @@ -24,7 +26,7 @@ TestLoadedDummyFixture.prototype.doGiven = function(sProperty, vValue) TestLoadedDummyFixture.prototype.doWhen = function(sProperty, vValue) { - throw new br.Errors.CustomError(br.Errors.INVALID_TEST, "TestLoadedDummyFixture can't be used in a When."); + throw new Errors.InvalidTestError("TestLoadedDummyFixture can't be used in a When."); }; TestLoadedDummyFixture.prototype.doThen = function(sProperty, vValue) { diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/ViewFixtureTestsFixtureFactory.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/ViewFixtureTestsFixtureFactory.js index 65dfa3f77..5f8763173 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/ViewFixtureTestsFixtureFactory.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/ViewFixtureTestsFixtureFactory.js @@ -1,8 +1,11 @@ +var br = require('br/Core'); +var FixtureFactory = require('br/test/FixtureFactory'); + ViewFixtureTestsFixtureFactory = function() { }; -br.Core.implement(ViewFixtureTestsFixtureFactory, br.test.FixtureFactory); +br.implement(ViewFixtureTestsFixtureFactory, FixtureFactory); ViewFixtureTestsFixtureFactory.prototype.addFixtures = function(oFixtureRegistry) { diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/event-logging.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/event-logging.js index 05adf23fc..980294397 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/event-logging.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/event-logging.js @@ -1,4 +1,4 @@ -br.Core.thirdparty("jquery"); +require("jquery"); eventsLog = []; logEvent = function(e) { diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/test-utils.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/test-utils.js index be1344e6d..b072d14bf 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/test-utils.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/test-utils.js @@ -1,5 +1,4 @@ -br.Core.thirdparty("jquery"); -br.Core.thirdparty('sl4bdummy'); +require("jquery"); var testHtml = null; setupPage = function() { diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/click-events.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/click-events.js index 303f47439..1e6337bf6 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/click-events.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/click-events.js @@ -1,4 +1,6 @@ -br.test.GwtTestRunner.initialize(); +var GwtTestRunner = require('br/test/GwtTestRunner'); + +GwtTestRunner.initialize(); describe("User performs click events", function() { fixtures("ViewFixtureTestsFixtureFactory"); diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/text-events.js b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/text-events.js index 21c514ca0..5d40bf28f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/text-events.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-test/tests/test-acceptance/js-test-driver/tests/view-fixture-tests/text-events.js @@ -1,4 +1,6 @@ -br.test.GwtTestRunner.initialize(); +var GwtTestRunner = require('br/test/GwtTestRunner'); + +GwtTestRunner.initialize(); describe("User performs text events", function() { fixtures("ViewFixtureTestsFixtureFactory"); diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/BlurredTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/BlurredTest.js index aaef88915..57d455639 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/BlurredTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/BlurredTest.js @@ -1,10 +1,12 @@ BlurredTest = TestCase("BlurredTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); BlurredTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -65,10 +67,10 @@ BlurredTest.prototype.test_cannotGetBlurredOnNonFocusableElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(form).blurred", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doThen("view.(div p).blurred", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; BlurredTest.prototype.test_cannotSetBlurredOnNonFocusableElements = function() @@ -76,10 +78,10 @@ BlurredTest.prototype.test_cannotSetBlurredOnNonFocusableElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(form).blurred", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(div p).blurred", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; BlurredTest.prototype.test_cannotSetBlurredOnDisabledElements = function() @@ -87,5 +89,5 @@ BlurredTest.prototype.test_cannotSetBlurredOnDisabledElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(#the-form select[disabled]).blurred", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/CheckedTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/CheckedTest.js index b5f0b567e..d85c2f5c7 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/CheckedTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/CheckedTest.js @@ -1,10 +1,11 @@ CheckedTest = TestCase("CheckedTest"); -require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); CheckedTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -73,44 +74,44 @@ CheckedTest.prototype.test_cannotGetCheckedStatusOfUncheckableElement = function var _self = this; assertException(function () { _self.m_oViewFixture.doThen("view.(.uncheckable).checked", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; CheckedTest.prototype.test_cannotSetCheckedStatusOfUncheckableElement = function() { var _self = this; assertException(function () { _self.m_oViewFixture.doWhen("view.(.uncheckable).checked", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function () { _self.m_oViewFixture.doWhen("view.(.uncheckable).checked", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; CheckedTest.prototype.test_cannotSetCheckedStatusToNonBooleanValue = function() { var _self = this; assertException("1a", function () { _self.m_oViewFixture.doWhen("view.(input#hobby1).checked", 1); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("1b", function () { _self.m_oViewFixture.doWhen("view.(input#hobby1).checked", 0); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("1c", function () { _self.m_oViewFixture.doWhen("view.(input#hobby2).checked", "false"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("1d", function () { _self.m_oViewFixture.doWhen("view.(input#hobby2).checked", "on"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("2a", function () { _self.m_oViewFixture.doWhen("view.(input#gender-m).checked", 1); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("2b", function () { _self.m_oViewFixture.doWhen("view.(input#gender-m).checked", "true"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("2c", function () { _self.m_oViewFixture.doWhen("view.(input#gender-f).checked", 0); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException("2d", function () { _self.m_oViewFixture.doWhen("view.(input#gender-f).checked", "off"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ChildrenCountTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ChildrenCountTest.js index ae8a1316c..24f7f03f5 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ChildrenCountTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ChildrenCountTest.js @@ -1,10 +1,11 @@ ChildrenCountTest = TestCase("ChildrenCountTest"); -require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); ChildrenCountTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -50,11 +51,11 @@ ChildrenCountTest.prototype.test_cannotSetChildCountForElement = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(form).childrenCount", 0); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(div#main).childrenCount", 100); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(div.level2:first).childrenCount", 42); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClassNameTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClassNameTest.js index 0efdba7e7..450ae9e05 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClassNameTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClassNameTest.js @@ -2,9 +2,11 @@ ClassNameTest = TestCase("ClassNameTest"); require('br/test/ViewFixture'); +var ViewFixture = require('br/test/ViewFixture'); + ClassNameTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClickedTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClickedTest.js index d327c41dd..3804bac00 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClickedTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ClickedTest.js @@ -1,12 +1,13 @@ -br.Core.thirdparty("jquery"); +require("jquery"); -require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); ClickedTest = TestCase("ClickedTest"); ClickedTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -42,5 +43,5 @@ ClickedTest.prototype.test_cannotGetClickedProperty= function() var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(#click-target).clicked", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/DoesNotHaveClassTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/DoesNotHaveClassTest.js index ae93e63c9..6077e76eb 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/DoesNotHaveClassTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/DoesNotHaveClassTest.js @@ -2,10 +2,12 @@ require("jsunitextensions"); DoesNotHaveClassTest = TestCase("DoesNotHaveClassTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); DoesNotHaveClassTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; @@ -50,5 +52,5 @@ DoesNotHaveClassTest.prototype.test_cannotSetDoesNotHaveClass = function() var self = this; assertException(function() { self.m_oViewFixture.doWhen("view.(#single-div).doesNotHaveClass", "one"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/EnabledTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/EnabledTest.js index 63e953761..c8f36891f 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/EnabledTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/EnabledTest.js @@ -1,10 +1,11 @@ EnabledTest = TestCase("EnabledTest"); require('br/test/ViewFixture'); +var ViewFixture = require('br/test/ViewFixture'); EnabledTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/FocusedTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/FocusedTest.js index 13f733685..ee9d76eb8 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/FocusedTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/FocusedTest.js @@ -1,10 +1,12 @@ FocusedTest = TestCase("FocusedTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); FocusedTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -65,10 +67,10 @@ FocusedTest.prototype.test_cannotGetFocusedOnNonFocusableElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(form).focused", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doThen("view.(div p).focused", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; FocusedTest.prototype.test_cannotSetFocusedOnNonFocusableElements = function() @@ -76,10 +78,10 @@ FocusedTest.prototype.test_cannotSetFocusedOnNonFocusableElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(form).focused", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(div p).focused", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; FocusedTest.prototype.test_cannotSetFocusedOnDisabledElements = function() @@ -87,5 +89,5 @@ FocusedTest.prototype.test_cannotSetFocusedOnDisabledElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(#the-form select[disabled]).focused", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/HasClassTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/HasClassTest.js index 11a3da76e..5e8e74642 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/HasClassTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/HasClassTest.js @@ -1,11 +1,12 @@ -br.Core.thirdparty('jsunitextensions'); +require('jsunitextensions'); HasClassTest = TestCase("HasClassTest"); -require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); HasClassTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; @@ -44,5 +45,5 @@ HasClassTest.prototype.test_cannotSetHasClass = function() var self = this; assertException(function() { self.m_oViewFixture.doWhen("view.(#single-div).hasClass", "never-applied-class"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/IsVisibleTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/IsVisibleTest.js index 3c6e90b9d..18f33279c 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/IsVisibleTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/IsVisibleTest.js @@ -1,10 +1,12 @@ IsVisibleTest = TestCase("IsVisibleTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); IsVisibleTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -75,7 +77,7 @@ IsVisibleTest.prototype.test_cannotSetIsVisibleProperty = function() var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(div#hidden-div).isVisible", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); this.m_oViewFixture.doThen("view.(div#hidden-div).isVisible", false); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/OptionsTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/OptionsTest.js index 013e14291..1d0bc074c 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/OptionsTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/OptionsTest.js @@ -1,10 +1,12 @@ OptionsTest = TestCase("OptionsTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); OptionsTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; @@ -75,10 +77,10 @@ OptionsTest.prototype.test_tryingToUseOptionsOnNonSelectElementThrowsException = var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(input:first).options", ["some", "thing"]); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(div.not-a-form).options", []); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; OptionsTest.prototype.test_canEmptyASelectElementWithAnEmptyArray = function() @@ -114,13 +116,13 @@ OptionsTest.prototype.test_tryingToSetOptionsWithNonArrayValueThrowsException = var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(#filled-select).options", "naughty value"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(#filled-select).options", 43); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(#filled-select).options", null); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); this.m_oViewFixture.doThen("view.(#filled-select).options", ["AB34", "CD78"]); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/SelectedTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/SelectedTest.js index b9cdaaae1..989796f22 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/SelectedTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/SelectedTest.js @@ -1,10 +1,12 @@ SelectedTest = TestCase("SelectedTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); SelectedTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -72,8 +74,8 @@ SelectedTest.prototype.test_cannotUseSelectedOnNonOptionElements = function() var _self = this; assertException(function(){ _self.m_oViewFixture.doThen("view.(input#gender-m).selected", false); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function(){ _self.m_oViewFixture.doWhen("view.(div.not-a-form).selected", true); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TextTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TextTest.js index 8b1e1aa4d..16ec5e644 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TextTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TextTest.js @@ -1,10 +1,12 @@ TextTest = TestCase("TextTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); TextTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_eElement = this.getElement(); document.body.appendChild(this.m_eElement); this.m_oViewFixture.setViewElement(this.m_eElement); @@ -74,5 +76,5 @@ TextTest.prototype.test_cannotUseTextOnInputElements = function() var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(input:first).text", "blah"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TypedValueTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TypedValueTest.js index 7c1e6224d..e735651d2 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TypedValueTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/TypedValueTest.js @@ -1,10 +1,12 @@ TypedValueTest = TestCase("TypedValueTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); TypedValueTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; @@ -57,10 +59,10 @@ TypedValueTest.prototype.test_cannotGetTypedValue = function() var _self = this; assertException(function() { _self.m_oViewFixture.doThen("view.(input#partial-text).typedValue", "some t"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doThen("view.(textarea#textArea).typedValue", "Hello, "); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; TypedValueTest.prototype.test_usingTypedValueOnNonInputElementsThrowsException = function() @@ -68,10 +70,10 @@ TypedValueTest.prototype.test_usingTypedValueOnNonInputElementsThrowsException = var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(form).typedValue", "type"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(.no-value).typedValue", "text"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); }; TypedValueTest.prototype.test_canTypeEnterIntoATextBox = function() diff --git a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ValueTest.js b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ValueTest.js index d94e2be4b..b4163d313 100644 --- a/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ValueTest.js +++ b/brjs-sdk/workspace/sdk/libs/javascript/br-viewhandler-tests_NODIST/tests/test-unit/js-test-driver/tests/br/test/ValueTest.js @@ -1,10 +1,12 @@ ValueTest = TestCase("ValueTest"); require('br/test/ViewFixture'); +var Errors = require('br/Errors'); +var ViewFixture = require('br/test/ViewFixture'); ValueTest.prototype.setUp = function() { - this.m_oViewFixture = new br.test.ViewFixture("view.*"); + this.m_oViewFixture = new ViewFixture("view.*"); this.m_oViewFixture.setViewElement(this.getElement()); }; @@ -78,8 +80,8 @@ ValueTest.prototype.test_usingValueOnNonInputElementsThrowsException = function( var _self = this; assertException(function() { _self.m_oViewFixture.doWhen("view.(form).value", "text"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); assertException(function() { _self.m_oViewFixture.doWhen("view.(.no-value).value", "text"); - }, br.Errors.INVALID_TEST); + }, Errors.INVALID_TEST); };