/*______________ | ______ | U I Z E J A V A S C R I P T F R A M E W O R K | / / | --------------------------------------------------- | / O / | MODULE : Uize.Test.ParserTest Class | / / / | | / / / /| | ONLINE : http://uize.com | /____/ /__/_| | COPYRIGHT : (c)2014 UIZE | /___ | LICENSE : Available under MIT License or GNU General Public License |_______________| http://uize.com/license.html */ /* Module Meta Data type: Test importance: 1 codeCompleteness: 100 docCompleteness: 5 */ /*? Introduction The =Uize.Test.ParserTest= module defines a base class for parser test classes. *DEVELOPERS:* `Chris van Rensburg` */ Uize.module ({ name:'Uize.Test.ParserTest', superclass:'Uize.Test', builder:function (_superclass) { 'use strict'; return _superclass.subclass ({ staticMethods:{ parserTest:function (_title,_arguments,_expectedInstanceState) { return { title:_title, test:function () { var m = this, _parser = new (Uize.getModuleByName (m.Class.parserClass)), _result = true ; function _expectObjectProperties (_expectedProperties,_actualProperties) { for (var _property in _expectedProperties) { var _expectedProperty = _expectedProperties [_property], _actualProperty = _actualProperties [_property] ; if (Uize.isPlainObject (_expectedProperty)) { _expectObjectProperties (_expectedProperty,_actualProperty); } else { _result = m.expect (_expectedProperty,_actualProperty); } if (!_result) break; } } _parser.parse.apply (_parser,_arguments); _expectObjectProperties (_expectedInstanceState,_parser); return _result; } }; }, serializerTest:function (_title,_instanceState,_expected) { return { title:_title, test:function () { var _parser = new (Uize.getModuleByName (this.Class.parserClass)); Uize.mergeInto (_parser,_instanceState); return this.expect (_expected,_parser.serialize ()); } }; } }, staticProperties:{ parserClass:null // this should be overridden by subclasses } }); } });