How to use fs.mv method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

fsCache.js

Source:fsCache.js Github

copy

Full Screen

1/*2 *3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 *20 */21describe("fsCache", function () {22 var fs = ripple('platform/webworks.core/2.0.0/fs'),23 event = ripple('event'),24 FileProperties = ripple('platform/webworks.core/2.0.0/client/FileProperties'),25 bbUtils = ripple('platform/webworks.core/2.0.0/client/utils'),26 cache = ripple('platform/webworks.core/2.0.0/fsCache'),27 _root = [{28 fullPath: "/dude",29 name: "dude",30 isDirectory: false,31 file: function (success) {32 success({33 lastModifiedDate: new Date(456),34 size: 20,35 type: "text/plain"36 });37 }38 }, {39 fullPath: "/dudeDir",40 name: "dudeDir",41 isDirectory: true42 }, {43 fullPath: "/hungry.js",44 name: "hungry.js",45 isDirectory: false,46 file: function (success) {47 success({48 lastModifiedDate: new Date(123),49 size: 50,50 type: "application/x-javascript"51 });52 }53 }, {54 fullPath: "/hippo",55 name: "hippo",56 isDirectory: true57 }];58 beforeEach(function () {59 spyOn(fs, "read");60 spyOn(fs, "ls").andCallFake(function (path, success) {61 success(path === "/" ? _root : []);62 });63 cache.refresh();64 });65 // TODO: cache (get,set,delete) layer is not under test66 it("calls refresh on WebWorksFileSystemInitialized", function () {67 spyOn(cache, "refresh");68 spyOn(fs, "mkdir").andCallFake(function (path, success) {69 success();70 });71 event.trigger("WebWorksFileSystemInitialized", null, true);72 expect(cache.refresh).toHaveBeenCalled();73 });74 describe("io.file", function () {75 describe("exists", function () {76 it("returns true when the file exists", function () {77 spyOn(fs, "stat");78 expect(cache.file.exists("/hungry.js")).toBe(true);79 });80 it("returns false when when given a directory", function () {81 spyOn(fs, "stat");82 expect(cache.file.exists("/dudeDir")).toBe(false);83 });84 });85 describe("deleteFile", function () {86 it("removes a file", function () {87 spyOn(fs, "rm");88 cache.file.deleteFile("/hungry.js");89 expect(fs.rm.argsForCall[0][0]).toBe("/hungry.js");90 expect(typeof fs.rm.argsForCall[0][1]).toBe("function");91 expect(typeof fs.rm.argsForCall[0][2]).toBe("function");92 });93 });94 describe("copy", function () {95 it("copies the file at the specified path", function () {96 spyOn(fs, "cp");97 cache.file.copy("/hungry.js", "/hungrier");98 expect(fs.cp.argsForCall[0][0]).toBe("/hungry.js");99 expect(fs.cp.argsForCall[0][1]).toBe("/hungrier");100 expect(typeof fs.cp.argsForCall[0][2]).toBe("function");101 expect(typeof fs.cp.argsForCall[0][3]).toBe("function");102 });103 });104 describe("getFileProperties", function () {105 it("returns an object of file properties", function () {106 spyOn(fs, "stat");107 var result = cache.file.getFileProperties("/hungry.js");108 expect(result.dateModified).toEqual(new Date(123));109 expect(result.dateCreated).toEqual(new Date(123));110 expect(result.directory).toEqual("/");111 expect(result.fileExtension).toEqual("js");112 expect(result.isHidden).toEqual(false);113 expect(result.isReadonly).toEqual(false);114 expect(result.mimeType).toEqual("application/x-javascript");115 expect(result.size).toEqual(50);116 expect(result instanceof FileProperties).toBe(true);117 });118 });119 describe("rename", function () {120 it("renames a file", function () {121 spyOn(cache.dir, "rename");122 cache.file.rename("/hungry.js", "hungryhungry.js");123 expect(cache.dir.rename).toHaveBeenCalledWith("/hungry.js", "hungryhungry.js");124 });125 });126 });127 describe("io.dir", function () {128 describe("createNewDir", function () {129 it("creates a directory", function () {130 spyOn(fs, "mkdir");131 cache.dir.createNewDir("/test");132 expect(fs.mkdir.argsForCall[0][0]).toBe("/test");133 expect(typeof fs.mkdir.argsForCall[0][1]).toBe("function");134 expect(typeof fs.mkdir.argsForCall[0][2]).toBe("function");135 });136 });137 describe("createNewDir", function () {138 it("creates a directory with a trailing slash", function () {139 spyOn(fs, "mkdir");140 cache.dir.createNewDir("/foo");141 expect(fs.mkdir.argsForCall[0][0]).toBe("/foo");142 expect(typeof fs.mkdir.argsForCall[0][1]).toBe("function");143 expect(typeof fs.mkdir.argsForCall[0][2]).toBe("function");144 });145 });146 describe("deleteDirectory", function () {147 it("removes a directory", function () {148 spyOn(fs, "rmdir");149 cache.dir.deleteDirectory("/dudeDir");150 expect(fs.rmdir.argsForCall[0][0]).toBe("/dudeDir");151 expect(typeof fs.rmdir.argsForCall[0][1]).toBe("function");152 expect(typeof fs.rmdir.argsForCall[0][2]).toBe("function");153 });154 it("removes a directory recursively", function () {155 spyOn(fs, "rm");156 cache.dir.deleteDirectory("/dudeDir", true);157 expect(fs.rm.argsForCall[0][0]).toBe("/dudeDir");158 expect(typeof fs.rm.argsForCall[0][1]).toBe("function");159 expect(typeof fs.rm.argsForCall[0][2]).toBe("function");160 expect(fs.rm.argsForCall[0][3]).toEqual({recursive: true});161 });162 });163 describe("exists", function () {164 it("returns true when the directory exists", function () {165 spyOn(fs, "stat");166 expect(cache.dir.exists("/dudeDir")).toBe(true);167 });168 it("returns false when given a file", function () {169 spyOn(fs, "stat");170 expect(cache.dir.exists("/hungry.js")).toBe(false);171 });172 it("returns true when the directory exists", function () {173 spyOn(fs, "stat");174 expect(cache.dir.exists("/dudeDir")).toBe(true);175 });176 });177 describe("getParentDirectory", function () {178 it("returns the path to the parent directory", function () {179 expect(cache.dir.getParentDirectory("/dudeDir")).toBe("/");180 });181 });182 describe("listDirectories", function () {183 it("returns an array of all directories in a path", function () {184 expect(cache.dir.listDirectories("/")).toEqual(["dudeDir", "hippo"]);185 expect(fs.ls.argsForCall[0][0]).toBe("/");186 expect(typeof fs.ls.argsForCall[0][1]).toBe("function");187 expect(typeof fs.ls.argsForCall[0][2]).toBe("function");188 });189 });190 describe("listFiles", function () {191 it("returns an array of all files in a path", function () {192 expect(cache.dir.listFiles("/")).toEqual(["dude", "hungry.js"]);193 expect(fs.ls.argsForCall[0][0]).toBe("/");194 expect(typeof fs.ls.argsForCall[0][1]).toBe("function");195 expect(typeof fs.ls.argsForCall[0][2]).toBe("function");196 });197 });198 describe("rename", function () {199 it("renames a directory at the specified path", function () {200 spyOn(fs, "mv");201 cache.dir.rename("/dudeDir", "theDudeDir");202 expect(fs.mv.argsForCall[0][0]).toBe("/dudeDir");203 expect(fs.mv.argsForCall[0][1]).toBe("/theDudeDir");204 expect(typeof fs.mv.argsForCall[0][2]).toBe("function");205 expect(typeof fs.mv.argsForCall[0][3]).toBe("function");206 });207 });208 describe("getRootDirs", function () {209 it("returns an array of top level directories", function () {210 spyOn(cache.dir, "listDirectories").andReturn(["foo"]);211 expect(cache.dir.getRootDirs()).toEqual(["foo"]);212 expect(cache.dir.listDirectories).toHaveBeenCalledWith("/");213 });214 });215 });216 describe("readFile", function () {217 it("asynchronously reads data from a file", function () {218 var blob = {size: 5},219 path = "/hungry.js",220 success = jasmine.createSpy();221 fs.read.reset();222 fs.read.andCallFake(function (path, success) {223 setTimeout(function () {224 success(blob);225 }, 1);226 });227 spyOn(bbUtils, "stringToBlob").andReturn(blob);228 cache.file.readFile(path, success, true);229 waits(1);230 runs(function () {231 expect(success).toHaveBeenCalledWith(blob);232 expect(fs.read.argsForCall[0][0]).toBe(path);233 expect(typeof fs.read.argsForCall[0][1]).toBe("function");234 expect(typeof fs.read.argsForCall[0][2]).toBe("function");235 });236 });237 it("synchronously reads data from a file", function () {238 var blob = {size: 5},239 path = "/hungry.js",240 success = jasmine.createSpy();241 fs.read.reset();242 spyOn(bbUtils, "stringToBlob").andReturn(blob);243 cache.file.readFile(path, success, false);244 expect(success).toHaveBeenCalledWith(blob);245 });246 });247 describe("saveFile", function () {248 it("asynchronously writes data to a file", function () {249 var blob = {size: 5},250 path = "/hungry.js";251 spyOn(fs, "write");252 spyOn(bbUtils, "blobToString").andReturn("contents");253 cache.file.saveFile(path, blob);254 expect(fs.write.argsForCall[0][0]).toBe(path);255 expect(fs.write.argsForCall[0][1]).toBe("contents");256 expect(typeof fs.write.argsForCall[0][2]).toBe("function");257 expect(typeof fs.write.argsForCall[0][3]).toBe("function");258 });259 });...

Full Screen

Full Screen

functions.js

Source:functions.js Github

copy

Full Screen

...75 );76 await RNFetchBlob.fs.unlink(77 newPath + `/.temp/${id}audio.${audioExtention}`,78 );79 await RNFetchBlob.fs.mv(newPath + id + '.mp4', pathWithTitle);80 //81 if (type === 'single') {82 await dispatch({83 type: 'PROGRESS',84 progress: 100,85 vid: id,86 downloaded: true,87 path: pathWithTitle,88 vidtype: type,89 });90 } else {91 if (index != totalVidInList) {92 await dispatch({93 type: 'PROGRESS',94 progress: 0,95 vid: playlistId,96 path: '',97 vidtype: type,98 });99 } else {100 await dispatch({101 type: 'PROGRESS',102 progress: 100,103 vid: playlistId,104 path: `${RNFetchBlob.fs.dirs.SDCardDir}/AYTD/${pltittle}`,105 downloaded: true,106 complete: totalVidInList + '/' + totalVidInList,107 vidtype: type,108 });109 }110 }111 Toast.show(`Complete Downloading ${tittle}`);112 } catch (err) {113 type === 'single'114 ? await dispatch({type: 'ERROR', vid: id})115 : await dispatch({type: 'ERROR', vid: playlistId});116 console.log(err);117 }118};119const downloadableURLIsSavedToFile = async (120 type,121 URL,122 tittle,123 id,124 itag,125 quality,126 dispatch,127 pltittle,128 index,129 totalVidInList,130 playlistId,131 setError,132) => {133 try {134 console.log('Download has started');135 if (id !== undefined) {136 const path = `${RNFetchBlob.fs.dirs.SDCardDir}/AYTD/.temp/${id}`;137 const downloadVideoURLs = await ytdl(URL, {138 quality: itag,139 });140 const downloadAudioURLs = await ytdl(URL, {141 quality: 'highestaudio',142 filter: 'audioonly',143 });144 Toast.show(`Download Started = ${tittle}`, 3000);145 //146 await downloadURLsToFile(147 downloadVideoURLs,148 path,149 id,150 'video',151 dispatch,152 type,153 playlistId,154 async (progress) => {155 var filterProgress = progress.toFixed(2);156 type === 'single'157 ? await dispatch({158 type: 'PROGRESS',159 progress: filterProgress,160 vid: id,161 downloaded: false,162 path: '',163 vidtype: 'single',164 })165 : await dispatch({166 type: 'PROGRESS',167 progress: filterProgress,168 vid: playlistId,169 downloaded: false,170 path: '',171 vidtype: 'list',172 complete: index + '/' + totalVidInList,173 });174 console.log(175 'video download progress',176 'id=',177 id,178 filterProgress,179 '%',180 );181 },182 setError,183 ).then(async (videoExtention) => {184 await downloadURLsToFile(185 downloadAudioURLs,186 path,187 id,188 'audio',189 type,190 dispatch,191 playlistId,192 async (progress) => {193 var filterProgress = progress.toFixed(2);194 console.log(195 'audio download progress',196 'id=',197 id,198 filterProgress,199 '%',200 );201 },202 setError,203 ).then(async (audioExtention) => {204 if (videoExtention || audioExtention !== 'plain') {205 await ffmpeg(206 path,207 tittle,208 id,209 audioExtention,210 videoExtention,211 quality,212 dispatch,213 type,214 pltittle,215 index,216 totalVidInList,217 playlistId,218 );219 } else {220 Toast.show(`Error To Fetch ${tittle}`);221 }222 });223 });224 }225 } catch (err) {226 type === 'single'227 ? await dispatch({type: 'ERROR', vid: id})228 : await dispatch({type: 'ERROR', vid: playlistId});229 Toast.show(`${err} ${tittle} `, 3000);230 console.log(err);231 }232};233const downloadURLsToFile = (234 URLs,235 path,236 id,237 type,238 vidtype,239 dispatch,240 playlistId,241 progressCallback,242 setError,243) =>244 new Promise(async (resolve, reject) => {245 var extns = '';246 path = path + type;247 for (let i = 0; i < URLs.length; i++) {248 let {url, headers} = URLs[i];249 try {250 const fileAlreadyExists = await RNFetchBlob.fs.exists(path);251 if (fileAlreadyExists) {252 await RNFetchBlob.fs.unlink(path);253 }254 // const res = await RNFetchBlob.config({255 // path,256 // overwrite: false,257 // })258 // .fetch('GET', url, headers)259 // .progress((received, total) => {260 // if (progressCallback) {261 // progressCallback((received * 100) / total);262 // }263 // })264 // .catch((err) => {265 // Toast.show(err);266 // console.error(`Could not save:"${path}" Reason:`, err);267 // });268 const res = RNFetchBlob.config({269 path,270 overwrite: false,271 fileCache: true,272 }).fetch('GET', url, headers);273 res.progress(async (received, total) => {274 if (progressCallback) {275 progressCallback((received * 100) / total);276 }277 var keyy = await AsyncStorage.getItem('vid');278 if (keyy === id || keyy === playlistId) {279 res.cancel(async () => {280 await AsyncStorage.removeItem('vid');281 setError();282 reject('Delete');283 });284 }285 });286 res287 .then(async (respns) => {288 const contentType = respns.respInfo.headers['Content-Type'];289 if (contentType) {290 const extension = contentType.split('/')[1];291 extns = extension;292 path = `${path}.${extension}`;293 await RNFetchBlob.fs.mv(respns.path(), path);294 }295 console.log('The file is saved to:', path);296 resolve(extns);297 })298 .catch((err) => console.log(err));299 // setTimeout(() => {300 // res1.cancel(() => {301 // reject('delete');302 // console.log('cancellll');303 // });304 // }, 5000);305 // .progress((received, total) => {306 // if (progressCallback) {307 // progressCallback((received * 100) / total);308 // }309 // })310 // .catch((err) => {311 // Toast.show(err);312 // console.error(`Could not save:"${path}" Reason:`, err);313 // });314 // const contentType = res.respInfo.headers['Content-Type'];315 // if (contentType) {316 // const extension = contentType.split('/')[1];317 // extns = extension;318 // path = `${path}.${extension}`;319 // await RNFetchBlob.fs.mv(res.path(), path);320 // }321 // console.log('The file is saved to:', path);322 } catch (e) {323 console.error(e);324 vidtype === 'single'325 ? await dispatch({type: 'ERROR', vid: id})326 : await dispatch({type: 'ERROR', vid: playlistId});327 reject(e);328 }329 }330 // resolve(extns);331 });332const dirPermissionAndExistCheck = async (tittle) => {333 try {...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1var assert = require('assert');2var proxyquire = require('proxyquire');3var fs = require('fs');4var rimraf = require('rimraf');5describe("mv", function() {6 // makes fs.rename return cross-device error.7 var mock_fs = {};8 mock_fs.rename = function(src, dest, cb) {9 setTimeout(function() {10 var err = new Error();11 err.code = 'EXDEV';12 cb(err);13 }, 10);14 };15 it("should rename a file on the same device", function (done) {16 var mv = proxyquire.resolve('../index', __dirname, {});17 mv("test/a-file", "test/a-file-dest", function (err) {18 assert.ifError(err);19 fs.readFile("test/a-file-dest", 'utf8', function (err, contents) {20 assert.ifError(err);21 assert.strictEqual(contents, "sonic the hedgehog\n");22 // move it back23 mv("test/a-file-dest", "test/a-file", done);24 });25 });26 });27 it("should not overwrite if clobber = false", function (done) {28 var mv = proxyquire.resolve('../index', __dirname, {});29 mv("test/a-file", "test/a-folder/another-file", {clobber: false}, function (err) {30 assert.ok(err && err.code === 'EEXIST', "throw EEXIST");31 done();32 });33 });34 it("should not create directory structure by default", function (done) {35 var mv = proxyquire.resolve('../index', __dirname, {});36 mv("test/a-file", "test/does/not/exist/a-file-dest", function (err) {37 assert.strictEqual(err.code, 'ENOENT');38 done();39 });40 });41 it("should create directory structure when mkdirp option set", function (done) {42 var mv = proxyquire.resolve('../index', __dirname, {});43 mv("test/a-file", "test/does/not/exist/a-file-dest", {mkdirp: true}, function (err) {44 assert.ifError(err);45 fs.readFile("test/does/not/exist/a-file-dest", 'utf8', function (err, contents) {46 assert.ifError(err);47 assert.strictEqual(contents, "sonic the hedgehog\n");48 // move it back49 mv("test/does/not/exist/a-file-dest", "test/a-file", function(err) {50 assert.ifError(err);51 rimraf("test/does", done);52 });53 });54 });55 });56 it("should work across devices", function (done) {57 var mv = proxyquire.resolve('../index', __dirname, {fs: mock_fs});58 mv("test/a-file", "test/a-file-dest", function (err) {59 assert.ifError(err);60 fs.readFile("test/a-file-dest", 'utf8', function (err, contents) {61 assert.ifError(err);62 assert.strictEqual(contents, "sonic the hedgehog\n");63 // move it back64 mv("test/a-file-dest", "test/a-file", done);65 });66 });67 });68 it("should move folders", function (done) {69 var mv = proxyquire.resolve('../index', __dirname, {});70 mv("test/a-folder", "test/a-folder-dest", function (err) {71 assert.ifError(err);72 fs.readFile("test/a-folder-dest/another-file", 'utf8', function (err, contents) {73 assert.ifError(err);74 assert.strictEqual(contents, "tails\n");75 // move it back76 mv("test/a-folder-dest", "test/a-folder", done);77 });78 });79 });80 it("should move folders across devices", function (done) {81 var mv = proxyquire.resolve('../index', __dirname, {fs: mock_fs});82 mv("test/a-folder", "test/a-folder-dest", function (err) {83 assert.ifError(err);84 fs.readFile("test/a-folder-dest/another-folder/file3", 'utf8', function (err, contents) {85 assert.ifError(err);86 assert.strictEqual(contents, "knuckles\n");87 // move it back88 mv("test/a-folder-dest", "test/a-folder", done);89 });90 });91 });...

Full Screen

Full Screen

lib.js

Source:lib.js Github

copy

Full Screen

1require('seajs');2var global = require('./driver/global');3global.lib = global.lib || {};45lib.string = lib.string || {};6lib.array = lib.array || {};7lib.element = lib.element || {};8lib.event = lib.event || {};9lib.fn = lib.fn || {};10lib.json = lib.json || {};11lib.lang = lib.lang || {};12lib.object = lib.object || {};13lib.selector = lib.selector || {};14lib.url = lib.url || {};15lib.http = lib.http || {};16lib.fs = lib.fs || {};17lib.date = lib.date || {};18lib.data = {};19lib.plugins = {};20lib.crypto = {};21lib.ic = {};22lib.async = {};23lib.event = {};242526//prototype27require('./platform/prototype/array/forEach');28require('./platform/prototype/string/trim');2930//string31lib.string.encodeHtml = require('./platform/string/encodeHtml');32lib.string.decodeHtml = require('./platform/string/decodeHtml');33lib.string.getLength = require('./platform/string/getLength');34lib.string.formatJSON = require('./platform/string/formatJSON');35//array36lib.array.getLen = require('./platform/array/getLen');37lib.array.isArray = require('./platform/array/isArray');38//function39lib.fn.abstractMethod = require('./platform/fn/abstractMethod');40lib.fn.emptyMethod = require('./platform/fn/emptyMethod');41//lang42lib.lang.isSameDomain = require('./platform/lang/isSameDomain');43//object44lib.object.extend = require('./platform/object/extend');45lib.object.deepExtend = require('./platform/object/deepExtend');46lib.object.forEach = require('./platform/object/forEach');47lib.object.isObject = require('./platform/object/isObject');48lib.object.isEmpty = require('./platform/object/isEmpty');49//url50lib.url.parse = require('./platform/url/parse');51lib.url.queryToJson = require('./platform/url/queryToJson');52lib.url.isUrl = require('./platform/url/isUrl');53lib.url.jsonToQuery = require('./platform/url/jsonToQuery');54//http55lib.http.request = require('./platform/http/request');5657lib.Class = require('./platform/class');5859lib.fs.readFile = require('./platform/fs/readFile');60lib.fs.writeFile = require('./platform/fs/writeFile');61lib.fs.readFileAsync = require('./platform/fs/readFileAsync');62lib.fs.recure = require('./platform/fs/recure');63lib.fs.rm = require('./platform/fs/rm');64lib.fs.mkdir = require('./platform/fs/mkdir');65lib.fs.mvAsync = require('./platform/fs/mvAsync');66lib.fs.cpAsync = require('./platform/fs/cpAsync');67lib.fs.open = require('./platform/fs/open');68lib.fs.close = require('./platform/fs/close');69lib.fs.write = require('./platform/fs/write');70lib.fs.isDirectory = require('./platform/fs/isDirectory');71lib.fs.isFile = require('./platform/fs/isFile');72lib.fs.isExist = require('./platform/fs/isExist');73lib.fs.appendAsync = require('./platform/fs/appendAsync');74lib.fs.readDir = require('./platform/fs/readDir');75lib.fs.size = require('./platform/fs/size');7677//date78lib.date.format = require('./platform/date/format');79lib.date.formatSeconds = require('./platform/date/formatSeconds');8081//data82lib.data.Tree = require('./platform/data/tree');8384//plugins85lib.plugins.Template = require('./platform/plugins/template');86lib.plugins.Mustache = require('./platform/plugins/mustache');87lib.plugins.ArtTemplate = require('./platform/plugins/artTemplate');8889//crypto90lib.crypto.md5 = require('./platform/crypto/md5');9192//ic93lib.ic.InfoCenter = require('./platform/ic/infoCenter');9495//async96lib.async.Queue = require('./platform/async/queue');9798//event99lib.event.customEvent = require('./platform/event/customEvent');100 ...

Full Screen

Full Screen

contracts.js

Source:contracts.js Github

copy

Full Screen

1const get = require('lodash/get');2const moment = require('moment');3const { pick } = require('lodash');4const FileHelper = require('../file');5const {6 WEEKS_PER_MONTH,7 EMPLOYER_TRIAL_PERIOD_TERMINATION,8 EMPLOYEE_TRIAL_PERIOD_TERMINATION,9 RESIGNATION,10 SERIOUS_MISCONDUCT_LAYOFF,11 GROSS_FAULT_LAYOFF,12 OTHER_REASON_LAYOFF,13 MUTATION,14 CONTRACTUAL_TERMINATION,15 INTERNSHIP_END,16 CDD_END,17 OTHER,18} = require('../constants');19const ContractHelper = require('../contracts');20const Contract = require('../../models/Contract');21const FS_MV_MOTIF_S = {22 [EMPLOYER_TRIAL_PERIOD_TERMINATION]: 34,23 [EMPLOYEE_TRIAL_PERIOD_TERMINATION]: 35,24 [RESIGNATION]: 59,25 [SERIOUS_MISCONDUCT_LAYOFF]: 16,26 [GROSS_FAULT_LAYOFF]: 17,27 [OTHER_REASON_LAYOFF]: 20,28 [MUTATION]: 62,29 [CONTRACTUAL_TERMINATION]: 8,30 [INTERNSHIP_END]: 80,31 [CDD_END]: 31,32 [OTHER]: 60,33};34exports.exportContractVersions = async (query, credentials) => {35 const rules = ContractHelper.getQuery(query, get(credentials, 'company._id') || '');36 const contracts = await Contract.find({ $and: rules })37 .populate({ path: 'user', select: 'serialNumber identity' })38 .lean();39 const filteredVersions = contracts40 .map(c => c.versions41 .filter(v => moment(v.startDate).isBetween(query.startDate, query.endDate, 'day', '[]'))42 .map(v => ({ ...v, ...pick(c, ['user', 'serialNumber']) })))43 .flat();44 const data = [];45 for (const version of filteredVersions) {46 data.push({47 ap_soc: process.env.AP_SOC,48 ap_matr: get(version, 'user.serialNumber') || '',49 fs_nom: get(version, 'user.identity.lastname') || '',50 ap_contrat: version.serialNumber || '',51 fs_date_avenant: moment(version.startDate).format('DD/MM/YYYY'),52 fs_horaire: version.weeklyHours * WEEKS_PER_MONTH,53 fs_sal_forfait_montant: version.weeklyHours * version.grossHourlyRate * WEEKS_PER_MONTH,54 });55 }56 return data.length57 ? FileHelper.exportToTxt([Object.keys(data[0]), ...data.map(d => Object.values(d))])58 : FileHelper.exportToTxt([]);59};60exports.exportContractEnds = async (query, credentials) => {61 const contractList = await Contract62 .find({63 endDate: { $lte: moment(query.endDate).endOf('d').toDate(), $gte: moment(query.startDate).startOf('d').toDate() },64 company: get(credentials, 'company._id'),65 })66 .populate({ path: 'user', select: 'serialNumber identity' })67 .lean();68 const data = [];69 for (const contract of contractList) {70 data.push({71 ap_soc: process.env.AP_SOC,72 ap_matr: get(contract, 'user.serialNumber') || '',73 fs_nom: get(contract, 'user.identity.lastname') || '',74 ap_contrat: contract.serialNumber || '',75 fs_mv_sortie: moment(contract.endDate).format('DD/MM/YYYY'),76 fs_mv_motif_s: FS_MV_MOTIF_S[contract.endReason] || '',77 });78 }79 return data.length80 ? FileHelper.exportToTxt([Object.keys(data[0]), ...data.map(d => Object.values(d))])81 : FileHelper.exportToTxt([]);...

Full Screen

Full Screen

FileSystem.js

Source:FileSystem.js Github

copy

Full Screen

...39export async function importBook(book: RNFetchBlobStat, guid: string) {40 const path = `${BOOKS_DIR}/${guid}`;41 const pagesPath = `${path}/pages`;42 await RNFetchBlob.fs.mkdir(path);43 await RNFetchBlob.fs.mv(book.path, pagesPath);44 const files = await getDirectoryFiles(pagesPath);45 const images = files.filter(file => isImage(file));46 await Promise.all(images.map((image, index) => RNFetchBlob.fs.mv(image.path, `${pagesPath}/${index + 1}.jpg`)));47 await createThumbnail(path);48 return {49 path,50 totalPages: images.length,51 };...

Full Screen

Full Screen

mvAsync.js

Source:mvAsync.js Github

copy

Full Screen

1define(function(require,exports,module){23 /*4 * mvAsync(srcPath,destPath,callback)5 * @srcPath 源路径6 * @destPath 目的路径7 * @callback 回调函数8 */9 10 var mvAsync = require('../../driver/fs/mvAsync');1112 module.exports = mvAsync; ...

Full Screen

Full Screen

test2.js

Source:test2.js Github

copy

Full Screen

1require('./lib/cx')2.run('input','output', function( cx ) {3 var fs = cx.file('about.html').cp();4 fs.mv('index.html');...

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Appium Base Driver 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