How to use requireOptions method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

CommonJsImportsParserPlugin.js

Source:CommonJsImportsParserPlugin.js Github

copy

Full Screen

1/*2 MIT License http://www.opensource.org/licenses/mit-license.php3 Author Tobias Koppers @sokra4*/5"use strict";6const CommentCompilationWarning = require("../CommentCompilationWarning");7const RuntimeGlobals = require("../RuntimeGlobals");8const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");9const {10 evaluateToIdentifier,11 evaluateToString,12 expressionIsUnsupported,13 toConstantDependency14} = require("../javascript/JavascriptParserHelpers");15const CommonJsFullRequireDependency = require("./CommonJsFullRequireDependency");16const CommonJsRequireContextDependency = require("./CommonJsRequireContextDependency");17const CommonJsRequireDependency = require("./CommonJsRequireDependency");18const ConstDependency = require("./ConstDependency");19const ContextDependencyHelpers = require("./ContextDependencyHelpers");20const LocalModuleDependency = require("./LocalModuleDependency");21const { getLocalModule } = require("./LocalModulesHelpers");22const RequireHeaderDependency = require("./RequireHeaderDependency");23const RequireResolveContextDependency = require("./RequireResolveContextDependency");24const RequireResolveDependency = require("./RequireResolveDependency");25const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");26/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */27class CommonJsImportsParserPlugin {28 /**29 * @param {JavascriptParserOptions} options parser options30 */31 constructor(options) {32 this.options = options;33 }34 apply(parser) {35 const options = this.options;36 // metadata //37 const tapRequireExpression = (expression, getMembers) => {38 parser.hooks.typeof39 .for(expression)40 .tap(41 "CommonJsPlugin",42 toConstantDependency(parser, JSON.stringify("function"))43 );44 parser.hooks.evaluateTypeof45 .for(expression)46 .tap("CommonJsPlugin", evaluateToString("function"));47 parser.hooks.evaluateIdentifier48 .for(expression)49 .tap(50 "CommonJsPlugin",51 evaluateToIdentifier(expression, "require", getMembers, true)52 );53 };54 tapRequireExpression("require", () => []);55 tapRequireExpression("require.resolve", () => ["resolve"]);56 tapRequireExpression("require.resolveWeak", () => ["resolveWeak"]);57 // Weird stuff //58 parser.hooks.assign.for("require").tap("CommonJsPlugin", expr => {59 // to not leak to global "require", we need to define a local require here.60 const dep = new ConstDependency("var require;", 0);61 dep.loc = expr.loc;62 parser.state.module.addPresentationalDependency(dep);63 return true;64 });65 // Unsupported //66 parser.hooks.expression67 .for("require.main.require")68 .tap(69 "CommonJsPlugin",70 expressionIsUnsupported(71 parser,72 "require.main.require is not supported by webpack."73 )74 );75 parser.hooks.call76 .for("require.main.require")77 .tap(78 "CommonJsPlugin",79 expressionIsUnsupported(80 parser,81 "require.main.require is not supported by webpack."82 )83 );84 parser.hooks.expression85 .for("module.parent.require")86 .tap(87 "CommonJsPlugin",88 expressionIsUnsupported(89 parser,90 "module.parent.require is not supported by webpack."91 )92 );93 parser.hooks.call94 .for("module.parent.require")95 .tap(96 "CommonJsPlugin",97 expressionIsUnsupported(98 parser,99 "module.parent.require is not supported by webpack."100 )101 );102 // renaming //103 parser.hooks.canRename.for("require").tap("CommonJsPlugin", () => true);104 parser.hooks.rename.for("require").tap("CommonJsPlugin", expr => {105 // To avoid "not defined" error, replace the value with undefined106 const dep = new ConstDependency("undefined", expr.range);107 dep.loc = expr.loc;108 parser.state.module.addPresentationalDependency(dep);109 return false;110 });111 // inspection //112 parser.hooks.expression113 .for("require.cache")114 .tap(115 "CommonJsImportsParserPlugin",116 toConstantDependency(parser, RuntimeGlobals.moduleCache, [117 RuntimeGlobals.moduleCache,118 RuntimeGlobals.moduleId,119 RuntimeGlobals.moduleLoaded120 ])121 );122 // require as expression //123 parser.hooks.expression124 .for("require")125 .tap("CommonJsImportsParserPlugin", expr => {126 const dep = new CommonJsRequireContextDependency(127 {128 request: options.unknownContextRequest,129 recursive: options.unknownContextRecursive,130 regExp: options.unknownContextRegExp,131 mode: "sync"132 },133 expr.range134 );135 dep.critical =136 options.unknownContextCritical &&137 "require function is used in a way in which dependencies cannot be statically extracted";138 dep.loc = expr.loc;139 dep.optional = !!parser.scope.inTry;140 parser.state.current.addDependency(dep);141 return true;142 });143 // require //144 const processRequireItem = (expr, param) => {145 if (param.isString()) {146 const dep = new CommonJsRequireDependency(param.string, param.range);147 dep.loc = expr.loc;148 dep.optional = !!parser.scope.inTry;149 parser.state.current.addDependency(dep);150 return true;151 }152 };153 const processRequireContext = (expr, param) => {154 const dep = ContextDependencyHelpers.create(155 CommonJsRequireContextDependency,156 expr.range,157 param,158 expr,159 options,160 {161 category: "commonjs"162 },163 parser164 );165 if (!dep) return;166 dep.loc = expr.loc;167 dep.optional = !!parser.scope.inTry;168 parser.state.current.addDependency(dep);169 return true;170 };171 const createRequireHandler = callNew => expr => {172 if (options.commonjsMagicComments) {173 const {174 options: requireOptions,175 errors: commentErrors176 } = parser.parseCommentOptions(expr.range);177 if (commentErrors) {178 for (const e of commentErrors) {179 const { comment } = e;180 parser.state.module.addWarning(181 new CommentCompilationWarning(182 `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,183 comment.loc184 )185 );186 }187 }188 if (requireOptions) {189 if (requireOptions.webpackIgnore !== undefined) {190 if (typeof requireOptions.webpackIgnore !== "boolean") {191 parser.state.module.addWarning(192 new UnsupportedFeatureWarning(193 `\`webpackIgnore\` expected a boolean, but received: ${requireOptions.webpackIgnore}.`,194 expr.loc195 )196 );197 } else {198 // Do not instrument `require()` if `webpackIgnore` is `true`199 if (requireOptions.webpackIgnore) {200 return true;201 }202 }203 }204 }205 }206 if (expr.arguments.length !== 1) return;207 let localModule;208 const param = parser.evaluateExpression(expr.arguments[0]);209 if (param.isConditional()) {210 let isExpression = false;211 for (const p of param.options) {212 const result = processRequireItem(expr, p);213 if (result === undefined) {214 isExpression = true;215 }216 }217 if (!isExpression) {218 const dep = new RequireHeaderDependency(expr.callee.range);219 dep.loc = expr.loc;220 parser.state.module.addPresentationalDependency(dep);221 return true;222 }223 }224 if (225 param.isString() &&226 (localModule = getLocalModule(parser.state, param.string))227 ) {228 localModule.flagUsed();229 const dep = new LocalModuleDependency(localModule, expr.range, callNew);230 dep.loc = expr.loc;231 parser.state.module.addPresentationalDependency(dep);232 return true;233 } else {234 const result = processRequireItem(expr, param);235 if (result === undefined) {236 processRequireContext(expr, param);237 } else {238 const dep = new RequireHeaderDependency(expr.callee.range);239 dep.loc = expr.loc;240 parser.state.module.addPresentationalDependency(dep);241 }242 return true;243 }244 };245 parser.hooks.call246 .for("require")247 .tap("CommonJsImportsParserPlugin", createRequireHandler(false));248 parser.hooks.new249 .for("require")250 .tap("CommonJsImportsParserPlugin", createRequireHandler(true));251 parser.hooks.call252 .for("module.require")253 .tap("CommonJsImportsParserPlugin", createRequireHandler(false));254 parser.hooks.new255 .for("module.require")256 .tap("CommonJsImportsParserPlugin", createRequireHandler(true));257 // require with property access //258 const chainHandler = (expr, calleeMembers, callExpr, members) => {259 if (callExpr.arguments.length !== 1) return;260 const param = parser.evaluateExpression(callExpr.arguments[0]);261 if (param.isString() && !getLocalModule(parser.state, param.string)) {262 const dep = new CommonJsFullRequireDependency(263 param.string,264 expr.range,265 members266 );267 dep.asiSafe = !parser.isAsiPosition(expr.range[0]);268 dep.optional = !!parser.scope.inTry;269 dep.loc = expr.loc;270 parser.state.module.addDependency(dep);271 return true;272 }273 };274 const callChainHandler = (expr, calleeMembers, callExpr, members) => {275 if (callExpr.arguments.length !== 1) return;276 const param = parser.evaluateExpression(callExpr.arguments[0]);277 if (param.isString() && !getLocalModule(parser.state, param.string)) {278 const dep = new CommonJsFullRequireDependency(279 param.string,280 expr.callee.range,281 members282 );283 dep.call = true;284 dep.asiSafe = !parser.isAsiPosition(expr.range[0]);285 dep.optional = !!parser.scope.inTry;286 dep.loc = expr.callee.loc;287 parser.state.module.addDependency(dep);288 parser.walkExpressions(expr.arguments);289 return true;290 }291 };292 parser.hooks.memberChainOfCallMemberChain293 .for("require")294 .tap("CommonJsImportsParserPlugin", chainHandler);295 parser.hooks.memberChainOfCallMemberChain296 .for("module.require")297 .tap("CommonJsImportsParserPlugin", chainHandler);298 parser.hooks.callMemberChainOfCallMemberChain299 .for("require")300 .tap("CommonJsImportsParserPlugin", callChainHandler);301 parser.hooks.callMemberChainOfCallMemberChain302 .for("module.require")303 .tap("CommonJsImportsParserPlugin", callChainHandler);304 // require.resolve //305 const processResolve = (expr, weak) => {306 if (expr.arguments.length !== 1) return;307 const param = parser.evaluateExpression(expr.arguments[0]);308 if (param.isConditional()) {309 for (const option of param.options) {310 const result = processResolveItem(expr, option, weak);311 if (result === undefined) {312 processResolveContext(expr, option, weak);313 }314 }315 const dep = new RequireResolveHeaderDependency(expr.callee.range);316 dep.loc = expr.loc;317 parser.state.module.addPresentationalDependency(dep);318 return true;319 } else {320 const result = processResolveItem(expr, param, weak);321 if (result === undefined) {322 processResolveContext(expr, param, weak);323 }324 const dep = new RequireResolveHeaderDependency(expr.callee.range);325 dep.loc = expr.loc;326 parser.state.module.addPresentationalDependency(dep);327 return true;328 }329 };330 const processResolveItem = (expr, param, weak) => {331 if (param.isString()) {332 const dep = new RequireResolveDependency(param.string, param.range);333 dep.loc = expr.loc;334 dep.optional = !!parser.scope.inTry;335 dep.weak = weak;336 parser.state.current.addDependency(dep);337 return true;338 }339 };340 const processResolveContext = (expr, param, weak) => {341 const dep = ContextDependencyHelpers.create(342 RequireResolveContextDependency,343 param.range,344 param,345 expr,346 options,347 {348 category: "commonjs",349 mode: weak ? "weak" : "sync"350 },351 parser352 );353 if (!dep) return;354 dep.loc = expr.loc;355 dep.optional = !!parser.scope.inTry;356 parser.state.current.addDependency(dep);357 return true;358 };359 parser.hooks.call360 .for("require.resolve")361 .tap("RequireResolveDependencyParserPlugin", expr => {362 return processResolve(expr, false);363 });364 parser.hooks.call365 .for("require.resolveWeak")366 .tap("RequireResolveDependencyParserPlugin", expr => {367 return processResolve(expr, true);368 });369 }370}...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1'use strict';2var defineModule = require('../');3var gutil = require('gulp-util');4var path = require('path');5var fs = require('fs');6require('mocha');7require('should');8var fixtureFile = function(filePath) {9 var fixturesDir = path.join('test', 'fixtures');10 var fixturePath = path.join(fixturesDir, filePath);11 var file = new gutil.File({12 path: fixturePath,13 cwd: fixturesDir,14 base: path.dirname(fixturePath),15 contents: fs.readFileSync(fixturePath)16 });17 return file;18};19var streamThroughDefineModule = function(type, options, filePath, cb) {20 var stream = defineModule(type, options);21 var file = fixtureFile(filePath);22 cb(stream);23 stream.write(file);24 stream.end();25};26var fileShouldMatchExpected = function(file, filePath) {27 var expectedDir = path.join('test', 'expected');28 var expectedPath = path.join(expectedDir, filePath);29 if (fs.existsSync(expectedPath + '.regex')) {30 var regex = new RegExp(fs.readFileSync(expectedPath + '.regex').toString());31 var match = file.contents.toString().match(regex);32 match.should.exist;33 if (typeof arguments[2] === 'function') {34 arguments[2](match);35 }36 }37 else {38 file.contents.toString().should.equal(fs.readFileSync(expectedPath).toString());39 }40};41describe('gulp-define-module', function() {42 describe('defineModule()', function() {43 var basic = function(type, options, variant) {44 return function(done) {45 streamThroughDefineModule(type, options, 'basic.js', function(stream) {46 stream.on('data', function(file) {47 var expectedName = 'basic_' + type;48 if (variant) { expectedName += '_' + variant; }49 fileShouldMatchExpected(file, expectedName + '.js');50 done();51 });52 });53 };54 };55 it('makes AMD modules', basic('amd'));56 it('makes CommonJS modules', basic('commonjs'));57 it('makes Node modules', basic('node'));58 it('makes Hybrid modules', basic('hybrid'));59 it('makes plain modules', basic('plain'));60 it('throws when the the type is unsupported', function() {61 basic('invalid').should.throw(); // throws before it becomes async62 });63 var requireOptions = { require: { Library: 'library' } };64 it('handles require for AMD', basic('amd', requireOptions, 'require'));65 it('handles require for Node', basic('node', requireOptions, 'require'));66 it('handles require for CommonJS', basic('commonjs', requireOptions, 'require'));67 it('handles require for Hybrid', basic('hybrid', requireOptions, 'require'));68 it('ignores require for plain', basic('plain', requireOptions));69 it('accepts wrapper option',70 basic('plain', { wrapper: 'App.TEMPLATES = TemplateWrapper(<%= contents %>)' }, 'wrapped'));71 it('accepts options.context as a string',72 basic('plain', {73 context: { customContents: '<%= contents %>' },74 wrapper: '<%= customContents %>'75 }));76 it('allows name to be overridden',77 // this isn't a recommended use of name. instead, the user should define78 // a wrapper, but it significantly simplifies the test setup.79 basic('plain', {80 context: { name: 'App["<%= name %>"] =' }81 }));82 it('accepts options.context as a function',83 basic('plain', {84 context: function(context) {85 return {86 customContents: 'App.TEMPLATES = TemplateWrapper(' + context.contents + ')'87 };88 },89 wrapper: '<%= customContents %>'90 }, 'wrapped'));91 it('accepts options through incoming file', function(done) {92 var stream = defineModule('amd');93 var file = fixtureFile('basic.js');94 file.defineModuleOptions = requireOptions;95 stream.on('data', function(file) {96 fileShouldMatchExpected(file, 'basic_amd_require.js');97 done();98 });99 stream.write(file);100 stream.end();101 });102 it('processes options for AMD both through invocation and incoming file', function(done) {103 // the options should be handled like this:104 // - require from `file.defineModuleOptions` should be used as base values, and the105 // values from `defineModule` should be merged over top of them.106 // - context from `file.defineModuleOptions` should be processed first, then context107 // from `defineModule`.108 // - wrapper from `defineModule` should override that of `file.defineModuleOptions`.109 // - any require from `defineModule` with the value of null should ignore the require110 var stream = defineModule('amd', {111 wrapper: 'Application.Library.TEMPLATES[\'<%= name %>\'] = <%= contents %>',112 context: function(context) {113 return { name: context.prefix + '.' + context.name };114 },115 require: { Application: 'application', Shared: 'shared-application-library', Vendor: null }116 });117 var file = fixtureFile('basic.js');118 file.defineModuleOptions = {119 wrapper: 'Library.TEMPLATES[\'<%= name %>\'] = <%= contents %>',120 context: { prefix: 'prefix' },121 require: { Library: 'library', Shared: 'shared-library', Vendor: 'shared-vendor-library' }122 };123 stream.on('data', function(file) {124 fileShouldMatchExpected(file, 'basic_amd_advanced_options.js', function(match) {125 match[1].split(',').sort().join(',').should.eql('"application","library","shared-application-library"');126 match[2].split(',').sort().join(',').should.eql('Application,Library,Shared');127 });128 done();129 });130 stream.write(file);131 stream.end();132 });133 it('processes options for CommonJS both through invocation and incoming file', function(done) {134 var stream = defineModule('commonjs', {135 wrapper: 'Application.Library.TEMPLATES[\'<%= name %>\'] = <%= contents %>',136 context: function(context) {137 return { name: context.prefix + '.' + context.name };138 },139 require: { Library: 'app-library', Vendor: null }140 });141 var file = fixtureFile('basic.js');142 file.defineModuleOptions = {143 wrapper: 'Library.TEMPLATES[\'<%= name %>\'] = <%= contents %>',144 context: { prefix: 'prefix' },145 require: { Library: 'app-library', Vendor: 'shared-vendor-library' }146 };147 stream.on('data', function(file) {148 fileShouldMatchExpected(file, 'basic_commonjs_advanced.js', function(match) {149 match[1].should.eql('Library');150 match[2].should.eql('app-library');151 done();152 });153 });154 stream.write(file);155 stream.end();156 });157 describe('wrapper context', function() {158 it('defines name', basic('plain', {159 wrapper: 'App["<%= name %>"] = <%= contents %>'160 }, 'context_name'));161 it('defines file', basic('plain', {162 wrapper: 'App["<%= file.path %>"] = <%= contents %>'163 }, 'context_file'));164 it('defines contents', basic('plain', {165 wrapper: '<%= contents %>'166 }));167 it('handles nested paths for name', function(done) {168 var stream = defineModule('plain', {169 wrapper: 'App["<%= name %>"] = <%= contents %>'170 });171 var file = fixtureFile('nested/basic.js');172 stream.on('data', function(file) {173 fileShouldMatchExpected(file, 'basic_plain_context_name.js');174 done();175 });176 stream.write(file);177 stream.end();178 });179 });180 });...

Full Screen

Full Screen

xe.editor.core.js

Source:xe.editor.core.js Github

copy

Full Screen

1(function (exports) {2'use strict';3var editorSet = {};4var editorOptionSet = {};5var InstanceObj = function (editorName, sel, editorOptions, toolInfoList) {6 var _options = {7 editorOptions: editorOptions,8 toolInfoList: toolInfoList,9 };10 this.editorName = editorName;11 this.selector = sel;12 this.props = {};13 this.getOptions = function () {14 return _options;15 };16};17InstanceObj.prototype = {18 getInstance: function () {19 return editorSet[this.editorName].editorList[this.selector];20 },21 getContents: function () {22 return editorSet[this.editorName].interfaces.getContents.call(this.getInstance());23 },24 setContents: function (text) {25 editorSet[this.editorName].interfaces.setContents.call(this.getInstance(), text);26 },27 addContents: function (text) {28 editorSet[this.editorName].interfaces.addContents.call(this.getInstance(), text);29 },30 addProps: function (obj) {31 for (var o in obj) {32 this.getInstance().props[o] = obj[o];33 }34 },35 addTools: function (toolInstanceList) {36 editorSet[this.editorName].interfaces.addTools.call(this.getInstance(), this.getOptions().toolInfoList, toolInstanceList);37 },38 on: function (eventName, callback) {39 editorSet[this.editorName].interfaces.on.call(this.getInstance(), eventName, callback);40 },41 renderFileUploader: function (customOptions) {42 editorSet[this.editorName].interfaces.renderFileUploader.call(this.getInstance(), customOptions);43 },44 reset: function () {45 editorSet[this.editorName].interfaces.reset.call(this.getInstance());46 },47};48var Editor = function (editorSettings, interfaces) {49 this.name = editorSettings.name;50 this.configs = editorSettings.configs;51 this.editorList = [];52 this.interfaces = {};53 if (editorSettings.hasOwnProperty('plugins')54 && editorSettings.plugins instanceof Array55 && editorSettings.plugins.length > 056 && editorSettings.hasOwnProperty('addPlugins')) {57 editorSettings.addPlugins(editorSettings.plugins);58 }59 for (var o in interfaces) {60 this.interfaces[o] = interfaces[o];61 }62};63Editor.prototype = {64 configs: {},65 interfaces: {},66 create: function (sel, options, editorOptions, toolInfoList) {67 var editorOptions = editorOptions || {};68 var toolInfoList = toolInfoList || [];69 var editorOptions = $.extend(this.configs || {}, editorOptions);70 if (Validation.isValidBeforeCreateInstance(sel, toolInfoList, this)) {71 this.editorList[sel] = new InstanceObj(this.name, sel, editorOptions, toolInfoList);72 this.interfaces.initialize.call(this.editorList[sel], sel, options, editorOptions);73 if (!!toolInfoList && toolInfoList.length > 0) {74 var tools = {};75 var toolInfoListFilter = [];76 for (var i = 0, max = toolInfoList.length; i < max; i += 1) {77 if (XEeditor.tools.get(toolInfoList[i].id)) {78 tools[toolInfoList[i].id] = XEeditor.tools.get(toolInfoList[i].id);79 toolInfoListFilter.push(toolInfoList[i]);80 } else {81 console.error('define된 tool이 존재하지 않음. [' + toolInfoList[i].id + ']');82 }83 }84 this.interfaces.addTools.call(this.editorList[sel], tools, toolInfoListFilter);85 }86 // return this.editorList[sel];87 return this.editorList[sel];88 }89 },90};91var Tools = function (obj) {92 for (var o in obj) {93 this[o] = obj[o];94 }95};96var toolsSet = {};97var XEeditor = (function () {98 return {99 define: function (obj) {100 var editorSettings = obj.editorSettings;101 var interfaces = obj.interfaces;102 if (Validation.isValidEditorOptions(editorSettings, interfaces)) {103 editorOptionSet[editorSettings.name] = editorSettings;104 editorSet[editorSettings.name] = new Editor(editorSettings, interfaces);105 }106 },107 getEditor: function (name) {108 return editorSet[name];109 },110 tools: {111 define: function (obj) {112 if (Validation.isValidToolsObject(obj)) {113 toolsSet[obj.id] = new Tools(obj);114 }115 },116 get: function (id) {117 return toolsSet[id];118 },119 },120 attachDomId: function (content, id) {121 return $(content).attr('xe-tool-id', id).clone().wrap('<div/>').parent().html();122 },123 getDomSelector: function (id) {124 return '[xe-tool-id="' + id + '"]';125 },126 };127})();128var Validation = (function () {129 var requireOptions = {130 editorSettings: [131 'name',132 ],133 interfaces: [134 'initialize',135 'getContents', 'setContents', 'addContents',136 ],137 tools: {138 property: [139 'id', 'events',140 ],141 events: [142 'iconClick', 'elementDoubleClick',143 ],144 },145 };146 return {147 isValidBeforeCreateInstance: function (sel, toolIdList, editorParent) {148 if (!sel) {149 console.error('error: 중복 editor id. (' + sel + ')');150 return false;151 }152 if (editorParent.editorList.length > 0) {153 var selValid = true;154 for (var i = 0, max = editorParent.editorList.length; i < max; i += 1) {155 if (editorParent.editorList[i] === sel) {156 selValid = false;157 console.error();158 break;159 }160 }161 if (!selValid) {162 return false;163 }164 }165 return true;166 },167 isValidEditorOptions: function (editorSettings, interfaces) {168 var valid = true;169 for (var eSettings in requireOptions.editorSettings) {170 if (!editorSettings.hasOwnProperty(requireOptions.editorSettings[eSettings])) {171 console.error('구현 필요 [editorSettings.' + requireOptions.editorSettings[eSettings] + ']');172 valid = false;173 }174 }175 for (var eInterface in requireOptions.interfaces) {176 if (!interfaces.hasOwnProperty(requireOptions.interfaces[eInterface])) {177 console.error('구현 필요 [' + requireOptions.interfaces[eInterface] + ']');178 valid = false;179 }180 }181 if (editorSettings.hasOwnProperty('plugins')182 && editorSettings.plugins instanceof Array183 && editorSettings.plugins.length > 0184 && !editorSettings.hasOwnProperty('addPlugins')) {185 console.error('구현 필요 [fn:addPlugins]');186 }187 if (!!editorSet.hasOwnProperty(editorSettings.name)) {188 console.error('등록된 에디터 있음 [' + editorSettings.name + ']');189 valid = false;190 }191 return (!valid) ? false : true;192 },193 isValidToolsObject: function (obj) {194 var valid = true;195 for (var i = 0, max = requireOptions.tools.property.length; i < max; i += 1) {196 if (!obj.hasOwnProperty(requireOptions.tools.property[i])) {197 console.error('구현 필요 [XEeditor.tools.define => fn:' + requireOptions.tools.property[i] + ']');198 valid = false;199 }200 }201 for (var i = 0, max = requireOptions.tools.events.length; i < max; i += 1) {202 if (!obj.events.hasOwnProperty(requireOptions.tools.events[i])) {203 console.error('구현 필요[XEeditor.tools.define => event' + requireOptions.tools.events[i] + ']');204 valid = false;205 }206 }207 return valid;208 },209 };210})();211exports.XEeditor = XEeditor;...

Full Screen

Full Screen

editorValidation.js

Source:editorValidation.js Github

copy

Full Screen

1import { EditorDefineError, EditorToolDefineError, EditorUsedContainer, EditorUndefinedContainer } from './errors/editor.error'2/**3 * @private4 */5const requireOptions = {6 editorSettings: [7 'name'8 ],9 interfaces: [10 'initialize',11 'addContents',12 'getContents',13 'setContents',14 'getContentDom'15 ],16 tools: {17 property: [18 'id',19 'events'20 ],21 events: [22 'iconClick',23 'elementDoubleClick'24 ]25 }26}27/**28 * @class29 */30class EditorValidation {31 /**32 * Editor의 instance를 생성하기 전 중복 검사 등 수행33 * @param {string} sel jQuery selector34 * @param {array} toolIdList35 * @param {object} editorParent36 * @return {boolean}37 * @throws {EditorUndefinedContainer}38 * @throws {EditorUsedContainer}39 */40 static isValidBeforeCreateInstance (sel, toolIdList, editorParent) {41 if (!sel) {42 // selector가 없음43 throw new EditorUndefinedContainer('Editor가 사용할 field를 지정해야 합니다.')44 }45 if (editorParent.editorList.length > 0) {46 let selValid = true47 for (let i = 0, max = editorParent.editorList.length; i < max; i += 1) {48 if (editorParent.editorList[i] === sel) {49 selValid = false50 throw new EditorUsedContainer(`Editor가 이미 사용 중입니다: ${sel}`)51 }52 }53 if (!selValid) {54 return false55 }56 }57 return true58 }59 /**60 * @typedef {Object} editorDefinition61 * @property {object} editorDefinition.editorSettings 에디터 설정 정보62 * @property {string} editorDefinition.editorSettings.name 에디터 설정 정보63 * @property {object} editorDefinition.interfaces 구현된 에디터 인터페이스64 * @property {function} editorDefinition.interfaces.initialize65 * @property {function} editorDefinition.interfaces.addContents66 * @property {function} editorDefinition.interfaces.getContents67 * @property {function} editorDefinition.interfaces.setContents68 * @property {function} editorDefinition.interfaces.getContentDom69 */70 /**71 * Editor 정의가 올바른지 검사72 * @param {editorDefinition.editorSettings} editorSettings73 * @param {editorDefinition.interfaces} interfaces74 * @return {boolean}75 * @throws {EditorDefineError}76 */77 static isValidEditorOptions (editorSettings, interfaces) {78 let valid = true79 for (let eSettings in requireOptions.editorSettings) {80 if (!editorSettings.hasOwnProperty(requireOptions.editorSettings[eSettings])) {81 valid = false82 throw new EditorDefineError(`Editor 규격이 맞지 않음 (구현 필요 [editorSettings: ${requireOptions.editorSettings[eSettings]}])`)83 }84 }85 for (let eInterface in requireOptions.interfaces) {86 if (!interfaces.hasOwnProperty(requireOptions.interfaces[eInterface])) {87 valid = false88 throw new EditorDefineError(`Editor 규격이 맞지 않음 (구현 필요 [interface: ${requireOptions.interfaces[eInterface]}])`)89 }90 }91 if (editorSettings.hasOwnProperty('plugins') &&92 editorSettings.plugins instanceof Array &&93 editorSettings.plugins.length > 0 &&94 !editorSettings.hasOwnProperty('addPlugins')) {95 valid = false96 throw new EditorDefineError(`Editor 규격이 맞지 않음 (구현 필요 [fn:addPlugins])`)97 }98 if (window.XEeditor.editorSet.hasOwnProperty(editorSettings.name)) {99 valid = false100 throw new EditorDefineError(`이미 같은 이름의 에디터가 등록되어 있음: ${editorSettings.name}`)101 }102 return !(!valid)103 }104 /**105 * @typedef {Object} editorToolDefinition106 * @property {string} id107 * @property {object} events108 * @property {function} events.iconClick109 * @property {function} events.elementDoubleClick110 * @deprecated111 */112 /**113 * EditorTool 정의가 올바른지 검사114 * @param {editorToolDefinition} toolDefine115 * @return {boolean}116 * @throws {EditorToolDefineError}117 */118 static isValidToolsObject (toolDefine) {119 let valid = true120 for (let i = 0, max = requireOptions.tools.property.length; i < max; i += 1) {121 if (!toolDefine.hasOwnProperty(requireOptions.tools.property[i])) {122 valid = false123 throw new EditorToolDefineError(`EditorTool 규격이 맞지 않음 (속성이 없음: ${requireOptions.tools.property[i]})`)124 }125 }126 for (let i = 0, max = requireOptions.tools.events.length; i < max; i += 1) {127 if (!toolDefine.events.hasOwnProperty(requireOptions.tools.events[i])) {128 valid = false129 throw new EditorToolDefineError(`EditorTool 규격이 맞지 않음 (이벤트가 정의되지 않음: ${requireOptions.tools.events[i]})`)130 }131 }132 return valid133 }134}135export default EditorValidation136export {137 requireOptions...

Full Screen

Full Screen

conductor-utils.spec.js

Source:conductor-utils.spec.js Github

copy

Full Screen

1'use strict';2var ConductorUtils = require('../');3describe("Conductor Utils", function () {4 beforeEach(function () {5 this.options = {6 conductor: 'conductor',7 searchlight: 'searchlight'8 };9 });10 describe("requireOptions", function () {11 beforeEach(function () {12 this.bindRequiredOptions = function (requiredKeys) {13 return ConductorUtils.requireOptions.14 bind(ConductorUtils, this.options, requiredKeys);15 };16 });17 it("succeeds if all provided keys are in the options object", function () {18 var requireOptions = this.bindRequiredOptions(['conductor', 'searchlight']);19 expect(requireOptions).not.to.throw(Error);20 });21 it("succeeds if the single provided string is in the options object", function () {22 var requireOptions = this.bindRequiredOptions('conductor');23 expect(requireOptions).not.to.throw(Error);24 });25 it("throws if not all of the provided keys are in the options object", function () {26 var requireOptions = this.bindRequiredOptions(['conductor', '[Not Provided]']);27 expect(requireOptions).to.throw(TypeError);28 });29 it("throws if options ar not provided", function () {30 this.options = null;31 var requireOptions = this.bindRequiredOptions([]);32 expect(requireOptions).to.throw(TypeError);33 });34 });35 describe("assignRequiredOptions", function () {36 beforeEach(function () {37 this.context = {};38 });39 it("assigns the values in the options to the context", function () {40 ConductorUtils.assignRequiredOptions(this.context, this.options, ['conductor']);41 expect(this.context).to.eql({ conductor: 'conductor' });42 });43 it("uses the value on the context if not provided by the option", function () {44 this.context.content = 'content';45 ConductorUtils.assignRequiredOptions(this.context, this.options, ['content', 'conductor']);46 expect(this.context).to.eql({47 conductor: 'conductor',48 content: 'content'49 });50 });51 it("throws if the context and options do not have all required keys", function () {52 var assignRequiredOptions = ConductorUtils.assignRequiredOptions.53 bind(this, this.context, this.options, ['conductor', '[Not Provided]']);54 expect(assignRequiredOptions).to.throw(TypeError);55 });56 });...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

...31 }32 obj[pathArray.length ? pathArray[0] : stringPath] = value;33 return value;34}35function requireOptions(options, requireOptionKeys) {36 for (let i = 0; i < requireOptionKeys.length; i += 1) {37 const key = requireOptionKeys[i];38 if (_.isUndefined(options[key])) {39 throw new TypeError(`"${key}" is required`);40 }41 }42}43const CommonController = {44};45module.exports.resolveProp = resolveProp;46module.exports.setProp = setProp;47module.exports.requireOptions = requireOptions;...

Full Screen

Full Screen

.eslintrc.js

Source:.eslintrc.js Github

copy

Full Screen

1const paramContexts = ["FunctionExpression", "FunctionDeclaration", "MethodDefinition"]2const requireOptions = {}3for (const context of [...paramContexts, "ClassDeclaration", "ClassExpression"]) {4 requireOptions[context] = true5}6module.exports = {7 env: {8 es2020: true,9 node: true,10 },11 root: true,12 parser: "@typescript-eslint/parser",13 parserOptions: {14 project: "./tsconfig.eslint.json",15 },16 plugins: ["@typescript-eslint", "eslint-plugin-tsdoc", "jest", "jsdoc", "prettier"],17 extends: [18 "eslint:recommended",19 "plugin:@typescript-eslint/recommended",20 "plugin:jest/recommended",21 "plugin:jsdoc/recommended",22 "prettier",23 ],24 rules: {25 "@typescript-eslint/ban-ts-comment": "off",26 "@typescript-eslint/no-explicit-any": "off",27 "jest/no-identical-title": "off",28 "jsdoc/require-jsdoc": ["warn", { require: requireOptions }],29 "jsdoc/require-description": ["warn", { contexts: ["any"], checkConstructors: false }],30 "jsdoc/require-description-complete-sentence": ["warn"],31 "jsdoc/require-param": ["warn", { contexts: paramContexts }],32 "jsdoc/require-param-description": ["warn", { contexts: paramContexts }],33 "jsdoc/require-param-name": ["warn", { contexts: paramContexts }],34 "jsdoc/require-param-type": ["off"],35 "jsdoc/require-returns": ["off"],36 "jsdoc/require-yields": ["off"],37 "sort-imports": ["error", { allowSeparatedGroups: true }],38 "tsdoc/syntax": "warn",39 },...

Full Screen

Full Screen

main.dev.js

Source:main.dev.js Github

copy

Full Screen

1(function () {2 "use strict";3 var requireOptions = {4 urlArgs: "bust=" + (new Date()).getTime(),5 paths: {6 // Plugins7 checkbox: "plugins/checkbox",8 radio: "plugins/radio",9 timeinputer: "plugins/timeinputer",10 placeholder: "plugins/placeholder",11 submitter: "plugins/submitter",12 msg: "plugins/msg",13 validate: "plugins/validate",14 // Libraries15 // jquery: "jquery.min",16 // underscore: "underscore.min",17 // bootstrap: "bootstrap.min",18 // ZeroClipboard: "ZeroClipboard.min",19 datepicker: "bootstrap-datepicker.min",20 ueditorConfig: "../ueditor/ueditor.config",21 ueditor: "../ueditor/ueditor.all.min"22 }23 };24 requireOptions.paths["echarts/chart/line"] = "echarts";25 requireOptions.paths["echarts/chart/bar"] = "echarts";26 requireOptions.paths["echarts/chart/pie"] = "echarts";27 require.config(requireOptions);28 require([29 "jquery",30 "underscore"31 ], function ($) {32 require([33 "welife",34 "bootstrap",35 "checkbox",36 "radio",37 "timeinputer",38 "placeholder",39 "submitter",40 "msg",41 "validate"42 ], function (WeLife) {43 $(function () {44 var $main = $(".main");45 $main.data("welife", new WeLife($main[0], $main.data("module")));46 });47 });48 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var chai = require('chai');3var chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6chaiAsPromised.transferPromiseness = wd.transferPromiseness;7var desired = {8};9var driver = wd.promiseChainRemote('localhost', 4723);10driver.init(desired).then(function () {11});12var wd = require('wd');13var chai = require('chai');14var chaiAsPromised = require('chai-as-promised');15chai.use(chaiAsPromised);16chai.should();17chaiAsPromised.transferPromiseness = wd.transferPromiseness;18var desired = {19};20var driver = wd.promiseChainRemote('localhost', 4723);21driver.init(desired).then(function () {22});23var wd = require('wd');24var chai = require('chai');25var chaiAsPromised = require('chai-as-promised');26chai.use(chaiAsPromised);27chai.should();28chaiAsPromised.transferPromiseness = wd.transferPromiseness;29var desired = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const XCUITestDriver = require('appium-xcuitest-driver');2const opts = {3};4const driver = new XCUITestDriver();5driver.requireOptions(opts);6driver.createSession(opts);7driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1const XCUITestDriver = require('appium-xcuitest-driver');2XCUITestDriver.prototype.requireOptions = function (opts, requiredOpts) {3 requiredOpts = requiredOpts || [];4 for (let requiredOpt of requiredOpts) {5 if (!opts[requiredOpt]) {6 throw new Error(`The desired capability ${requiredOpt} is required`);7 }8 }9};10const XCUITestDriver = require('appium-xcuitest-driver');11XCUITestDriver.prototype.requireOptions = function (opts, requiredOpts) {12 requiredOpts = requiredOpts || [];13 for (let requiredOpt of requiredOpts) {14 if (!opts[requiredOpt]) {15 throw new Error(`The desired capability ${requiredOpt} is required`);16 }17 }18};19const XCUITestDriver = require('appium-xcuitest-driver');20XCUITestDriver.prototype.requireOptions = function (opts, requiredOpts) {21 requiredOpts = requiredOpts || [];22 for (let requiredOpt of requiredOpts) {23 if (!opts[requiredOpt]) {24 throw new Error(`The desired capability ${requiredOpt} is required`);25 }26 }27};28const XCUITestDriver = require('appium-xcuitest-driver');29XCUITestDriver.prototype.requireOptions = function (opts, requiredOpts) {30 requiredOpts = requiredOpts || [];31 for (let requiredOpt of requiredOpts) {32 if (!opts[requiredOpt]) {33 throw new Error(`The desired capability ${requiredOpt} is required`);34 }35 }36};37const XCUITestDriver = require('appium-xcuitest-driver');38XCUITestDriver.prototype.requireOptions = function (opts, requiredOpts) {39 requiredOpts = requiredOpts || [];40 for (let requiredOpt of requiredOpts) {41 if (!opts[requiredOpt]) {42 throw new Error(`The desired capability ${requiredOpt} is required`);43 }44 }45};

Full Screen

Using AI Code Generation

copy

Full Screen

1const XCUITestDriver = require('appium-xcuitest-driver');2let options = {3};4let driver = new XCUITestDriver();5driver.requireOptions(options);6driver.createSession(options);7const AndroidDriver = require('appium-android-driver');8let options = {9};10let driver = new AndroidDriver();11driver.requireOptions(options);12driver.createSession(options);13const WindowsDriver = require('appium-windows-driver');14let options = {15};16let driver = new WindowsDriver();17driver.requireOptions(options);18driver.createSession(options);19const MacDriver = require('appium-mac-driver');20let options = {21};22let driver = new MacDriver();23driver.requireOptions(options);24driver.createSession(options);25const YouiEngineDriver = require('appium-youiengine-driver');26let options = {27};28let driver = new YouiEngineDriver();29driver.requireOptions(options);30driver.createSession(options);31const TizenDriver = require('appium-tizen-driver');32let options = {33};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { XCUITestDriver } = require('appium-xcuitest-driver');2async function test() {3 const driver = new XCUITestDriver();4 const opts = {app: 'path/to/my/app.app'};5 await driver.createSession(opts);6}7test().catch((err) => {8 console.error(err);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1requireOptions = require('./driver').requireOptions;2var opts = {3};4requireOptions(opts);5function requireOptions (opts) {6 if (!opts.app) {7 throw new Error('App path is required');8 }9 if (!opts.platformVersion) {10 throw new Error('Platform Version is required');11 }12 if (!opts.platformName) {13 throw new Error('Platform Name is required');14 }15};16exports.requireOptions = requireOptions;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful