How to use config.get method in Cypress

Best JavaScript code snippet using cypress

Configuration.qunit.js

Source:Configuration.qunit.js Github

copy

Full Screen

1/*global QUnit, sinon */2(function() {3 "use strict";4 QUnit.config.autostart = false;5 sap.ui.require(['sap/ui/core/Configuration', 'sap/ui/core/Core', 'sap/ui/core/library', 'sap/ui/core/Locale', 'sap/base/Log'],6 function(Configuration, Core, coreLibrary, Locale, Log) {7 var browserUrl = {8 change: function(sUrl) {9 if (sUrl) {10 if (!this.href) {11 this.href = window.location.href;12 }13 window.history.pushState({},"Test URL", sUrl);14 }15 },16 reset: function() {17 if (this.href) {18 window.history.pushState({},"Test URL reset", this.href);19 this.href = null;20 }21 }22 };23 var CalendarType = coreLibrary.CalendarType;24 var AnimationMode = Configuration.AnimationMode;25 QUnit.module("Basic");26 QUnit.test("Settings", function(assert) {27 var oCfg = new Configuration();28 assert.equal(oCfg.theme, "sap_belize", "tag config should override global config");29 assert.deepEqual(oCfg.modules, ["sap.ui.core.library"], "Module List in configuration matches configured modules/libraries");30 });31 QUnit.test("jQuery and $", function(assert) {32 // we configured noConflict=true, so $ shouldn'T be the same as jQuery33 assert.ok(window.jQuery, "window.jQuery is available");34 assert.ok(!window.$ || window.$ !== window.jQuery, "window.$ not available or not the same as jQuery");35 });36 QUnit.test("LegacyDateCalendarCustomizing", function(assert) {37 var oCfg = new Configuration(),38 oFormatSettings = oCfg.getFormatSettings();39 var aData = [{40 "dateFormat": "A",41 "islamicMonthStart": "14351201",42 "gregDate": "20140925"43 }, {44 "dateFormat": "A",45 "islamicMonthStart": "14360101",46 "gregDate": "20141024"47 }, {48 "dateFormat": "A",49 "islamicMonthStart": "14360201",50 "gregDate": "20141123"51 }];52 assert.ok(oFormatSettings, "FormatSettings object is created");53 oFormatSettings.setLegacyDateCalendarCustomizing(aData);54 assert.strictEqual(oFormatSettings.getLegacyDateCalendarCustomizing(), aData, "The customizing data set can be retrieved");55 });56 QUnit.test("getter and setter for option 'calendar'", function(assert) {57 var oCfg = new Configuration(),58 oFormatSettings = oCfg.getFormatSettings();59 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The bootstrap parameter is respected");60 oCfg.setCalendarType(null);61 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The default calendar type is determined using the current locale");62 oCfg.setLanguage("ar_SA");63 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The default calendar type for ar_SA is islamic");64 oFormatSettings.setLegacyDateFormat("1");65 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '1' changes the calendar type to gregorian");66 oFormatSettings.setLegacyDateFormat("2");67 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '2' changes the calendar type to gregorian");68 oFormatSettings.setLegacyDateFormat("3");69 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '3' changes the calendar type to gregorian");70 oFormatSettings.setLegacyDateFormat("4");71 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '4' changes the calendar type to gregorian");72 oFormatSettings.setLegacyDateFormat("5");73 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '5' changes the calendar type to gregorian");74 oFormatSettings.setLegacyDateFormat("6");75 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The legacy date format '6' changes the calendar type to gregorian");76 oFormatSettings.setLegacyDateFormat(null);77 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The default calendar type for ar_SA is islamic");78 oCfg.setLanguage("en_US");79 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The default calendar type for en_US is gregorian");80 oFormatSettings.setLegacyDateFormat("A");81 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The legacy date format 'A' changes the calendar type to islamic");82 oCfg.setCalendarType(CalendarType.Gregorian);83 assert.equal(oCfg.getCalendarType(), CalendarType.Gregorian, "The calendar type is modified back to gregorian via calling setCalendarType");84 oCfg.setCalendarType(null);85 oFormatSettings.setLegacyDateFormat("B");86 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The legacy date format 'B' changes the calendar type to islamic");87 oFormatSettings.setLegacyDateFormat("7");88 assert.equal(oCfg.getCalendarType(), CalendarType.Japanese, "The legacy date format '7' changes the calendar type to japanese");89 oFormatSettings.setLegacyDateFormat("A");90 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The legacy date format 'A' changes the calendar type to islamic");91 oFormatSettings.setLegacyDateFormat("8");92 assert.equal(oCfg.getCalendarType(), CalendarType.Japanese, "The legacy date format '8' changes the calendar type to japanese");93 oFormatSettings.setLegacyDateFormat("A");94 assert.equal(oCfg.getCalendarType(), CalendarType.Islamic, "The legacy date format 'A' changes the calendar type to islamic");95 oFormatSettings.setLegacyDateFormat("9");96 assert.equal(oCfg.getCalendarType(), CalendarType.Japanese, "The legacy date format '9' changes the calendar type to japanese");97 oFormatSettings.setLegacyDateFormat("C");98 assert.equal(oCfg.getCalendarType(), CalendarType.Persian, "The legacy date format 'C' changes the calendar type to persian");99 });100 QUnit.module("localization change", {101 beforeEach: function(assert) {102 this.reset = function() {103 this.eventsReceived = 0;104 this.changes = [];105 };106 this.reset();107 this.oCoreMock = {108 fireLocalizationChanged: function(changes) {109 this.eventsReceived++;110 this.changes.push(changes);111 }.bind(this)112 };113 window['sap-ui-config'] = {114 language: 'en'115 };116 this.oConfig = new Configuration(this.oCoreMock);117 }118 });119 QUnit.test("setLanguage(en) - noop", function(assert) {120 this.oConfig.setLanguage("en");121 assert.equal(this.oConfig.getLanguage(), "en", "language still should be 'en'");122 assert.equal(this.oConfig.getSAPLogonLanguage(), "EN", "SAP Logon language should be 'EN'");123 assert.equal(this.eventsReceived, 0, "one localizationChange event should have been fired");124 });125 QUnit.test("setLanguage(de) - simple", function(assert) {126 this.oConfig.setLanguage("de");127 assert.equal(this.oConfig.getLanguage(), "de", "language should have changed to 'de'");128 assert.equal(this.oConfig.getSAPLogonLanguage(), "DE", "SAP Logon language should be 'DE'");129 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");130 assert.deepEqual(Object.keys(this.changes[0]), ['language'], "event should have reported 'language' as changed");131 });132 QUnit.test("setLanguage(he) - multi", function(assert) {133 this.oConfig.setLanguage("he");134 assert.equal(this.oConfig.getLanguage(), "he", "language should have changed to 'he'");135 assert.equal(this.oConfig.getSAPLogonLanguage(), "HE", "SAP Logon language should be 'HE'");136 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");137 assert.deepEqual(Object.keys(this.changes[0]).sort(), ['language', 'rtl'], "event should have reported 'language' and 'rtl' as changed");138 });139 QUnit.test("setLanguage(invalid)", function(assert) {140 var that = this;141 assert.throws(function() {142 that.oConfig.setLanguage(new Date());143 }, "setting anything but a string should cause an error");144 assert.throws(function() {145 that.oConfig.setLanguage({ toString : function() { return "en-GB"; }});146 }, "setting anything that only looks like a string should throw error");147 });148 QUnit.test("setRTL(null) - noop", function(assert) {149 assert.equal(this.oConfig.getRTL(), false, "[precondition] RTL should be false for 'en'");150 this.oConfig.setRTL(null);151 assert.equal(this.oConfig.getRTL(), false, "RTL still should be false for 'en'");152 assert.equal(this.eventsReceived, 0, "no localizationChange event should have been fired");153 this.oConfig.setLanguage("he");154 assert.equal(this.oConfig.getRTL(), true, "language 'he' should change the RTL flag when none (null) had been set");155 });156 QUnit.test("setRTL(false) - noop", function(assert) {157 assert.equal(this.oConfig.getRTL(), false, "[precondition] RTL should be false for 'en'");158 this.oConfig.setRTL(false);159 assert.equal(this.oConfig.getRTL(), false, "RTL still should be false for 'en'");160 assert.equal(this.eventsReceived, 0, "no localizationChange event should have been fired");161 this.oConfig.setLanguage("he");162 assert.equal(this.oConfig.getRTL(), false, "language 'he' must not change the explicitily configured RTL flag");163 });164 QUnit.test("setRTL(true) - change", function(assert) {165 assert.equal(this.oConfig.getRTL(), false, "[precondition] RTL should be false for 'en'");166 this.oConfig.setRTL(true);167 assert.equal(this.oConfig.getRTL(), true, "RTL still should be false for 'en'");168 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");169 assert.deepEqual(Object.keys(this.changes[0]).sort(), ['rtl'], "event should have reported 'rtl' as changed");170 });171 QUnit.test("setLegacyDateFormat", function(assert) {172 this.oConfig.getFormatSettings().setLegacyDateFormat("1");173 assert.equal(this.oConfig.getFormatSettings().getLegacyDateFormat(), "1", "legacy date format should have changed to '1'");174 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");175 assert.deepEqual(Object.keys(this.changes[0]).sort(), ['dateFormats-medium', 'dateFormats-short', 'legacyDateFormat'], "event should have reported 'language' and 'rtl' as changed");176 assert.ok(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should contain private extension 'sapufmt'");177 // unset again178 this.oConfig.getFormatSettings().setLegacyDateFormat();179 assert.notOk(this.oConfig.getFormatSettings().getLegacyDateFormat(), "legacy date format should have been unset");180 assert.notOk(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should no longer contain private extension 'sapufmt'");181 });182 QUnit.test("setLegacyTimeFormat", function(assert) {183 this.oConfig.getFormatSettings().setLegacyTimeFormat("1");184 assert.equal(this.oConfig.getFormatSettings().getLegacyTimeFormat(), "1", "legacy time format should have changed to '1'");185 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");186 assert.deepEqual(Object.keys(this.changes[0]).sort(), ['dayPeriods-format-abbreviated', 'legacyTimeFormat', 'timeFormats-medium', 'timeFormats-short'], "event should have reported 'language' and 'rtl' as changed");187 assert.ok(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should contain private extension 'sapufmt'");188 // unset again189 this.oConfig.getFormatSettings().setLegacyTimeFormat();190 assert.notOk(this.oConfig.getFormatSettings().getLegacyTimeFormat(), "legacy date format should have been unset");191 assert.notOk(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should no longer contain private extension 'sapufmt'");192 });193 QUnit.test("applySettings", function(assert) {194 this.oConfig.applySettings({195 language: 'he',196 formatSettings: {197 legacyDateFormat: '1',198 legacyTimeFormat: '1'199 },200 calendarType: 'Islamic'201 });202 assert.equal(this.oConfig.getLanguage(), "he", "language should have changed to 'he'");203 assert.equal(this.oConfig.getRTL(), true, "RTL should have changed to true");204 assert.equal(this.oConfig.getFormatSettings().getLegacyDateFormat(), "1", "legacy date format should have changed to '1'");205 assert.equal(this.oConfig.getFormatSettings().getLegacyTimeFormat(), "1", "legacy time format should have changed to '1'");206 assert.ok(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should contain private extension 'sapufmt'");207 assert.equal(this.eventsReceived, 1, "one localizationChange event should have been fired");208 assert.deepEqual(Object.keys(this.changes[0]).sort(), [209 'calendarType',210 'dateFormats-medium',211 'dateFormats-short',212 'dayPeriods-format-abbreviated',213 'language',214 'legacyDateFormat',215 'legacyTimeFormat',216 'rtl',217 'timeFormats-medium',218 'timeFormats-short'], "event should have reported the expected settings as changed");219 // unset again220 this.oConfig.applySettings({221 language: 'en',222 formatSettings: {223 legacyDateFormat: null,224 legacyTimeFormat: null225 },226 calendarType: null227 });228 assert.equal(this.oConfig.getLanguage(), "en", "language should have been reset to 'en'");229 assert.equal(this.oConfig.getRTL(), false, "RTL should have changed to false");230 assert.notOk(this.oConfig.getFormatSettings().getLegacyDateFormat(), "legacy date format should have been reset");231 assert.notOk(this.oConfig.getFormatSettings().getLegacyTimeFormat(), "legacy time format should have been reset");232 assert.equal(this.oConfig.getCalendarType(), CalendarType.Gregorian, "calendar type should be 'Gregorian' again");233 assert.notOk(/-x-(.*-)?sapufmt/.test(this.oConfig.getFormatSettings().getFormatLocale().toString()), "format locale should no longer contain private extension 'sapufmt'");234 });235 QUnit.module("SAP Logon Language");236 QUnit.test("derived from language - simple", function(assert) {237 var oConfig = Core.getConfiguration();238 // SAP language derived by UI5 - simple239 oConfig.setLanguage("en-US");240 assert.equal(oConfig.getSAPLogonLanguage(), "EN", "SAP Logon language should be 'EN'");241 oConfig.setLanguage("de-CH");242 assert.equal(oConfig.getSAPLogonLanguage(), "DE", "SAP Logon language should be 'DE'");243 });244 QUnit.test("derived from language - special cases", function(assert) {245 var oConfig = Core.getConfiguration();246 // SAP language derived by UI5 - special cases247 oConfig.setLanguage("zh-CN");248 assert.equal(oConfig.getSAPLogonLanguage(), "ZH", "SAP Logon language should be 'ZH'");249 oConfig.setLanguage("zh-Hans");250 assert.equal(oConfig.getSAPLogonLanguage(), "ZH", "SAP Logon language should be 'ZH'");251 oConfig.setLanguage("zh-Hans-CN");252 assert.equal(oConfig.getSAPLogonLanguage(), "ZH", "SAP Logon language should be 'ZH'");253 oConfig.setLanguage("zh-TW");254 assert.equal(oConfig.getSAPLogonLanguage(), "ZF", "SAP Logon language should be 'ZF'");255 oConfig.setLanguage("zh-Hant");256 assert.equal(oConfig.getSAPLogonLanguage(), "ZF", "SAP Logon language should be 'ZF'");257 oConfig.setLanguage("zh-Hant-TW");258 assert.equal(oConfig.getSAPLogonLanguage(), "ZF", "SAP Logon language should be 'ZF'");259 oConfig.setLanguage("en-US-x-saptrc");260 assert.equal(oConfig.getSAPLogonLanguage(), "1Q", "SAP Logon language should be '1Q'");261 oConfig.setLanguage("en-US-x-sappsd");262 assert.equal(oConfig.getSAPLogonLanguage(), "2Q", "SAP Logon language should be '2Q'");263 });264 QUnit.test("configured via API", function(assert) {265 var oConfig = Core.getConfiguration();266 // SAP language provided by caller of setLanguage267 oConfig.setLanguage("en-GB");268 assert.equal(oConfig.getSAPLogonLanguage(), "EN", "setting only BCP47 language can only return 'EN'");269 oConfig.setLanguage("en-GB", "6N"); // note: only SAPLanguage changes!270 assert.equal(oConfig.getSAPLogonLanguage(), "6N", "setting both values must return the extected SAP Language '6N'");271 oConfig.setLanguage("en-GB");272 assert.equal(oConfig.getSAPLogonLanguage(), "EN", "setting only BCP47 language again must reset the knowledge about SAP Language");273 });274 QUnit.module("SAP Logon Language (via url)", {275 beforeEach: function(assert) {276 this.setupConfig = function(sLanguage, sUrl) {277 var oCoreMock = {278 fireLocalizationChanged: function() {}279 };280 window["sap-ui-config"] = window["sap-ui-config"] || {};281 window["sap-ui-config"].language = sLanguage;282 browserUrl.change(sUrl);283 return new Configuration(oCoreMock);284 };285 },286 afterEach: function() {287 browserUrl.reset();288 }289 });290 [291 /* URL parameter language languageTag SAP-L Caption */292 [ "?sap-language=EN", "EN", "en", "EN", "sap-language is the valid ISO language EN"],293 [ "?sap-language=ZH", "zh-Hans", "zh-Hans", "ZH", "sap-language is the known SAP language ZN"],294 [ "?sap-language=ZF", "zh-Hant", "zh-Hant", "ZF", "sap-language is the known SAP language ZF"],295 [ "?sap-language=1Q", "en-US-x-saptrc", "en-US-x-saptrc", "1Q", "sap-language is the known SAP language 1Q"],296 [ "?sap-language=2Q", "en-US-x-sappsd", "en-US-x-sappsd", "2Q", "sap-language is the known SAP language 2Q"],297 [ "?sap-language=6N", "de", "de", "6N", "sap-language is the unknown SAP language 6N"],298 [ "?sap-locale=fr_CH", "fr_CH", "fr-CH", "FR", "sap-locale is the accepted BCP47 tag fr_CH"],299 [ "?sap-locale=En_gb&sap-language=6N", "En_gb", "en-GB", "6N", "valid combination of sap-locale and sap-language (En_gb, 6N)"],300 [ "?sap-ui-language=en_GB&sap-language=6N", "en_GB", "en-GB", "6N", "valid combination of sap-ui-language and sap-language (en_GB, 6N)"],301 [ "?sap-language=EN&sap-locale=en_GB", "en_GB", "en-GB", "EN", "valid combination of sap-language and sap-locale, both as BCP47 tag (EN, en_GB)"]302 ].forEach(function( data ) {303 QUnit.test(data[4], function(assert) {304 var oConfig = this.setupConfig("de", data[0]);305 assert.equal(oConfig.getLanguage(), data[1], "the effective language should be '" + data[1] + "'");306 assert.equal(oConfig.getLanguageTag(), data[2], "the effective language tag should be '" + data[2] + "'");307 assert.equal(oConfig.getSAPLogonLanguage(), data[3], "the SAP Logon language should be '" + data[3] + "'");308 });309 });310 QUnit.test("language via url, locale+language via API", function(assert) {311 var oConfig = this.setupConfig("de", "?sap-language=6N");312 assert.equal(oConfig.getLanguage(), "de", "the effective language still should be 'de'");313 assert.equal(oConfig.getLanguageTag(), "de", "the effective language tag still should be 'de'");314 assert.equal(oConfig.getSAPLogonLanguage(), "6N", "the SAP Logon language should be '6N' already");315 // without the second parameter, the sap language now would be 'EN' only316 oConfig.setLanguage("en-GB");317 assert.equal(oConfig.getLanguage(), "en-GB", "the effective language should be 'en-GB'");318 assert.equal(oConfig.getLanguageTag(), "en-GB", "the effective language tag should be 'en-GB'");319 assert.equal(oConfig.getSAPLogonLanguage(), "EN", "the SAP Logon language should be 'EN'");320 // but with the second parameter, everything should be fine321 oConfig.setLanguage("en-GB", "6N");322 assert.equal(oConfig.getLanguage(), "en-GB", "the effective language should be 'en-GB'");323 assert.equal(oConfig.getLanguageTag(), "en-GB", "the effective language tag should be 'en-GB'");324 assert.equal(oConfig.getSAPLogonLanguage(), "6N", "the SAP Logon language should be '6N'");325 });326 QUnit.test("error reporting", function(assert) {327 this.stub(Log, 'warning');328 this.setupConfig("de", "?sap-language=6N&sap-locale=en-GB");329 assert.strictEqual(Log.warning.called, false, "no warning should be written if accompanied by sap-locale");330 this.setupConfig("de", "?sap-language=6N&sap-ui-language=en-GB");331 assert.strictEqual(Log.warning.called, false, "no warning should be written if accompanied by sap-ui-language");332 this.setupConfig("de", "?sap-language=6N");333 assert.ok(Log.warning.calledWith(sinon.match(/6N/).and(sinon.match(/BCP-?47/i))), "warning must have been written");334 assert.throws(function() {335 this.setupConfig("de", "?sap-locale=6N&sap-language=6N");336 }, "setting an invalid (non-BCP-47) sap-locale should cause an error");337 assert.throws(function() {338 this.setupConfig("de", "?sap-ui-language=6N&sap-language=6N");339 }, "setting an invalid (non-BCP-47) sap-ui-language should cause an error");340 });341 QUnit.test("Format Locale", function(assert) {342 var oConfig;343 window['sap-ui-config'].formatlocale = 'fr-CH'; // Note: Configuration expects sap-ui-config names converted to lowercase (done by bootstrap)344 oConfig = this.setupConfig("fr-FR", "");345 assert.equal(oConfig.getLanguageTag(), "fr-FR", "language should be fr-FR");346 assert.equal(oConfig.getFormatLocale(), "fr-CH", "format locale string should be fr-CH");347 assert.ok(oConfig.getFormatSettings().getFormatLocale() instanceof Locale, "format locale should exist");348 assert.equal(oConfig.getFormatSettings().getFormatLocale().toString(), "fr-CH", "format locale should be fr-CH");349 window['sap-ui-config'].formatlocale = null;350 oConfig = this.setupConfig("fr-FR", "");351 assert.equal(oConfig.getLanguageTag(), "fr-FR", "language should be fr-FR");352 assert.equal(oConfig.getFormatLocale(), "fr-FR", "format locale string should be fr-CH");353 assert.ok(oConfig.getFormatSettings().getFormatLocale() instanceof Locale, "format locale should exist");354 assert.equal(oConfig.getFormatSettings().getFormatLocale().toString(), "fr-FR", "format locale should be fr-CH");355 delete window['sap-ui-config'].formatlocale;356 oConfig = this.setupConfig("de", "?sap-language=EN&sap-ui-formatLocale=en-AU");357 assert.equal(oConfig.getLanguageTag(), "en", "language should be en");358 assert.equal(oConfig.getFormatLocale(), "en-AU", "format locale string should be en-AU");359 assert.ok(oConfig.getFormatSettings().getFormatLocale() instanceof Locale, "format locale should exist");360 assert.equal(oConfig.getFormatSettings().getFormatLocale().toString(), "en-AU", "format locale should be en-AU");361 oConfig.setFormatLocale("en-CA");362 assert.equal(oConfig.getFormatLocale(), "en-CA", "format locale string should be en-CA");363 assert.ok(oConfig.getFormatSettings().getFormatLocale() instanceof Locale, "format locale should exist");364 assert.equal(oConfig.getFormatSettings().getFormatLocale().toString(), "en-CA", "format locale should be en-CA");365 oConfig.setFormatLocale();366 assert.equal(oConfig.getFormatLocale(), "en", "format locale string should be en");367 assert.ok(oConfig.getFormatSettings().getFormatLocale() instanceof Locale, "format locale should exist");368 assert.equal(oConfig.getFormatSettings().getFormatLocale().toString(), "en", "format locale should be en");369 assert.throws(function() {370 oConfig.setFormatLocale('6N');371 }, "setting an invalid (non-BCP-47) format locale should cause an error");372 assert.throws(function() {373 oConfig.setFormatLocale(new Date());374 }, "setting a non-string value as format locale should cause an error");375 });376 QUnit.module("Format settings", {377 afterEach: function() {378 browserUrl.reset();379 }380 });381 QUnit.test("Read 'sap-ui-legacy-number-format' from URL", function(assert) {382 var oSpySetLegacyNumberFormat = sinon.spy(Configuration.FormatSettings.prototype, "setLegacyNumberFormat");383 [384 { param: '', expected: undefined },385 { param: ' ', expected: ' ' },386 { param: 'X', expected: 'X' },387 { param: 'x', expected: 'X' },388 { param: 'Y', expected: 'Y' },389 { param: 'y', expected: 'Y' }390 ].forEach(function (data) {391 // setup392 browserUrl.change('?sap-ui-legacy-number-format=' + encodeURIComponent(data.param));393 oSpySetLegacyNumberFormat.reset();394 // call method under test395 var oConfig = new Configuration();396 // verify results397 assert.equal(oSpySetLegacyNumberFormat.callCount, 1, "setLegacyNumberFormat with value: '" + data.param + "' must be called");398 assert.equal(oConfig.getFormatSettings().getLegacyNumberFormat(), data.expected, "Value of number format must be '" + data.expected + "'.");399 oConfig.destroy();400 });401 });402 QUnit.test("Read 'sap-ui-legacy-date-format' from URL", function(assert) {403 var oSpySetLegacyDateFormat = sinon.spy(Configuration.FormatSettings.prototype, "setLegacyDateFormat");404 [405 { param: '', expected: undefined },406 { param: '1', expected: '1' },407 { param: '2', expected: '2' },408 { param: '3', expected: '3' },409 { param: '4', expected: '4' },410 { param: '5', expected: '5' },411 { param: '6', expected: '6' },412 { param: '7', expected: '7' },413 { param: '8', expected: '8' },414 { param: '9', expected: '9' },415 { param: 'A', expected: 'A' },416 { param: 'B', expected: 'B' },417 { param: 'C', expected: 'C' },418 { param: 'a', expected: 'A' },419 { param: 'b', expected: 'B' },420 { param: 'c', expected: 'C' }421 ].forEach(function (data) {422 browserUrl.change('?sap-ui-legacy-date-format=' + encodeURIComponent(data.param));423 oSpySetLegacyDateFormat.reset();424 var oConfig = new Configuration();425 assert.equal(oSpySetLegacyDateFormat.callCount, 1, "setLegacyDateFormat must have been called one time");426 assert.equal(oConfig.getFormatSettings().getLegacyDateFormat(), data.expected, "Value of date format must be '" + data.expected + "'.");427 oConfig.destroy();428 });429 });430 QUnit.test("Read 'sap-ui-legacy-time-format' from URL", function(assert) {431 var oSpySetLegacyTimeFormat = sinon.spy(Configuration.FormatSettings.prototype, "setLegacyTimeFormat");432 [433 { param: '', expected: undefined },434 { param: '0', expected: '0' },435 { param: '1', expected: '1' },436 { param: '2', expected: '2' },437 { param: '3', expected: '3' },438 { param: '4', expected: '4' }439 ].forEach(function (data) {440 browserUrl.change('?sap-ui-legacy-time-format=' + encodeURIComponent(data.param));441 oSpySetLegacyTimeFormat.reset();442 var oConfig = new Configuration();443 assert.equal(oSpySetLegacyTimeFormat.callCount, 1, "setLegacyTimeFormat must be called one time");444 assert.equal(oConfig.getFormatSettings().getLegacyTimeFormat(), data.expected, "Value of time format must be '" + data.expected + "'.");445 oConfig.destroy();446 });447 });448 QUnit.module("SAP parameters", {449 beforeEach: function(assert) {450 window["sap-ui-config"].language = "en";451 },452 afterEach: function() {453 browserUrl.reset();454 }455 });456 QUnit.test("Read SAP parameters from URL", function(assert) {457 // setup458 browserUrl.change('?sap-client=foo&sap-server=bar&sap-system=abc&sap-language=en');459 // call method under test460 var oConfig = new Configuration();461 // verify results462 assert.equal(oConfig.getSAPParam('sap-client'), 'foo', 'SAP parameter sap-client=foo');463 assert.equal(oConfig.getSAPParam('sap-server'), 'bar', 'SAP parameter sap-server=bar');464 assert.equal(oConfig.getSAPParam('sap-system'), 'abc', 'SAP parameter sap-system=abc');465 assert.equal(oConfig.getSAPParam('sap-language'), 'en', 'SAP parameter sap-language=en');466 oConfig.destroy();467 });468 QUnit.test("Read SAP parameters from URL (ignoreUrlParams)", function(assert) {469 // setup470 browserUrl.change('?sap-client=foo&sap-server=bar&sap-system=abc&sap-language=de');471 window["sap-ui-config"].ignoreurlparams = true;472 // call method under test473 var oConfig = new Configuration();474 // verify results475 assert.equal(oConfig.getSAPParam('sap-client'), undefined, 'SAP parameter sap-client=foo');476 assert.equal(oConfig.getSAPParam('sap-server'), undefined, 'SAP parameter sap-server=bar');477 assert.equal(oConfig.getSAPParam('sap-system'), undefined, 'SAP parameter sap-system=abc');478 assert.equal(oConfig.getSAPParam('sap-language'), 'EN', 'SAP parameter sap-language=en');479 oConfig.destroy();480 delete window["sap-ui-config"].ignoreurlparams;481 });482 QUnit.test("Set SAPLogonLanguage and SAP parameter is updated", function(assert) {483 // setup484 browserUrl.change('?sap-language=EN');485 // call method under test486 var oConfig = new Configuration();487 // verify results488 assert.equal(oConfig.getSAPParam('sap-language'), 'EN', 'SAP parameter sap-language=EN');489 oConfig.setLanguage("es");490 assert.equal(oConfig.getSAPParam('sap-language'), 'ES', 'SAP parameter sap-language=ES');491 oConfig.destroy();492 });493 QUnit.test("Read SAP parameters from <meta> tag", function(assert) {494 // setup495 var metaTagClient = document.createElement("meta");496 metaTagClient.setAttribute("name", "sap-client");497 metaTagClient.setAttribute("content", "foo");498 document.head.appendChild(metaTagClient);499 var metaTagServer = document.createElement("meta");500 metaTagServer.setAttribute("name", "sap-server");501 metaTagServer.setAttribute("content", "bar");502 document.head.appendChild(metaTagServer);503 var metaTagSystem = document.createElement("meta");504 metaTagSystem.setAttribute("name", "sap-system");505 metaTagSystem.setAttribute("content", "abc");506 document.head.appendChild(metaTagSystem);507 // call method under test508 var oConfig = new Configuration();509 // verify results510 assert.equal(oConfig.getSAPParam('sap-client'), 'foo', 'SAP parameter sap-client=foo');511 assert.equal(oConfig.getSAPParam('sap-server'), 'bar', 'SAP parameter sap-system=bar');512 assert.equal(oConfig.getSAPParam('sap-system'), 'abc', 'SAP parameter sap-client=abc');513 oConfig.destroy();514 document.head.removeChild(metaTagClient);515 document.head.removeChild(metaTagServer);516 document.head.removeChild(metaTagSystem);517 });518 // "animationmode" is the normalized value, the application still needs to use "animationMode".519 var sAnimationModeConfigurationName = 'animationmode';520 QUnit.module("Animation", {521 beforeEach: function() {522 window['sap-ui-config'] = window["sap-ui-config"] || {};523 delete window["sap-ui-config"]['animation'];524 delete window["sap-ui-config"][sAnimationModeConfigurationName];525 }526 });527 QUnit.test("Default animation and animation mode", function(assert) {528 var oConfiguration = new Configuration();529 assert.ok(oConfiguration.getAnimation(), "Default animation.");530 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.full, "Default animation mode.");531 });532 QUnit.test("Animation is off, default animation mode", function(assert) {533 window['sap-ui-config'] = { animation: false };534 var oConfiguration = new Configuration();535 assert.ok(!oConfiguration.getAnimation(), "Animation should be off.");536 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.minimal, "Animation mode should switch to " + AnimationMode.minimal + ".");537 });538 QUnit.test("Animation is off, valid but not possible mode is set and sanitized", function(assert) {539 window['sap-ui-config']['animaton'] = false;540 window['sap-ui-config'][sAnimationModeConfigurationName] = AnimationMode.basic;541 var oConfiguration = new Configuration();542 assert.ok(oConfiguration.getAnimation(), "Animation should be on because animation mode overwrites animation.");543 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.basic, "Animation mode should switch to " + AnimationMode.basic + ".");544 });545 QUnit.test("Invalid animation mode", function(assert) {546 window['sap-ui-config'][sAnimationModeConfigurationName] = "someuUnsupportedStringValue";547 assert.throws(548 function() { new Configuration(); },549 new Error("Unsupported Enumeration value for animationMode, valid values are: full, basic, minimal, none"),550 "Unsupported value for animation mode should throw an error."551 );552 });553 QUnit.test("Valid animation modes from enumeration", function(assert) {554 for (var sAnimationModeKey in AnimationMode) {555 if (AnimationMode.hasOwnProperty(sAnimationModeKey)) {556 var sAnimationMode = AnimationMode[sAnimationModeKey];557 window['sap-ui-config'][sAnimationModeConfigurationName] = sAnimationMode;558 var oConfiguration = new Configuration();559 if (sAnimationMode === AnimationMode.none || sAnimationMode === AnimationMode.minimal) {560 assert.ok(!oConfiguration.getAnimation(), "Animation is switched to off because of animation mode.");561 } else {562 assert.ok(oConfiguration.getAnimation(), "Animation is switched to on because of animation mode.");563 }564 assert.equal(oConfiguration.getAnimationMode(), sAnimationMode, "Test for animation mode: " + sAnimationMode);565 }566 }567 });568 QUnit.module("Animation runtime", {569 beforeEach: function() {570 this.getConfiguration = function () {571 return sap.ui.getCore().getConfiguration();572 };573 this.getHtmlAttribute = function(sAttribute) {574 var $html = jQuery("html");575 return $html.attr(sAttribute);576 };577 },578 afterEach: function() {579 // Restore default animation mode580 sap.ui.getCore().getConfiguration().setAnimationMode(AnimationMode.full);581 }582 });583 QUnit.test("Set animation mode to a valid value", function(assert) {584 var oConfiguration = this.getConfiguration();585 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.full, "Default animation mode is " + AnimationMode.full + ".");586 assert.equal(this.getHtmlAttribute("data-sap-ui-animation-mode"), AnimationMode.full);587 oConfiguration.setAnimationMode(AnimationMode.basic);588 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.basic, "Animation mode should switch to " + AnimationMode.basic + ".");589 assert.equal(this.getHtmlAttribute("data-sap-ui-animation-mode"), AnimationMode.basic);590 });591 QUnit.test("Set animation mode to " + AnimationMode.none + " to turn animation off", function(assert) {592 var oConfiguration = this.getConfiguration();593 // Check if default values are set594 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.full, "Default animation mode is " + AnimationMode.full + ".");595 assert.equal(this.getHtmlAttribute("data-sap-ui-animation-mode"), AnimationMode.full, "Default animation mode should be injected as attribute.");596 assert.equal(this.getHtmlAttribute("data-sap-ui-animation"), "on", "Default animation should be injected as attribute.");597 // Change animation mode598 oConfiguration.setAnimationMode(AnimationMode.none);599 assert.equal(oConfiguration.getAnimationMode(), AnimationMode.none, "Animation mode should switch to " + AnimationMode.none + ".");600 assert.equal(this.getHtmlAttribute("data-sap-ui-animation-mode"), AnimationMode.none, "Animation mode should be injected as attribute.");601 assert.equal(this.getHtmlAttribute("data-sap-ui-animation"), "off", "Animation should be turned off.");602 });603 QUnit.test("Invalid animation mode", function(assert) {604 var oConfiguration = this.getConfiguration();605 assert.throws(606 function() { oConfiguration.setAnimationMode("someUnsupportedStringValue"); },607 new Error("Unsupported Enumeration value for animationMode, valid values are: full, basic, minimal, none"),608 "Unsupported value for animation mode should throw an error."609 );610 assert.equal(this.getHtmlAttribute("data-sap-ui-animation-mode"), AnimationMode.full, "Default animation mode should stay the same.");611 });612 QUnit.start();613 });...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

...51 default: return unknown(action, cb)52 }53}54function edit (cb) {55 var e = npm.config.get("editor")56 , which = npm.config.get("global") ? "global" : "user"57 , f = npm.config.get(which + "config")58 , eol = process.platform === "win32" ? "\r\n" : "\n"59 if (!e) return cb(new Error("No EDITOR config or environ set."))60 npm.config.save(which, function (er) {61 if (er) return cb(er)62 fs.readFile(f, "utf8", function (er, data) {63 if (er) data = ""64 data = [ ";;;;"65 , "; npm "+(npm.config.get("global") ?66 "globalconfig" : "userconfig")+" file"67 , "; this is a simple ini-formatted file"68 , "; lines that start with semi-colons are comments."69 , "; read `npm help config` for help on the various options"70 , ";;;;"71 , ""72 , data73 ].concat( [ ";;;;"74 , "; all options with default values"75 , ";;;;"76 ]77 )78 .concat(Object.keys(npmconf.defaults).map(function (k) {79 return "; " + k + " = " + npmconf.defaults[k]80 }))81 .concat([""])82 .join(eol)83 fs.writeFile84 ( f85 , data86 , "utf8"87 , function (er) {88 if (er) return cb(er)89 exec(e, [f], cb)90 }91 )92 })93 })94}95function del (key, cb) {96 if (!key) return cb(new Error("no key provided"))97 var where = npm.config.get("global") ? "global" : "user"98 npm.config.del(key, where)99 npm.config.save(where, cb)100}101function set (key, val, cb) {102 if (key === undefined) {103 return unknown("", cb)104 }105 if (val === undefined) {106 if (key.indexOf("=") !== -1) {107 var k = key.split("=")108 key = k.shift()109 val = k.join("=")110 } else {111 val = ""112 }113 }114 key = key.trim()115 val = val.trim()116 log.info("config", "set %j %j", key, val)117 var where = npm.config.get("global") ? "global" : "user"118 npm.config.set(key, val, where)119 npm.config.save(where, cb)120}121function get (key, cb) {122 if (!key) return list(cb)123 if (key.charAt(0) === "_") {124 return cb(new Error("---sekretz---"))125 }126 console.log(npm.config.get(key))127 cb()128}129function sort (a, b) {130 return a > b ? 1 : -1131}132function reverse (a, b) {133 return a > b ? -1 : 1134}135function public (k) {136 return !(k.charAt(0) === "_" || types[k] !== types[k])137}138function getKeys (data) {139 return Object.keys(data).filter(public).sort(sort)140}141function list (cb) {142 var msg = ""143 , long = npm.config.get("long")144 var cli = npm.config.sources.cli.data145 , cliKeys = getKeys(cli)146 if (cliKeys.length) {147 msg += "; cli configs\n"148 cliKeys.forEach(function (k) {149 if (cli[k] && typeof cli[k] === "object") return150 if (k === "argv") return151 msg += k + " = " + JSON.stringify(cli[k]) + "\n"152 })153 msg += "\n"154 }155 // env configs156 var env = npm.config.sources.env.data157 , envKeys = getKeys(env)158 if (envKeys.length) {159 msg += "; environment configs\n"160 envKeys.forEach(function (k) {161 if (env[k] !== npm.config.get(k)) {162 if (!long) return163 msg += "; " + k + " = " + JSON.stringify(env[k])164 + " (overridden)\n"165 } else msg += k + " = " + JSON.stringify(env[k]) + "\n"166 })167 msg += "\n"168 }169 // user config file170 var uconf = npm.config.sources.user.data171 , uconfKeys = getKeys(uconf)172 if (uconfKeys.length) {173 msg += "; userconfig " + npm.config.get("userconfig") + "\n"174 uconfKeys.forEach(function (k) {175 var val = (k.charAt(0) === "_")176 ? "---sekretz---"177 : JSON.stringify(uconf[k])178 if (uconf[k] !== npm.config.get(k)) {179 if (!long) return180 msg += "; " + k + " = " + val181 + " (overridden)\n"182 } else msg += k + " = " + val + "\n"183 })184 msg += "\n"185 }186 // global config file187 var gconf = npm.config.sources.global.data188 , gconfKeys = getKeys(gconf)189 if (gconfKeys.length) {190 msg += "; globalconfig " + npm.config.get("globalconfig") + "\n"191 gconfKeys.forEach(function (k) {192 var val = (k.charAt(0) === "_")193 ? "---sekretz---"194 : JSON.stringify(gconf[k])195 if (gconf[k] !== npm.config.get(k)) {196 if (!long) return197 msg += "; " + k + " = " + val198 + " (overridden)\n"199 } else msg += k + " = " + val + "\n"200 })201 msg += "\n"202 }203 // builtin config file204 var builtin = npm.config.sources.builtin || {}205 if (builtin && builtin.data) {206 var bconf = builtin.data207 , bpath = builtin.path208 , bconfKeys = getKeys(bconf)209 if (bconfKeys.length) {210 var path = require("path")211 msg += "; builtin config " + bpath + "\n"212 bconfKeys.forEach(function (k) {213 var val = (k.charAt(0) === "_")214 ? "---sekretz---"215 : JSON.stringify(bconf[k])216 if (bconf[k] !== npm.config.get(k)) {217 if (!long) return218 msg += "; " + k + " = " + val219 + " (overridden)\n"220 } else msg += k + " = " + val + "\n"221 })222 msg += "\n"223 }224 }225 // only show defaults if --long226 if (!long) {227 msg += "; node bin location = " + process.execPath + "\n"228 + "; cwd = " + process.cwd() + "\n"229 + "; HOME = " + process.env.HOME + "\n"230 + "; 'npm config ls -l' to show all defaults.\n"231 console.log(msg)232 return cb()233 }234 var defaults = npmconf.defaults235 , defKeys = getKeys(defaults)236 msg += "; default values\n"237 defKeys.forEach(function (k) {238 if (defaults[k] && typeof defaults[k] === "object") return239 var val = JSON.stringify(defaults[k])240 if (defaults[k] !== npm.config.get(k)) {241 msg += "; " + k + " = " + val242 + " (overridden)\n"243 } else msg += k + " = " + val + "\n"244 })245 msg += "\n"246 console.log(msg)247 return cb()248}249function unknown (action, cb) {250 cb("Usage:\n" + config.usage)...

Full Screen

Full Screen

vn-config.js

Source:vn-config.js Github

copy

Full Screen

1'use strict';2describe('Service: vnConfig', function () {3 // load the service's module4 beforeEach(module('Volusion.toolboxCommon'));5 // instantiate service6 var vnConfig;7 describe('before configuration', function () {8 beforeEach(inject(function (_vnConfig_) {9 vnConfig = _vnConfig_;10 }));11 it('should not have an account defined', function () {12 expect(vnConfig.getAccount()).not.toBeDefined();13 });14 it('should default to true for globalNavState ', function () {15 expect(vnConfig.getGlobalNavState()).toBe(true);16 });17 it('should default to the designAction ', function () {18 expect(vnConfig.getCurrentAction()).toBe('designAction');19 });20 it('should default to true for the globalAttrBucketState', function () {21 expect(vnConfig.getGlobalAttrBucketState()).toBe(true);22 });23 it('should not have an iframe base path', function () {24 expect(vnConfig.getIframePathBase()).not.toBeDefined();25 });26 it('should not have a firebase endpoint', function () {27 expect(vnConfig.getFirebaseUrl()).not.toBeDefined();28 });29 it('should default screenMode to desktop', function () {30 expect(vnConfig.getScreenMode()).toBe('desktop');31 });32 it('should default to off for preview mode', function () {33 expect(vnConfig.getPreviewMode()).toBe('off');34 });35 it('should have default workspace dimensions', function () {36 var wsd = vnConfig.getWorkspaceDimensions();37 expect(wsd).toBeDefined();38 expect(wsd.width).toBeDefined();39 expect(wsd.width).toBe(0);40 expect(wsd.height).toBeDefined();41 expect(wsd.height).toBe(0);42 });43 });44 describe('after configuration', function () {45 beforeEach(inject(function (_vnConfig_) {46 vnConfig = _vnConfig_;47 // TODO - Implicit test of initConfig fn needs to be made explicit48 vnConfig.initConfig(); // The mock is baked into this method for dev49 }));50 it('should return an account', function () {51 var testAccount = vnConfig.getAccount();52 expect(testAccount).toBeDefined();53 expect(typeof testAccount).toBe('string');54 });55 it('should return an globalNavState', function () {56 var navState = vnConfig.getGlobalNavState();57 expect(navState).toBeDefined();58 expect(typeof navState).toBe('boolean');59 });60 it('should set a global nav state', function () {61 vnConfig.setGlobalNavState(false);62 expect(vnConfig.getGlobalNavState()).toBe(false);63 vnConfig.setGlobalNavState(true);64 expect(vnConfig.getGlobalNavState()).toBe(true);65 });66 it('should return a current action', function () {67 var testAction = vnConfig.getCurrentAction();68 expect(testAction).toBeDefined();69 expect(typeof testAction).toBe('string');70 });71 it('should set a current action', function () {72 //TODO - force only specific action types as string73 var testAction = 'testAction';74 vnConfig.setCurrentAction(testAction);75 expect(vnConfig.getCurrentAction()).toBe('testAction');76 });77 it('should return an iFramePathBase', function () {78 //TODO - answer why this doesn't have a setter. How is it set?79 var test = vnConfig.getIframePathBase();80 expect(test).toBeDefined();81 expect(typeof test).toBe('string');82 });83 it('should return a firebase url ', function () {84 var test = vnConfig.getFirebaseUrl();85 expect(test).toBeDefined();86 expect(typeof test).toBe('string');87 });88 it('should get the screenMode', function () {89 var test = vnConfig.getScreenMode();90 expect(test).toBeDefined();91 expect(typeof test).toBe('string');92 });93 it('should set a screenMode', function () {94 vnConfig.setScreenMode(true);95 expect(vnConfig.getScreenMode()).toBe(true);96 vnConfig.setScreenMode(false);97 expect(vnConfig.getScreenMode()).toBe(false);98 });99 //TODO Talk w/ tsnako re the setter takes Boolean and the getter returns string100 //TODO optimize it?101 it('should get the preview mode', function () {102 var test = vnConfig.getPreviewMode();103 expect(test).toBeDefined();104 expect(typeof test).toBe('string');105 });106 it('should set the preview mode', function () {107 vnConfig.setPreviewMode(true);108 expect(vnConfig.getPreviewMode()).toBe('on');109 vnConfig.setPreviewMode(false);110 expect(vnConfig.getPreviewMode()).toBe('off');111 });112 it('should get workspace dimensions', function () {113 var test = vnConfig.getWorkspaceDimensions();114 expect(test).toBeDefined();115 expect(typeof test).toBe('object');116 });117 it('should set workspace dimensions', function () {118 var mock = {119 width: 11,120 height: 99121 };122 vnConfig.setWorkspaceDimensions(mock);123 var test = vnConfig.getWorkspaceDimensions();124 expect(test.width).toEqual(11);125 expect(test.height).toEqual(99);126 });127 });...

Full Screen

Full Screen

urc.test.js

Source:urc.test.js Github

copy

Full Screen

1'use strict';2const path = require('path');3const tempy = require('tempy');4const fs = require('fs');5const getDefaultConfig = require('../default-underreact.config');6const Urc = require('./urc');7test('Urc is correctly initialized when command=build and mode=development', () => {8 const cliOpts = {9 command: 'build',10 mode: 'development',11 configPath: path.join('/', 'fake-volume', 'underreact.config.js')12 };13 const defaultConfig = getDefaultConfig(cliOpts);14 expect(new Urc({}, defaultConfig, cliOpts)).toMatchSnapshot();15});16test('Urc is correctly initialized when command=build and mode=production', () => {17 const cliOpts = {18 command: 'build',19 mode: 'production',20 configPath: path.join('/', 'fake-volume', 'underreact.config.js')21 };22 const defaultConfig = getDefaultConfig(cliOpts);23 expect(new Urc({}, defaultConfig, cliOpts)).toMatchSnapshot();24});25test('Urc is correctly initialized when command=start and mode=development', () => {26 const cliOpts = {27 command: 'start',28 mode: 'development',29 configPath: path.join('/', 'fake-volume', 'underreact.config.js')30 };31 const defaultConfig = getDefaultConfig(cliOpts);32 expect(new Urc({}, defaultConfig, cliOpts)).toMatchSnapshot();33});34test('Urc is correctly initialized when command=start and mode=production', () => {35 const cliOpts = {36 command: 'start',37 mode: 'production',38 configPath: path.join('/', 'fake-volume', 'underreact.config.js')39 };40 const defaultConfig = getDefaultConfig(cliOpts);41 expect(new Urc({}, defaultConfig, cliOpts)).toMatchSnapshot();42});43test("Doesn't hot reload when command is build ", () => {44 const cliOpts = {45 command: 'build',46 mode: 'development',47 configPath: path.join('/', 'fake-volume', 'underreact.config.js')48 };49 const defaultConfig = getDefaultConfig(cliOpts);50 expect(new Urc({ hot: true }, defaultConfig, cliOpts).hot).toBe(false);51});52test('Live reload is off when mode is production ', () => {53 const cliOpts = {54 command: 'build',55 mode: 'production',56 configPath: path.join('/', 'fake-volume', 'underreact.config.js')57 };58 const defaultConfig = getDefaultConfig(cliOpts);59 expect(new Urc({}, defaultConfig, cliOpts).liveReload).toBe(false);60});61test('normalizes fancy configuration', () => {62 const cliOpts = {63 command: 'build',64 mode: 'development',65 configPath: path.join('/', 'fake-volume', 'underreact.config.js')66 };67 const defaultConfig = getDefaultConfig(cliOpts);68 expect(69 new Urc(70 {71 siteBasePath: 'fancy',72 publicAssetsPath: 'cacheable-things',73 webpackLoaders: [74 {75 test: /\.less$/,76 use: ['css-loader', 'less-loader']77 }78 ],79 webpackPlugins: [function foo() {}],80 webpackConfigTransform: config => {81 config.devtool = false;82 return config;83 }84 },85 defaultConfig,86 cliOpts87 )88 ).toMatchSnapshot();89});90test('setting urc.polyfill to false removes polyfill entry', () => {91 const cliOpts = {92 command: 'build',93 mode: 'development',94 configPath: path.join('/', 'fake-volume', 'underreact.config.js')95 };96 const defaultConfig = getDefaultConfig(cliOpts);97 expect(98 new Urc(99 {100 polyfill: false101 },102 defaultConfig,103 cliOpts104 ).polyfill105 ).toBe(false);106});107test('not setting polyfill fallbacks to default path', () => {108 const cliOpts = {109 command: 'build',110 mode: 'development',111 configPath: path.join('/', 'fake-volume', 'underreact.config.js')112 };113 const defaultConfig = getDefaultConfig(cliOpts);114 expect(new Urc({}, defaultConfig, cliOpts).polyfill).toMatchSnapshot();115});116test('reads environment variables', () => {117 const tempDir = tempy.directory();118 const cliOpts = {119 mode: 'development',120 stats: undefined,121 port: undefined,122 configPath: path.join(tempDir, 'underreact.config.js')123 };124 const defaultConfig = getDefaultConfig(cliOpts);125 const clientEnv = new Urc(126 {127 environmentVariables: {128 MY_ENV_1: 1,129 MY_ENV_2: 2130 }131 },132 defaultConfig,133 cliOpts134 ).readClientEnvVars();135 expect(clientEnv).toMatchSnapshot();136});137test('throws an error if setting DEPLOY_ENV', () => {138 const tempDir = tempy.directory();139 const cliOpts = {140 mode: 'development',141 stats: undefined,142 port: undefined,143 configPath: path.join(tempDir, 'underreact.config.js')144 };145 const defaultConfig = getDefaultConfig(cliOpts);146 const urc = new Urc(147 {148 environmentVariables: {149 DEPLOY_ENV: 1,150 MY_ENV_2: 2151 }152 },153 defaultConfig,154 cliOpts155 );156 expect(() => urc.readClientEnvVars()).toThrowErrorMatchingInlineSnapshot(157 `"DEPLOY_ENV can not be set in your Underreact configuration. Please set it directly in your shell."`158 );159});160test("doesn't set default browserslist if user is using external config", () => {161 const tempDir = tempy.directory();162 fs.writeFileSync(path.join(tempDir, '.browserslistrc'), `chrome 67`);163 const cliOpts = {164 mode: 'development',165 stats: undefined,166 port: undefined,167 configPath: path.join(tempDir, 'underreact.config.js')168 };169 const defaultConfig = getDefaultConfig(cliOpts);170 const urc = new Urc({}, defaultConfig, cliOpts);171 expect(urc.browserslist).toBeUndefined();...

Full Screen

Full Screen

Sidebar.Project.js

Source:Sidebar.Project.js Github

copy

Full Screen

1/**2 * @author mrdoob / http://mrdoob.com/3 */4Sidebar.Project = function ( editor ) {5 var config = editor.config;6 var signals = editor.signals;7 var rendererTypes = {8 'WebGLRenderer': THREE.WebGLRenderer,9 'CanvasRenderer': THREE.CanvasRenderer,10 'SVGRenderer': THREE.SVGRenderer,11 'SoftwareRenderer': THREE.SoftwareRenderer,12 'RaytracingRenderer': THREE.RaytracingRenderer13 };14 var container = new UI.Panel();15 container.setBorderTop( '0' );16 container.setPaddingTop( '20px' );17 // Title18 var titleRow = new UI.Row();19 var title = new UI.Input( config.getKey( 'project/title' ) ).setLeft( '100px' ).onChange( function () {20 config.setKey( 'project/title', this.getValue() );21 } );22 titleRow.add( new UI.Text( 'Title' ).setWidth( '90px' ) );23 titleRow.add( title );24 container.add( titleRow );25 // Editable26 var editableRow = new UI.Row();27 var editable = new UI.Checkbox( config.getKey( 'project/editable' ) ).setLeft( '100px' ).onChange( function () {28 config.setKey( 'project/editable', this.getValue() );29 } );30 editableRow.add( new UI.Text( 'Editable' ).setWidth( '90px' ) );31 editableRow.add( editable );32 container.add( editableRow );33 // VR34 var vrRow = new UI.Row();35 var vr = new UI.Checkbox( config.getKey( 'project/vr' ) ).setLeft( '100px' ).onChange( function () {36 config.setKey( 'project/vr', this.getValue() );37 } );38 vrRow.add( new UI.Text( 'VR' ).setWidth( '90px' ) );39 vrRow.add( vr );40 container.add( vrRow );41 // Renderer42 var options = {};43 for ( var key in rendererTypes ) {44 if ( key.indexOf( 'WebGL' ) >= 0 && System.support.webgl === false ) continue;45 options[ key ] = key;46 }47 var rendererTypeRow = new UI.Row();48 var rendererType = new UI.Select().setOptions( options ).setWidth( '150px' ).onChange( function () {49 var value = this.getValue();50 config.setKey( 'project/renderer', value );51 updateRenderer();52 } );53 rendererTypeRow.add( new UI.Text( 'Renderer' ).setWidth( '90px' ) );54 rendererTypeRow.add( rendererType );55 container.add( rendererTypeRow );56 if ( config.getKey( 'project/renderer' ) !== undefined ) {57 rendererType.setValue( config.getKey( 'project/renderer' ) );58 }59 // Renderer / Antialias60 var rendererPropertiesRow = new UI.Row().setMarginLeft( '90px' );61 var rendererAntialias = new UI.THREE.Boolean( config.getKey( 'project/renderer/antialias' ), 'antialias' ).onChange( function () {62 config.setKey( 'project/renderer/antialias', this.getValue() );63 updateRenderer();64 } );65 rendererPropertiesRow.add( rendererAntialias );66 // Renderer / Shadows67 var rendererShadows = new UI.THREE.Boolean( config.getKey( 'project/renderer/shadows' ), 'shadows' ).onChange( function () {68 config.setKey( 'project/renderer/shadows', this.getValue() );69 updateRenderer();70 } );71 rendererPropertiesRow.add( rendererShadows );72 rendererPropertiesRow.add( new UI.Break() );73 // Renderer / Gamma input74 var rendererGammaInput = new UI.THREE.Boolean( config.getKey( 'project/renderer/gammaInput' ), 'γ input' ).onChange( function () {75 config.setKey( 'project/renderer/gammaInput', this.getValue() );76 updateRenderer();77 } );78 rendererPropertiesRow.add( rendererGammaInput );79 // Renderer / Gamma output80 var rendererGammaOutput = new UI.THREE.Boolean( config.getKey( 'project/renderer/gammaOutput' ), 'γ output' ).onChange( function () {81 config.setKey( 'project/renderer/gammaOutput', this.getValue() );82 updateRenderer();83 } );84 rendererPropertiesRow.add( rendererGammaOutput );85 container.add( rendererPropertiesRow );86 //87 function updateRenderer() {88 createRenderer( rendererType.getValue(), rendererAntialias.getValue(), rendererShadows.getValue(), rendererGammaInput.getValue(), rendererGammaOutput.getValue() );89 }90 function createRenderer( type, antialias, shadows, gammaIn, gammaOut ) {91 if ( type === 'WebGLRenderer' && System.support.webgl === false ) {92 type = 'CanvasRenderer';93 }94 rendererPropertiesRow.setDisplay( type === 'WebGLRenderer' ? '' : 'none' );95 var renderer = new rendererTypes[ type ]( { antialias: antialias} );96 renderer.gammaInput = gammaIn;97 renderer.gammaOutput = gammaOut;98 if ( shadows && renderer.shadowMap ) {99 renderer.shadowMap.enabled = true;100 // renderer.shadowMap.type = THREE.PCFSoftShadowMap;101 }102 signals.rendererChanged.dispatch( renderer );103 }104 createRenderer( config.getKey( 'project/renderer' ), config.getKey( 'project/renderer/antialias' ), config.getKey( 'project/renderer/shadows' ), config.getKey( 'project/renderer/gammaInput' ), config.getKey( 'project/renderer/gammaOutput' ) );105 return container;...

Full Screen

Full Screen

fetch.js

Source:fetch.js Github

copy

Full Screen

...55}56function makeRequest (remote, fstr, headers) {57 remote = url.parse(remote)58 log.http("GET", remote.href)59 regHost = regHost || url.parse(npm.config.get("registry")).host60 if (remote.host === regHost && npm.config.get("always-auth")) {61 remote.auth = new Buffer( npm.config.get("_auth")62 , "base64" ).toString("utf8")63 if (!remote.auth) return fstr.emit("error", new Error(64 "Auth required and none provided. Please run 'npm adduser'"))65 }66 var proxy67 if (remote.protocol !== "https:" || !(proxy = npm.config.get("https-proxy"))) {68 proxy = npm.config.get("proxy")69 }70 var opts = { url: remote71 , proxy: proxy72 , strictSSL: npm.config.get("strict-ssl")73 , rejectUnauthorized: npm.config.get("strict-ssl")74 , ca: remote.host === regHost ? npm.config.get("ca") : undefined75 , headers: { "user-agent": npm.config.get("user-agent") }}76 var req = request(opts)77 req.on("error", function (er) {78 fstr.emit("error", er)79 })80 req.pipe(fstr)81 return req...

Full Screen

Full Screen

email.js

Source:email.js Github

copy

Full Screen

...37 if (!config.smtpConfigured()) {38 console.error('email.send() called without being configured');39 return;40 }41 if (config.get('debug')) {42 console.log('sending email');43 }44 const smtpConfig = {45 host: config.get('smtpHost'),46 port: config.get('smtpPort'),47 secure: config.get('smtpSecure'),48 auth: {49 user: config.get('smtpUser'),50 pass: config.get('smtpPassword')51 },52 tls: {53 ciphers: 'SSLv3'54 }55 };56 return new Promise((resolve, reject) => {57 const transporter = nodemailer.createTransport(smtpConfig);58 const mailOptions = {59 from: config.get('smtpFrom'),60 to,61 subject,62 text,63 html64 };65 transporter.sendMail(mailOptions, function(err, info) {66 if (config.get('debug')) {67 console.log('sent email: ' + info);68 }69 if (err) {70 console.error(err);71 return reject(err);72 }73 resolve(info);74 });75 });76 });77}78module.exports = {79 fullUrl,80 send,...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

2var _ = require('lodash');3var fromNode = require('bluebird').fromNode;4module.exports = function (kbnServer, server, config) {5 return fromNode(function (cb) {6 var events = config.get('logging.events');7 if (config.get('logging.silent')) {8 _.defaults(events, {});9 } else if (config.get('logging.quiet')) {10 _.defaults(events, {11 log: ['listening', 'error', 'fatal'],12 error: '*'13 });14 } else if (config.get('logging.verbose')) {15 _.defaults(events, {16 log: '*',17 ops: '*',18 request: '*',19 response: '*',20 error: '*'21 });22 } else {23 _.defaults(events, {24 log: ['info', 'warning', 'error', 'fatal'],25 response: config.get('logging.json') ? '*' : '!',26 error: '*'27 });28 }29 server.register({30 register: require('good'),31 options: {32 opsInterval: 5000,33 requestHeaders: true,34 requestPayload: true,35 reporters: [{36 reporter: require('./LogReporter'),37 config: {38 json: config.get('logging.json'),39 dest: config.get('logging.dest'),40 // I'm adding the default here because if you add another filter41 // using the commandline it will remove authorization. I want users42 // to have to explicitly set --logging.filter.authorization=none to43 // have it show up int he logs.44 filter: _.defaults(config.get('logging.filter'), {45 authorization: 'remove'46 })47 },48 events: _.transform(events, function (filtered, val, key) {49 // provide a string compatible way to remove events50 if (val !== '!') filtered[key] = val;51 }, {})52 }]53 }54 }, cb);55 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6{7 "env": {8 }9}10describe('My First Test', function() {11 it('Does not do much!', function() {12 cy.visit('/')13 cy.get('nav a').contains('About')14 cy.get('nav a').contains('Contact')15 })16})17describe('My First Test', function() {18 it('Does not do much!', function() {19 cy.visit('/')20 cy.get('nav a').contains('About')21 cy.get('nav a').contains('Contact')22 })23})24describe('My First Test', function() {25 it('Does not do much!', function() {26 cy.visit('/')27 cy.get('nav a').contains('About')28 cy.get('nav a').contains('Contact')29 })30})31describe('My First Test', function() {32 it('Does not do much!', function() {33 cy.visit('/')34 cy.get('nav a').contains('About')35 cy.get('nav a').contains('Contact')36 })37})38describe('My First Test', function() {39 it('Does not do much!', function() {40 cy.visit('/')41 cy.get('nav a').contains('About')42 cy.get('nav a').contains('Contact')43 })44})45describe('My First Test', function() {46 it('Does not do much!', function() {47 cy.visit('/')48 cy.get('nav a').contains('About')49 cy.get('nav a').contains('Contact')50 })51})52describe('My First Test', function() {53 it('Does not do much!', function() {54 cy.visit('/')55 cy.get('nav a').contains('About')56 cy.get('nav a').contains('Contact')57 })58})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('Test', function() {3 cy.get('.home-list > :nth-child(1) > .home-list-item').click()4 cy.get('.query-btn').click()5 cy.get('.query-btn').should('contain', 'Button')6 cy.get('.query-btn').should('have.class', 'btn')7 cy.get('.query-btn').should('have.css', 'background-color', 'rgb(0, 128, 0)')8 })9})

Full Screen

Using AI Code Generation

copy

Full Screen

1const config = require('config');2describe('My First Test', function() {3 it('Does not do much!', function() {4 cy.log(config.get('name'));5 cy.contains('type').click();6 cy.url().should('include', '/commands/actions');7 cy.get('.action-email')8 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1const config = require('../../config/config.js');2const url = config.get('url');3const username = config.get('username');4const password = config.get('password');5const login = config.get('login');6const title = config.get('title');7const description = config.get('description');8const tags = config.get('tags');9const article = config.get('article');10const articleTitle = config.get('articleTitle');11const articleDescription = config.get('articleDescription');12const articleBody = config.get('articleBody');13const articleTags = config.get('articleTags');14describe('E2E Test', () => {15 before(() => {16 cy.visit(url);17 cy.get(login).click();18 cy.get('input[type="email"]').type(username);19 cy.get('input[type="password"]').type(password);20 cy.get('.btn').click();21 });22 it('create a new article', () => {23 cy.get('.ion-compose').click();24 cy.get('input[placeholder="Article Title"]').type(articleTitle);25 cy.get('input[placeholder="What\'s this article about?"]').type(articleDescription);26 cy.get('textarea[placeholder="Write your article (in markdown)"]').type(articleBody);27 cy.get('input[placeholder="Enter tags"]').type(articleTags);28 cy.get('.btn-lg').click();29 });30 it('edit the article', () => {31 cy.contains('Edit Article').click();32 cy.get('input[placeholder="Article Title"]').clear().type(title);33 cy.get('input[placeholder="What\'s this article about?"]').clear().type(description);34 cy.get('textarea[placeholder="Write your article (in markdown)"]').clear().type(article);35 cy.get('input[placeholder="Enter tags"]').clear().type(tags);36 cy.get('.btn-lg').click();37 });38 it('delete the article', () => {39 cy.contains('Delete Article').click();40 });41});42const config = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const config = require('../config/config.js');2describe('My First Test', function() {3 it('Visits the Kitchen Sink', function() {4 cy.visit(config.get('url'));5 })6})

Full Screen

Using AI Code Generation

copy

Full Screen

1const url = Cypress.config().baseUrl2describe('My First Test', function() {3 it('Visits the Kitchen Sink', function() {4 cy.visit(url)5 })6})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful