How to use versions.getVersions method in Cypress

Best JavaScript code snippet using cypress

Versions.qunit.js

Source:Versions.qunit.js Github

copy

Full Screen

1/* global QUnit */2sap.ui.define([3 "sap/ui/thirdparty/sinon-4",4 "sap/ui/fl/write/_internal/Versions",5 "sap/ui/fl/write/_internal/Storage",6 "sap/ui/fl/write/_internal/connectors/KeyUserConnector",7 "sap/ui/fl/ChangePersistenceFactory"8], function(9 sinon,10 Versions,11 Storage,12 KeyUserConnector,13 ChangePersistenceFactory14) {15 "use strict";16 var sandbox = sinon.sandbox.create();17 QUnit.module("Internal Caching", {18 beforeEach: function () {19 this.aReturnedVersions = [];20 this.oStorageLoadVersionsStub = sandbox.stub(Storage.versions, "load").resolves(this.aReturnedVersions);21 },22 afterEach: function() {23 Versions.clearInstances();24 sandbox.restore();25 }26 }, function() {27 QUnit.test("Given Versions.getVersions is called", function (assert) {28 var mPropertyBag = {29 layer : "CUSTOMER",30 reference : "com.sap.app"31 };32 return Versions.getVersions(mPropertyBag).then(function (oResponse) {33 assert.equal(this.oStorageLoadVersionsStub.callCount, 1, "then a request was sent");34 assert.equal(oResponse, this.aReturnedVersions, "and the versions list is returned");35 }.bind(this));36 });37 QUnit.test("Given Versions.getVersions is called multiple times for the same reference and layer", function (assert) {38 var mPropertyBag = {39 layer : "CUSTOMER",40 reference : "com.sap.app"41 };42 return Versions.getVersions(mPropertyBag).then(function (oResponse) {43 assert.equal(this.oStorageLoadVersionsStub.callCount, 1, "then a request was sent");44 assert.equal(oResponse, this.aReturnedVersions, "and the versions list is returned");45 return Versions.getVersions(mPropertyBag);46 }.bind(this)).then(function (oResponse) {47 assert.equal(this.oStorageLoadVersionsStub.callCount, 1, "no further request is sent");48 assert.equal(oResponse, this.aReturnedVersions, "and the versions list is returned");49 }.bind(this));50 });51 QUnit.test("Given Versions.getVersions is called multiple times for different references", function (assert) {52 var mPropertyBag1 = {53 layer : "CUSTOMER",54 reference : "com.sap.app"55 };56 var mPropertyBag2 = {57 layer : "CUSTOMER",58 reference : "com.sap.app2"59 };60 var aReturnedVersions = [];61 sandbox.stub(KeyUserConnector.versions, "load").resolves(aReturnedVersions);62 return Versions.getVersions(mPropertyBag1).then(function (oResponse) {63 assert.equal(this.oStorageLoadVersionsStub.callCount, 1, "then a request was sent");64 assert.deepEqual(oResponse, aReturnedVersions, "and the versions list is returned");65 return Versions.getVersions(mPropertyBag2);66 }.bind(this)).then(function (oResponse) {67 assert.equal(this.oStorageLoadVersionsStub.callCount, 2, "a further request is sent");68 assert.deepEqual(oResponse, aReturnedVersions, "and the versions list is returned");69 }.bind(this));70 });71 QUnit.test("Given Versions.getVersions is called multiple times for different layers", function (assert) {72 var mPropertyBag1 = {73 layer : "CUSTOMER",74 reference : "com.sap.app"75 };76 var mPropertyBag2 = {77 layer : "USER",78 reference : "com.sap.app"79 };80 return Versions.getVersions(mPropertyBag1).then(function (oResponse) {81 assert.equal(this.oStorageLoadVersionsStub.callCount, 1, "then a request was sent");82 assert.equal(oResponse, this.aReturnedVersions, "and the versions list is returned");83 return Versions.getVersions(mPropertyBag2);84 }.bind(this)).then(function (oResponse) {85 assert.equal(this.oStorageLoadVersionsStub.callCount, 2, "a further request is sent");86 assert.equal(oResponse, this.aReturnedVersions, "and the versions list is returned");87 }.bind(this));88 });89 });90 QUnit.module("Calling the Storage: Given Versions.getVersions is called", {91 beforeEach: function () {92 sandbox.stub(sap.ui.getCore().getConfiguration(), "getFlexibilityServices").returns([93 {connector : "KeyUserConnector", layers : ["CUSTOMER"], url: "/flexKeyUser"}94 ]);95 },96 afterEach: function() {97 Versions.clearInstances();98 sandbox.restore();99 }100 }, function() {101 QUnit.test("and a connector is configured which returns a list of versions", function (assert) {102 var mPropertyBag = {103 layer : "CUSTOMER",104 reference : "com.sap.app"105 };106 var aReturnedVersions = [];107 sandbox.stub(KeyUserConnector.versions, "load").resolves(aReturnedVersions);108 return Versions.getVersions(mPropertyBag).then(function (oResponse) {109 assert.equal(oResponse, aReturnedVersions, "then the versions list is returned");110 });111 });112 });113 QUnit.module("Calling the Storage: Given Versions.activateDraft is called", {114 beforeEach: function () {115 sandbox.stub(sap.ui.getCore().getConfiguration(), "getFlexibilityServices").returns([116 {connector : "KeyUserConnector", layers : ["CUSTOMER"], url: "/flexKeyUser"}117 ]);118 },119 afterEach: function() {120 Versions.clearInstances();121 sandbox.restore();122 }123 }, function() {124 QUnit.test("and a connector is configured which returns a list of versions while a draft exists", function (assert) {125 var sReference = "com.sap.app";126 var mPropertyBag = {127 layer : "CUSTOMER",128 reference : sReference129 };130 var oFirstVersion = {131 activatedBy : "qunit",132 activatedAt : "a while ago",133 versionNumber : 1134 };135 var aReturnedVersions = [136 oFirstVersion,137 {versionNumber : 0}138 ];139 sandbox.stub(Storage.versions, "load").resolves(aReturnedVersions);140 var oChangePersistence = ChangePersistenceFactory.getChangePersistenceForComponent(sReference);141 sandbox.stub(oChangePersistence, "getDirtyChanges").returns([]);142 var oSaveStub = sandbox.stub(oChangePersistence, "saveDirtyChanges").resolves();143 var oActivatedVersion = {144 activatedBy : "qunit",145 activatedAt : "just now",146 versionNumber : 2147 };148 sandbox.stub(KeyUserConnector.versions, "activateDraft").resolves(oActivatedVersion);149 return Versions.activateDraft(mPropertyBag)150 .then(function (oResponse) {151 assert.equal(oSaveStub.callCount, 0, "no save changes was called");152 assert.equal(Array.isArray(oResponse), true, "then the versions list is returned");153 assert.equal(oResponse.length, 2, "with two versions");154 assert.equal(oResponse[0], oFirstVersion, "where the older version is the first");155 assert.equal(oResponse[1], oActivatedVersion, "and the newly activated is the second");156 })157 .then(Versions.getVersions.bind(Versions, mPropertyBag))158 .then(function (aVersions) {159 assert.equal(aVersions.length, 2, "and a getting the versions anew will return two versions");160 assert.equal(aVersions[0], oFirstVersion, "where the older version is the first");161 assert.equal(aVersions[1], oActivatedVersion, "and the newly activated is the second");162 });163 });164 QUnit.test("and a connector is configured which returns a list of versions while a draft does NOT exists", function (assert) {165 var sReference = "com.sap.app";166 var mPropertyBag = {167 layer : "CUSTOMER",168 reference : sReference169 };170 var oFirstVersion = {171 activatedBy: "qunit",172 activatedAt: "a while ago",173 versionNumber: 1174 };175 var aReturnedVersions = [176 oFirstVersion177 ];178 var oChangePersistence = ChangePersistenceFactory.getChangePersistenceForComponent(sReference);179 sandbox.stub(oChangePersistence, "getDirtyChanges").returns([]);180 var oSaveStub = sandbox.stub(oChangePersistence, "saveDirtyChanges").resolves();181 sandbox.stub(Storage.versions, "load").resolves(aReturnedVersions);182 var oActivatedVersion = {183 activatedBy: "qunit",184 activatedAt: "just now",185 versionNumber: 2186 };187 sandbox.stub(KeyUserConnector.versions, "activateDraft").resolves(oActivatedVersion);188 return Versions.activateDraft(mPropertyBag).catch(function (sErrorMessage) {189 assert.equal(oSaveStub.callCount, 0, "no save changes was called");190 assert.equal(sErrorMessage, "No draft exists", "then the promise is rejected with an error message");191 });192 });193 QUnit.test("and a connector is configured which returns a list of versions while a draft does NOT exists but dirty changes do", function (assert) {194 var sReference = "com.sap.app";195 var mPropertyBag = {196 layer : "CUSTOMER",197 reference : sReference198 };199 var oFirstVersion = {200 activatedBy: "qunit",201 activatedAt: "a while ago",202 versionNumber: 1203 };204 var aReturnedVersions = [205 oFirstVersion206 ];207 sandbox.stub(Storage.versions, "load").resolves(aReturnedVersions);208 var oChangePersistence = ChangePersistenceFactory.getChangePersistenceForComponent(sReference);209 sandbox.stub(oChangePersistence, "getDirtyChanges").returns([{}]);210 var oSaveStub = sandbox.stub(oChangePersistence, "saveDirtyChanges").resolves();211 var oActivatedVersion = {212 activatedBy: "qunit",213 activatedAt: "just now",214 versionNumber: 2215 };216 sandbox.stub(KeyUserConnector.versions, "activateDraft").resolves(oActivatedVersion);217 return Versions.activateDraft(mPropertyBag)218 .then(function (oResponse) {219 assert.equal(oSaveStub.callCount, 1, "the changes were saved");220 var aSaveCallArgs = oSaveStub.getCall(0).args;221 assert.equal(aSaveCallArgs[0], false, "the caching update should not be skipped");222 assert.equal(aSaveCallArgs[1], undefined, "no list of changes is passed");223 assert.equal(aSaveCallArgs[2], true, "the draft flag is set");224 assert.equal(Array.isArray(oResponse), true, "then the versions list is returned");225 assert.equal(oResponse.length, 2, "with two versions");226 assert.equal(oResponse[0], oFirstVersion, "where the older version is the first");227 assert.equal(oResponse[1], oActivatedVersion, "and the newly activated is the second");228 })229 .then(Versions.getVersions.bind(Versions, mPropertyBag))230 .then(function (aVersions) {231 assert.equal(aVersions.length, 2, "and a getting the versions anew will return two versions");232 assert.equal(aVersions[0], oFirstVersion, "where the older version is the first");233 assert.equal(aVersions[1], oActivatedVersion, "and the newly activated is the second");234 });235 });236 });237 QUnit.done(function () {238 jQuery('#qunit-fixture').hide();239 });...

Full Screen

Full Screen

poetry.piggy.js

Source:poetry.piggy.js Github

copy

Full Screen

1function initWords(){2 getWords();3}4function initUI(){5 //add behaviour to the sidebar panels6 $$('div.sb_block').each(7 function(el){8 var titles=el.select("div.sb_title");9 var bodies=el.select("div.sb_body");10 if (titles[0] && bodies[0]){11 var bod=bodies[0];12 titles[0].observe("click",13 function(){ bod.toggle(); }14 );15 } 16 } 17 );18}19function initDragDrop(){20 //set listener on dragging, to update note positions21 Draggables.addObserver(22 { onStart:function(evName,draggable,event){23 draggable.startPos={ 24 x: event.clientX, 25 y: event.clientY 26 };27 },28 onEnd:function(evName,draggable,event){29 var el=draggable.element;30 if (el.hasClassName('note') && el.word){31 if (!el.word.pendingDeletion){32 var startPos=draggable.startPos;33 var dx=event.clientX-startPos.x;34 var dy=event.clientY-startPos.y;35 el.word.update(dx,dy);36 }37 }38 draggable.startPos=null;39 }40 }41 );42 //activate the trashcan43 Droppables.add(44 'trash',45 { onHover:function(el,trash){46 x=3;47 },48 onDrop: function(el, trash){49 if (el.hasClassName('note') && el.word){50 el.word.deleteMe();51 }52 }53 }54 );55}56var poll={57 timer:null,58 interval:3,59 run:function(){60 this.stop();61 this.timer=setTimeout(62 function(){ getWords(); }.bind(this),63 this.interval*100064 ); 65 },66 stop:function(){67 if (this.timer){68 clearTimeout(this.timer);69 }70 }71};72var callback=function(response){73 var results=response.responseJSON.results;74 results.each(75 function(result){ 76 if (Words["_"+result.id]){77 var word=Words["_"+result.id];78 if (result.deleted){79 word.deleteUI();80 }else{81 word.updateUI(result.x,result.y,result.version);82 }83 }else{84 new Word(result);85 } 86 }87 );88 poll.run();89}90var getVersions=function(){91 return $H(Words).collect(92 function(pair){ 93 var word=pair.value;94 return word.id+"="+word.version;95 }96 ).join(" ");97}98function getWords(){99 poll.stop();100 new Ajax.Request(101 "piggy/read",102 { evalJSON: "force",103 parameters: { "versions": getVersions() },104 onSuccess: callback105 }106 );107}108function addWord(){109 poll.stop();110 var text=$F('word_text');111 var color=$F('word_color');112 var x=Math.floor(Math.random()*350); 113 var y=Math.floor(Math.random()*420); 114 var paramsObj={ text:text, color:color, x:x, y:y, versions: getVersions() };115 new Ajax.Request(116 "piggy/create",117 { parameters: paramsObj,118 evalJSON:"force",119 onSuccess:callback120 }121 );122}123var Words={};124var Word=Class.create({125 initialize:function(props){126 Object.extend(this,props);127 Words["_"+this.id]=this;128 this.render();129 },130 render:function(){131 var tmpl="<div id='note_#{id}' class='note' "132 +"style='top:#{y}px;left:#{x}px;background-color:#{color}'>"133 +"#{text}</div>";134 var html=tmpl.interpolate(this)135 $("board").insert({top:html});136 this.body=$("note_"+this.id);137 this.body.word=this;138 new Draggable(this.body);139 },140 update:function(dx,dy){141 poll.stop();142 this.x=parseInt(this.x)+dx;143 this.y=parseInt(this.y)+dy;144 var params={145 id: this.id,146 x: this.x,147 y: this.y,148 versions: getVersions()149 };150 new Ajax.Request(151 "piggy/update",152 { parameters: params,153 evalJSON: "force",154 onSuccess:callback155 }156 );157 },158 updateUI:function(x,y,version){159 this.x=x;160 this.y=y;161 if (version){ this.version=version; }162 this.body.setStyle({163 "left":x+"px","top":y+"px"164 });165 },166 deleteMe:function(){167 poll.stop();168 this.pendingDeletion=true;169 new Ajax.Request(170 "piggy/delete",171 { parameters: { id: this.id, versions:getVersions() },172 evalJSON: "force",173 onSuccess: callback174 }175 );176 },177 deleteUI:function(){178 this.body.style.zIndex=3;179 new Effect.Puff(this.body);180 Words["_"+this.attr.id]=null;181 }...

Full Screen

Full Screen

gulpfile.babel.js

Source:gulpfile.babel.js Github

copy

Full Screen

1import fs from 'fs'2import _ from 'lodash'3import gulp from 'gulp'4import twig from 'gulp-twig'5import all from 'gulp-all'6import rename from 'gulp-rename'7import sass from 'gulp-sass'8import autoprefixer from 'gulp-autoprefixer'9import concat from 'gulp-concat'10import header from 'gulp-header'11import cleanCss from 'gulp-clean-css'12import ghPages from 'gulp-gh-pages'13gulp.task('default', ['sass'])14gulp.task('gh-build', ['gh:copy-assets', 'gh:twig-other', 'gh:twig-library'])15/* font */16gulp.task('sass', function () {17 let subtasks = [];18 let versions = getVersions()19 let latest = _.head(versions)20 let license = "/*!\n* XEIcon <%= version %> by @NAVER - http://xpressengine.github.io/XEIcon/ - @XEIcon\n* License - http://xpressengine.github.io/XEIcon/license.html (Font: SIL OFL 1.1, CSS: MIT License)\n*/\n\n"21 return gulp.src(['./src/versions/' + latest + '/style.css', './src/sass/xeicon.scss'])22 .pipe(sass({outputStyle: 'expanded'}))23 .pipe(autoprefixer())24 .pipe(concat('xeicon.css'))25 .pipe(header(license, {version : latest }))26 .pipe(gulp.dest('./'))27 .pipe(rename({suffix: '.min'}))28 .pipe(cleanCss({29 compatibility: 'ie9'30 }))31 .pipe(gulp.dest('./'))32});33gulp.task('gh:deploy', function() {34 return gulp.src('./dist/**/*')35 .pipe(ghPages());36});37/* gh-pages */38gulp.task('gh:copy-assets', function() {39 return gulp.src('./src/template/assets/**/*')40 .pipe(gulp.dest('./dist/assets'))41})42gulp.task('gh:twig-other', function () {43 'use strict';44 let versions = getVersions()45 return gulp.src(['./src/template/*.twig', '!**/library.twig'])46 .pipe(twig({47 data: {48 title: 'XEIcon, 문자를 그리다',49 versions: versions50 }51 }))52 .pipe(gulp.dest('./dist'));53});54gulp.task('gh:twig-library', function () {55 'use strict';56 let versions = getVersions()57 let subtasks = versions.map(function(version){58 let selection = getIcons(version)59 return gulp.src('./src/template/library.twig')60 .pipe(twig({61 data: {62 title: 'XEIcon, 문자를 그리다',63 versions: versions,64 version: selection.version,65 categories: selection.categories,66 icons: selection.icons67 }68 }))69 .pipe(rename({70 suffix: "-" + version71 }))72 .pipe(gulp.dest('./dist'));73 })74 return all(subtasks)75});76function getIcons(version) {77 let icons = []78 let result = {79 "version": null,80 "categories": [],81 "icons": null82 }83 let selection = JSON.parse(fs.readFileSync('./src/versions/' + version + '/selection.json').toString()).icons84 // icon을 카테고리별로 분류85 selection.map(function(item, idx) {86 let icon = {}87 let name = _.map(item.properties.name.split(','), _.trim)88 // 필요한 데이터만 선별, 정리89 icon.name = _.head(name)90 icon.alias = _.slice(name, 1)91 icon.category = _.head(item.icon.tags)92 icon.order = item.iconIdx93 icon.code = item.properties.code94 icon.hex = item.properties.code.toString(16)95 icon.keyword = _.uniq(_.concat(name, _.slice(item.icon.tags, 1)))96 icons.push(icon);97 })98 result.version = version99 result.icons = _.groupBy(icons, 'category')100 result.categories = _.keys(result.icons)101 return result;102}103function getVersions() {104 let dirs = fs.readdirSync('./src/versions');105 let versions = [];106 dirs.map(function(ver) {107 if(fs.existsSync('./src/versions/' + ver + '/selection.json')) {108 versions.push(ver)109 }110 })111 return _.reverse(versions)...

Full Screen

Full Screen

get-versions-test.js

Source:get-versions-test.js Github

copy

Full Screen

1const td = require('testdouble');2const expect = require('../../helpers/expect');3const path = require('path');4const mockProject = require('../../fixtures/corber-mock/project');5const root = mockProject.project.root;6const projectPackagePath = path.join(root, 'package.json');7const projectCorberPackagePath = path.join(8 root,9 'node_modules',10 'corber',11 'package.json'12);13const globalCorberPackagePath = path.resolve(14 __dirname,15 '..',16 '..',17 '..',18 'package.json'19);20describe('getVersions', () => {21 let getPackage, fsUtils;22 let getVersions;23 beforeEach(() => {24 getPackage = td.replace('../../../lib/utils/get-package');25 fsUtils = td.replace('../../../lib/utils/fs-utils');26 getVersions = require('../../../lib/utils/get-versions');27 td.when(getPackage(globalCorberPackagePath)).thenReturn({28 version: '1.0.0'29 });30 td.when(getPackage(projectPackagePath)).thenReturn({31 devDependencies: {32 corber: '~1.2.3'33 }34 });35 td.when(getPackage(projectCorberPackagePath)).thenReturn({36 version: '1.2.5'37 })38 td.when(fsUtils.existsSync(globalCorberPackagePath)).thenReturn(true);39 td.when(fsUtils.existsSync(projectPackagePath)).thenReturn(true);40 td.when(fsUtils.existsSync(projectCorberPackagePath)).thenReturn(true);41 });42 afterEach(() => {43 td.reset();44 });45 it('reads global corber version', () => {46 let versions = getVersions(root);47 expect(versions.corber.global).to.equal('1.0.0');48 });49 it('reads ./node_modules/corber/package.json version', () => {50 let versions = getVersions(root);51 expect(versions.corber.project.installed).to.equal('1.2.5');52 });53 it('reads ./package.json corber version', () => {54 let versions = getVersions(root);55 expect(versions.corber.project.required).to.equal('~1.2.3');56 });57 it('reads node version', () => {58 let versions = getVersions(root);59 expect(versions.node).to.equal(process.versions.node);60 });61 context('when project package.json does not exist', () => {62 beforeEach(() => {63 td.when(fsUtils.existsSync(projectPackagePath)).thenReturn(false);64 });65 it('does not contain a required version', () => {66 let versions = getVersions(root);67 expect(versions.corber.project.required).to.be.undefined;68 });69 it('does not contain an installed version', () => {70 let versions = getVersions(root);71 expect(versions.corber.project.installed).to.be.undefined;72 });73 });74 context('when ./node_modules/corber/package.json does not exist', () => {75 beforeEach(() => {76 td.when(fsUtils.existsSync(projectCorberPackagePath)).thenReturn(false);77 });78 it('does not contain an installed version', () => {79 let versions = getVersions(root);80 expect(versions.corber.project.installed).to.be.undefined;81 });82 });83 context('when corber belongs to package.json dependencies', () => {84 beforeEach(() => {85 td.when(getPackage(projectPackagePath)).thenReturn({86 dependencies: {87 corber: '~1.2.3'88 }89 });90 });91 it('returns the correct required version', () => {92 let versions = getVersions(root);93 expect(versions.corber.project.required).to.equal('~1.2.3');94 })95 });...

Full Screen

Full Screen

GetVersions.js

Source:GetVersions.js Github

copy

Full Screen

1/**2 * @typedef {ITHit.WebDAV.Client.WebDavSession} webDavSession3 */4QUnit.module('Versions.GetVersions');5/**6 * @class ITHit.WebDAV.Client.Tests.Versions.GetVersions7 */8ITHit.DefineClass('ITHit.WebDAV.Client.Tests.Versions.GetVersions', null, {}, /** @lends ITHit.WebDAV.Client.Tests.Versions.GetVersions */{9 /**10 * @param {ITHit.WebDAV.Client.WebDavSession} [webDavSession=new ITHit.WebDAV.Client.WebDavSession()]11 * @param {string} [sFolderAbsolutePath='http://localhost:87654/myfile.txt']12 * @param {function} [fCallback=function() {}]13 */14 GetVersions: function(webDavSession, sFolderAbsolutePath, fCallback) {15 webDavSession.OpenFileAsync(sFolderAbsolutePath, null, function(oFileAsyncResult) {16 /** @typedef {ITHit.WebDAV.Client.File} oFile */17 var oFile = oFileAsyncResult.Result;18 oFile.GetVersionsAsync(function(oAsyncResult) {19 /** @typedef {ITHit.WebDAV.Client.Version[]} aVersions */20 var aVersions = oAsyncResult.Result;21 for (var i = 0, l = aVersions.length; i < l; i++) {22 var oVersion = aVersions[i];23 console.log([24 'Version Name: ' + oVersion.VersionName,25 'Comment: ' + oVersion.Comment,26 'Author: ' + oVersion.CreatorDisplayName,27 'Created: ' + oVersion.CreationDate28 ].join('\n'));29 }30 fCallback(oAsyncResult);31 });32 });33 }34});35QUnitRunner.test('Get file versions list', function (test) {36 QUnit.stop();37 Helper.Create([38 'Versions/ver.txt'39 ], function() {40 QUnit.start();41 QUnit.stop();42 webDavSession.OpenFileAsync(Helper.GetAbsolutePath('Versions/ver.txt'), null, function(oAsyncResult) {43 QUnit.start();44 /** @typedef {ITHit.WebDAV.Client.File} oFile */45 var oFile = oAsyncResult.Result;46 QUnit.stop();47 Helper.CheckVersionsSupported(oFile, function(bIsVersionSupported) {48 QUnit.start();49 if (!bIsVersionSupported) {50 ITHitTests.skip(test, 'Server does not support versions.');51 return;52 }53 test.strictEqual(oAsyncResult.IsSuccess, true, 'Check success of open item request');54 test.strictEqual(oFile instanceof ITHit.WebDAV.Client.HierarchyItem, true, 'Check result is instance of HierarchyItem');55 QUnit.stop();56 ITHit.WebDAV.Client.Tests.Versions.GetVersions.GetVersions(webDavSession, Helper.GetAbsolutePath('Versions/ver.txt'), function(oAsyncResult) {57 QUnit.start();58 var oVersion = oAsyncResult.Result[0];59 test.strictEqual(oAsyncResult.IsSuccess, true, 'Check success of get versions request');60 test.strictEqual(oVersion instanceof ITHit.WebDAV.Client.Version, true, 'Check result item is instance of Version');61 });62 });63 });64 });...

Full Screen

Full Screen

versions_spec.js

Source:versions_spec.js Github

copy

Full Screen

...15 sinon.stub(util, 'pkgVersion').returns('4.5.6')16 })17 describe('.getVersions', function () {18 it('gets the correct binary and package version', function () {19 return versions.getVersions().then(({ package, binary }) => {20 expect(package, 'package version').to.eql('4.5.6')21 expect(binary, 'binary version').to.eql('1.2.3')22 })23 })24 it('gets the correct Electron and bundled Node version', function () {25 return versions.getVersions().then(({ electronVersion, electronNodeVersion }) => {26 expect(electronVersion, 'electron version').to.eql('10.1.2')27 expect(electronNodeVersion, 'node version').to.eql('12.16.3')28 })29 })30 it('gets correct binary version if CYPRESS_RUN_BINARY', function () {31 sinon.stub(state, 'parseRealPlatformBinaryFolderAsync').resolves('/my/cypress/path')32 process.env.CYPRESS_RUN_BINARY = '/my/cypress/path'33 state.getBinaryPkgAsync34 .withArgs('/my/cypress/path')35 .resolves({36 version: '7.8.9',37 })38 return versions.getVersions().then(({ package, binary }) => {39 expect(package).to.eql('4.5.6')40 expect(binary).to.eql('7.8.9')41 })42 })43 it('reports default versions if not found', function () {44 // imagine package.json only has version there45 state.getBinaryPkgAsync.withArgs(binaryDir).resolves({46 version: '90.9.9',47 })48 return versions.getVersions().then((versions) => {49 expect(versions).to.deep.equal({50 'package': '4.5.6',51 'binary': '90.9.9',52 'electronVersion': 'not found',53 'electronNodeVersion': 'not found',54 })55 })56 })57 })...

Full Screen

Full Screen

versionsBlock.js

Source:versionsBlock.js Github

copy

Full Screen

1import { whitespace, beginningOfStringOrNewline, newline, newlineCharacters } from './regexes.js'2const blockItem = `${newline}+${whitespace}*\\- (?<name>[^:]+): (?<version>[^ ${newlineCharacters}]+)(?<locked> \\(locked\\))?`3const blockItems = `(${blockItem})+`4const versionBlockRegex = `${beginningOfStringOrNewline}(?<block>#* ?\\*{0,2}versions:?\\*{0,2}:?${blockItems})`5const getVersionsBlock = (body) => {6 const blockMatch = body.match(new RegExp(versionBlockRegex, 'i'))7 return blockMatch && blockMatch.groups.block8}9export const getVersions = (body, filter = () => true) => {10 const versionsText = getVersionsBlock(body)11 if (!versionsText) {12 return null13 }14 return versionsText.match(new RegExp(blockItem, 'gi'))15 .map(itemText => {16 const { groups } = itemText.match(new RegExp(blockItem, 'i'))17 return { ...groups, locked: !!groups.locked }18 })19 .filter(filter)20 .reduce((result, item) => ({ ...result, [item.name]: item.version }), {})21}22export const getVersion = (body, itemName) => {23 const versions = getVersions(body)24 /* istanbul ignore if */25 if (!versions) {26 return null27 }28 return versions[itemName]29}30export const setVersions = (body, versions) => {31 const lockedVersions = getVersions(body, item => item.locked) || {}32 const newVersions = { ...versions, ...lockedVersions }33 const versionsText = getVersionsBlock(body)34 const itemsText = versionsText && versionsText.match(new RegExp(blockItems, 'i'))[0]35 const newItemsText = Object.entries(newVersions).reduce((result, [name, version]) =>36 result + `\n- ${name}: ${version}${name in lockedVersions ? ' (locked)' : ''}`37 , '')38 return itemsText39 ? body.replace(itemsText, newItemsText)40 : body + '\n\nversions:' + newItemsText41}42export const setVersion = (body, itemName, version) => {43 const versions = getVersions(body) || {}44 return setVersions(body, {45 ...versions,46 [itemName]: version47 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1const getVersions = require('../packages/kronos-get-versions/getVersions')2const generate = require('../packages/kronos-generate/generate')3const generateModel = require('../packages/kronos-generate-model/generateModel')4const checkHasPermissions = require('../packages/kronos-check-has-permissions/checkHasPermissions')5const kronos = {}6kronos.generate = generate7kronos.getVersions = getVersions8kronos.generateModel = generateModel9kronos.checkHasPermissions = checkHasPermissions...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const versions = require('cypress/lib/tasks/versions');2versions.getVersions().then((versions) => {3 console.log(versions);4});5{6 "scripts": {7 },8 "devDependencies": {9 }10}11{12 { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '89.0.4389.114', path: 'C:\\Users\\user\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe', majorVersion: 89 },13 { name: 'chromium', family: 'chromium', channel: 'stable', displayName: 'Chromium', version: '89.0.4389.114', path: 'C:\\Program Files (x86)\\Chromium\\Application\\chrome.exe', majorVersion: 89 },14 { name: 'edge', family: 'chromium', channel: 'stable', displayName: 'Edge', version: '89.0.774.68', path: 'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe', majorVersion: 89 },15 { name: 'firefox', family: 'firefox', channel: 'stable', displayName: 'Firefox', version: '86.0.1', path: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe', majorVersion: 86 },16 { name: 'firefoxdeveloperedition', family: 'firefox', channel: 'stable', displayName: 'Firefox Developer Edition', version: '87.0b9', path: 'C:\\Program Files\\Firefox Developer Edition\\firefox.exe', majorVersion: 87 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1const cypress = require('cypress');2cypress.versions.getVersions().then((versions) => {3 console.log(versions);4});5{6 {7 },8 {9 }10}11const cypress = require('cypress');12cypress.versions.getVersions().then((versions) => {13 const browsers = versions.browsers;14 browsers.forEach((browser) => {15 cypress.run({16 });17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1const versions = require('cypress-versions');2versions.getVersions().then(versions => {3 console.log(versions);4});5{6}7const versions = require('cypress-versions');8module.exports = (on, config) => {9 on('task', {10 getVersions() {11 return versions.getVersions();12 }13 });14};15const versions = require('cypress-versions');16Cypress.Commands.add('getVersions', () => {17 cy.task('getVersions').then(versions => {18 return versions;19 });20});21describe('Test', () => {22 it('Test', () => {23 cy.getVersions().then(versions => {24 console.log(versions);25 });26 });27});28{29}30Cypress versions.getVersions() method31Cypress versions.getVersions() method returns the version of the browser and cypress that is currently running. It returns the following properties:32Cypress versions.getVersions() method example33describe('Test', () => {34 it('Test', () => {35 cy.getVersions().then(versions => {36 expect(versions.cypress).to.be.a('string');

Full Screen

Using AI Code Generation

copy

Full Screen

1const versions = require('cypress/lib/tasks/versions')2versions.getVersions().then((versions) => {3 console.log(versions)4})5const versions = require('cypress/lib/tasks/versions')6const fs = require('fs')7const path = require('path')8const versionFile = path.join(__dirname, 'versions.json')9const versions = versions.getVersions()10fs.writeFileSync(versionFile, JSON.stringify(versions, null, 2), 'utf8')11const versions = require('cypress/lib/tasks/versions')12module.exports = (on, config) => {13 on('task', {14 versions() {15 return versions.getVersions()16 },17 })18}19describe('test', () => {20 it('test', () => {21 cy.task('versions').then((versions) => {22 })23 })24})25describe('test', () => {26 it('test', () => {27 cy.exec('npx cypress versions').then((result) => {28 })29 })30})31describe('test', () => {32 it('test', () => {33 cy.exec('npx cypress info --json').then((result) => {34 })35 })36})37describe('test', () => {38 it('test', () => {39 cy.exec('npx cypress version').then((result) => {40 })41 })42})43describe('test', () => {44 it('test', () => {45 cy.exec('npx cypress cache path').then((result) => {46 })47 })48})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('getVersions', () => {2 return cy.request({3 })4})5describe('Test', () => {6 it('should get versions', () => {7 cy.getVersions().then((response) => {8 expect(response.status).to.eq(200)9 expect(response.body).to.have.property('versions')10 })11 })12})13import './commands'

Full Screen

Using AI Code Generation

copy

Full Screen

1const versions = require('cypress/versions')2versions.getVersions().then((versions) => {3 console.log(versions)4})5{6 "env": {7 }8}9{10 "scripts": {11 }12}13const versions = require('cypress/versions')14versions.getVersions().then((versions) => {15 console.log(versions)16 console.log(Cypress.env("versions"))17})18const versions = require('cypress/versions')19versions.getVersions().then((versions) => {20 console.log(versions)21 console.log(Cypress.env("versions"))22})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.versions().then((versions) => {2 console.log(versions);3});4{5}6Cypress.versions() method will return an object with the following properties:7Cypress.versions() method is available in the following versions of Cypress:

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