How to use files.filter method in qawolf

Best JavaScript code snippet using qawolf

file.js

Source:file.js Github

copy

Full Screen

1const {Files} = require('../../selectors/BO/catalogpage/files');2const {CatalogPage} = require('../../selectors/BO/catalogpage/index');3const {Menu} = require('../../selectors/BO/menu.js');4const {AccessPageBO} = require('../../selectors/BO/access_page');5const {SearchProductPage} = require('../../selectors/FO/search_product_page');6const {productPage} = require('../../selectors/FO/product_page');7let promise = Promise.resolve();8module.exports = {9 createFile: function (filename, description, file) {10 scenario('Create a new "File"', client => {11 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));12 test('should click on "Add new file" button', () => client.waitForExistAndClick(Files.add_new_file_button));13 test('should set the "Filename" input', () => client.waitAndSetValue(Files.filename_input, filename));14 test('should set the "Description" textarea', () => client.waitAndSetValue(Files.description_textarea, description));15 test('should upload the picture', () => client.uploadPicture(file, Files.file, 'file'));16 test('should click on "Save" button', () => client.waitForExistAndClick(Files.save_button));17 test('should verify the appearance of the green validation', () => client.checkTextValue(CatalogPage.success_panel, '×\nSuccessful creation.'));18 }, 'common_client');19 },20 editFile: function (filename, updatedFilename, updatedDescription, updatedFile) {21 scenario('Edit the created "File"', client => {22 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));23 test('should search for the created file', () => {24 return promise25 .then(() => client.isVisible(Files.filter_name_input))26 .then(() => client.searchByValue(Files.filter_name_input, Files.filter_search_button, filename));27 });28 test('should click on "Edit" button', () => client.waitForExistAndClick(Files.edit_button));29 test('should set the "Filename" input', () => client.waitAndSetValue(Files.filename_input, updatedFilename));30 test('should set the "Description" textarea', () => client.waitAndSetValue(Files.description_textarea, updatedDescription));31 test('should upload the picture', () => client.uploadPicture(updatedFile, Files.file, 'file'));32 test('should click on "Save" button', () => client.waitForExistAndClick(Files.save_button));33 test('should verify the appearance of the green validation', () => client.checkTextValue(CatalogPage.success_panel, '×\nSuccessful update.'));34 test('should click on "Reset" button', () => {35 return promise36 .then(() => client.isVisible(Files.filter_reset_button))37 .then(() => client.resetButton(Files.filter_reset_button));38 });39 }, 'file');40 },41 checkFile: function (filename, description) {42 scenario('Check the created "File"', client => {43 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));44 test('should search for the created file', () => {45 return promise46 .then(() => client.isVisible(Files.filter_name_input))47 .then(() => client.searchByValue(Files.filter_name_input, Files.filter_search_button, filename));48 });49 test('should click on "Edit" button', () => client.waitForExistAndClick(Files.edit_button));50 test('should check that the "Filename" value is equal to "' + filename + '"', () => client.checkAttributeValue(Files.filename_input, 'value', filename));51 test('should check that the "Description" value is equal to "' + description + '"', () => client.checkAttributeValue(Files.description_textarea, 'value', description));52 test('should click on "Reset" button', () => {53 return promise54 .then(() => client.isVisible(Files.filter_reset_button))55 .then(() => client.resetButton(Files.filter_reset_button));56 });57 }, 'file');58 },59 deleteFile: function (filename) {60 scenario('Delete the created "File"', client => {61 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));62 test('should click on "Reset" button', () => {63 return promise64 .then(() => client.isVisible(Files.filter_reset_button, 3000))65 .then(() => client.resetButton(Files.filter_reset_button));66 });67 test('should search for the created files', () => {68 return promise69 .then(() => client.isVisible(Files.filter_name_input))70 .then(() => client.searchByValue(Files.filter_name_input, Files.filter_search_button, filename));71 });72 test('should click on "Dropdown toggle" button', () => client.waitForExistAndClick(Files.dropdown_button));73 test('should click on "Delete" action button', () => client.waitForExistAndClick(Files.action_button.replace('%B', 'Delete')));74 test('should accept the confirmation modal', () => client.alertAccept());75 test('should verify the appearance of the green validation', () => client.checkTextValue(CatalogPage.success_panel, '×\nSuccessful deletion.'));76 }, 'file');77 },78 deleteFileWithBulkAction: function (filename) {79 scenario('Delete the created "File" with bulk action', client => {80 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));81 test('should search for the created files', () => {82 return promise83 .then(() => client.isVisible(Files.filter_name_input))84 .then(() => client.searchByValue(Files.filter_name_input, Files.filter_search_button, filename));85 });86 test('should click on "Bulk action" button', () => client.waitForExistAndClick(Files.bulk_action_button));87 test('should click on "Select all" action', () => client.waitForExistAndClick(Files.bulk_actions_select_all_button));88 test('should click on "Bulk action" button', () => client.waitForExistAndClick(Files.bulk_action_button));89 test('should click on "Delete" action', () => client.waitForExistAndClick(Files.bulk_actions_delete_button));90 test('should accept the confirmation modal', () => client.alertAccept());91 test('should verify the appearance of the green validation', () => client.checkTextValue(CatalogPage.success_panel, '×\nThe selection has been successfully deleted.'));92 test('should click on "Reset" button', () => {93 return promise94 .then(() => client.isVisible(Files.filter_reset_button))95 .then(() => client.resetButton(Files.filter_reset_button));96 });97 }, 'file');98 },99 viewFile: function (folderPath, filename, file) {100 scenario('View the created "File"', client => {101 test('should go to "Files" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu));102 test('should search for the created files', () => {103 return promise104 .then(() => client.isVisible(Files.filter_name_input))105 .then(() => client.searchByValue(Files.filter_name_input, Files.filter_search_button, filename));106 });107 test('should click on "Dropdown toggle" button', () => client.waitForExistAndClick(Files.dropdown_button));108 test('should click on "View" action button', () => {109 return promise110 .then(() => client.waitForExistAndClick(Files.action_button.replace('%B', 'View')))111 .then(() => client.pause(2000));112 });113 test('should check that the file is well downloaded', () => client.checkFile(folderPath, file, 3000));114 test('should click on "Reset" button', () => {115 return promise116 .then(() => client.isVisible(Files.filter_reset_button))117 .then(() => client.resetButton(Files.filter_reset_button));118 });119 }, 'file');120 },121 checkFileFO: function (productName, filename, pause = 0) {122 scenario('Check that the file is well associated with the created product in the FO', client => {123 test('should go to the Front Office', () => {124 return promise125 .then(() => client.waitForExistAndClick(AccessPageBO.shopname, pause))126 .then(() => client.switchWindow(1));127 });128 test('should set the shop language to "English"', () => client.changeLanguage());129 test('should search for the product', () => client.searchByValue(SearchProductPage.search_input, SearchProductPage.search_button, productName + date_time));130 test('should go to the product page', () => client.waitForExistAndClick(SearchProductPage.product_result_name));131 test('should click on "Attachments" tab', () => client.scrollWaitForExistAndClick(productPage.attachments_tab, 50));132 test('should check the existence of the file', () => client.checkTextValue(productPage.filename_link, filename, 'equal', 5000));133 test('should go back to the Back Office', () => client.switchWindow(0));134 }, 'common_client');135 },136 // if (sortBy === 'id') index = 2;137 // if (sortBy === 'name') index = 3;138 // if (sortBy === 'size') index = 5;139 // if (sortBy === 'associated') index = 6;140 sortFile: function (sortBy, index, filtredTable = false) {141 scenario('Sort files by "' + sortBy.toUpperCase() + '" in the Back Office', client => {142 test('should go to "Files" page', () => {143 return promise144 .then(() => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu))145 .then(() => client.isVisible(Files.filter_reset_button))146 .then(() => client.resetButton(Files.filter_reset_button, filtredTable))147 .then(() => client.getTextInVar(Files.files_number, 'filesNumber'));148 });149 test('should click on "Sort by ASC" icon', () => client.waitForExistAndClick(Files.sort_by_icon.replace("%H", index).replace("%BY", "up")));150 test('should check "Sort file by ' + sortBy + '"', () => {151 for (let j = 0; j < global.tab['filesNumber']; j++) {152 promise = client.getFileInformations(Files.files_table.replace('%R', j + 1).replace('%D', index), j);153 }154 return promise155 .then(() => client.checkSortFile(sortBy));156 });157 test('should click on "Sort by DESC" icon', () => client.waitForExistAndClick(Files.sort_by_icon.replace("%H", index).replace("%BY", "down")));158 test('should check "Sort file by ' + sortBy + '"', () => {159 for (let j = 0; j < global.tab['filesNumber']; j++) {160 promise = client.getFileInformations(Files.files_table.replace('%R', j + 1).replace('%D', index), j);161 }162 return promise163 .then(() => client.checkSortFile(sortBy));164 });165 }, 'file');166 },167 filterFile: function (searchValue, filterBy, index, sortedTable = false) {168 scenario('Filter files by "' + filterBy.toUpperCase() + '" in the Back Office', client => {169 test('should go to "Files" page', () => {170 return promise171 .then(() => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.files_submenu))172 .then(() => client.isVisible(Files.filter_reset_button))173 .then(() => client.resetButton(Files.filter_reset_button, sortedTable));174 });175 test('should search "Files" by "' + filterBy + '"', () => {176 return promise177 .then(() => client.isVisible(Files.filter_name_input))178 .then(() => {179 if (filterBy === 'name') {180 client.searchByValue(Files.filter_name_input, Files.filter_search_button, searchValue);181 } else if (filterBy === 'size') {182 client.searchByValue(Files.filter_size_input, Files.filter_search_button, searchValue);183 } else if (filterBy === 'associated') {184 client.searchByValue(Files.filter_associated_input, Files.filter_search_button, searchValue);185 }186 })187 .then(() => client.isVisible(Files.empty_list, 1000))188 .then(() => client.getFilesNumber('table-attachment', 1000));189 });190 test('should check "Filter file by ' + filterBy + '"', () => {191 if (global.filesNumber > 0) {192 for (let j = 0; j < global.filesNumber; j++) {193 promise = client.getFileInformations(Files.files_table.replace('%R', j + 1).replace('%D', index), j, false);194 }195 // BOOM: 9607196 return promise197 .then(() => client.checkFilterFile(searchValue));198 } else {199 return Promise.reject(new Error('No Records Found')).then(expect(global.filesNumber).to.be.at.most(0));200 }201 });202 }, 'file');203 }...

Full Screen

Full Screen

audio-wfrp3.js

Source:audio-wfrp3.js Github

copy

Full Screen

...174 }175 }176 if (context.item.special == "warhammer")177 file = "warhammer"178 files = files.filter(f => f.includes(file))179 180 if(context.item.type == "weapon")181 {182 globalSound = true;183 184 if(context.action == "miss")185 files = files.filter(f => f.includes("-miss"))186 else if(context.action == "misfire")187 files = files.filter(f => f.includes("-misfire"))188 else if(context.action == "fire")189 {190 if(file == "weapon_xbow" || file == "weapon_bow" || file == "weapon_gun" || file.includes("throw"))191 files = files.filter(f => f.includes("-fire"))192 else if(file != "weapon_bomb")193 files = files.filter(f => f.includes("-swing"))194 else 195 files = files.filter(f => f.includes("-throw"))196 }197 else if (context.action == "load")198 files = files.filter(f => f.includes("-load"))199 else if (context.action == "damage")200 {201 globalSound = false;202 files = files.filter(f => f.includes("damage"))203 if (context.outcome == "shield")204 files = files.filter(f => f.includes("shield"))205 }206 }207 if (context.item.type == "shield")208 {209 files = files.filter(f => f.includes(context.action));210 }211 if(context.action == "equip")212 {213 if (context.outcome || context.item.type == "weapon")214 {215 files = files.filter(f => f.includes("-equip"))216 }217 else218 {219 files = files.filter(f => f.includes("deequip"))220 }221 }222 if(context.action == "hit")223 {224 files = files.filter(f => f.includes("hit"))225 }226 227 if(context.item.type == "spell")228 {229 if(context.action == "memorize")230 files = files.filter(f => f.includes("-memorize"))231 else if(context.action == "unmemorize")232 files = files.filter(f => f.includes("unmemorize"))233 else if(context.action == "cast")234 {235 if (context.outcome == "damage")236 files = files.filter(f => f.includes("damage-cast"))237 else 238 files = files.filter(f => f.includes("-cast") && !f.includes("damage"))239 globalSound = true;240 }241 else242 {243 files = files.filter(f => f.includes("miscast"))244 globalSound = true;245 }246 }247 248 if(context.item.type == "prayer")249 {250 globalSound = true;251 if(context.action == "cast")252 files = files.filter(f => f.includes("-cast"))253 else254 files = files.filter(f => f.includes("miscast"))255 }256 257 if(context.action == "hit")258 {259 globalSound = true;260 if (context.outcome == "blocked")261 files = files.filter(f => f.includes(context.item.armourType))262 else if (context.item.type == "armour")263 files = files.filter(f => f.includes("armour"))264 else 265 files = files.filter(f => !f.includes("armour")) // all non-armour sounds266 if (context.outcome == "normal")267 files = files.filter(f => f.includes("normal"))268 if (context.outcome == "warhammer")269 files = files.filter(f => f.includes("warhammer"))270 if(context.outcome == "crit")271 files = files.filter(f => f.includes("crit-"))272 if(context.outcome == "crit_impale")273 files = files.filter(f => f.includes("crit_impale"))274 }275 276 if(context.item.type == "skill")277 {278 if(context.action == "consumeAlcohol")279 files = files.filter(f => f.includes(`consumeAlcohol-${context.outcome == "fail" ? 'fail' : 'success'}`))280 if(context.action == "stealth") 281 files = files.filter(f => f.includes(`stealth-${context.outcome == "fail" ? 'fail' : 'success'}`))282 if (context.action == "pickLock")283 files = files.filter(f => f.includes(context.action))284 }285 286 return {file : files[new Roll(`1d${files.length}-1`).roll().total], global : globalSound}287 }288 catch (e)289 {290 console.log("wfrp3 | Sound Context Error: " + e)291 }292 }...

Full Screen

Full Screen

files.js

Source:files.js Github

copy

Full Screen

1/* eslint-env mocha */2/* eslint max-nested-callbacks: ["error", 8] */3'use strict'4const chai = require('chai')5const dirtyChai = require('dirty-chai')6const DaemonFactory = require('ipfsd-ctl')7const expect = chai.expect8chai.use(dirtyChai)9const {10 FILE_TYPES11} = require('ipfs-mfs')12const df = DaemonFactory.create({ exec: 'src/cli/bin.js' })13describe('.files', () => {14 let ipfs = null15 let ipfsd = null16 before(function (done) {17 this.timeout(20 * 1000)18 df.spawn({ initOptions: { bits: 512 } }, (err, _ipfsd) => {19 expect(err).to.not.exist()20 ipfsd = _ipfsd21 ipfs = ipfsd.api22 done()23 })24 })25 after((done) => ipfsd.stop(done))26 describe('.add', function () {27 it('performs a speculative add, --only-hash', () => {28 const content = String(Math.random())29 return ipfs.add(Buffer.from(content), { onlyHash: true })30 .then(files => {31 const getAttempt = ipfs.object.get(files[0].hash)32 .then(() => {33 throw new Error('Should not find an object for content added with --only-hash')34 })35 return Promise.race([36 getAttempt,37 new Promise((resolve, reject) => setTimeout(resolve, 4000))38 ])39 })40 })41 })42 describe('.ls', function () {43 it('lists empty directory', () => {44 return ipfs.files.ls()45 .then(files => {46 expect(files).to.be.empty()47 })48 })49 it('lists files', () => {50 const fileName = `single-file-${Math.random()}.txt`51 return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {52 create: true53 })54 .then(() => ipfs.files.ls())55 .then(files => {56 expect(files.length).to.equal(1)57 expect(files[0].name).to.equal(fileName)58 })59 })60 it('lists files in directories', () => {61 const dirName = `dir-${Math.random()}`62 const fileName = `file-in-dir-${Math.random()}.txt`63 return ipfs.files.write(`/${dirName}/${fileName}`, Buffer.from('Hello world'), {64 create: true,65 parents: true66 })67 .then(() => ipfs.files.ls(`/${dirName}`))68 .then(files => {69 expect(files.length).to.equal(1)70 expect(files[0].name).to.equal(fileName)71 })72 })73 })74 describe('.cp', function () {75 it('copies a file', () => {76 const source = `source-file-${Math.random()}.txt`77 const destination = `destination-file-${Math.random()}.txt`78 return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {79 create: true80 })81 .then(() => ipfs.files.cp(`/${source}`, `/${destination}`))82 .then(() => ipfs.files.ls(`/`, {83 long: true84 }))85 .then(files => {86 const sourceFile = files87 .filter(file => file.name === source)88 .pop()89 expect(sourceFile.type).to.equal(FILE_TYPES.file)90 const destFile = files91 .filter(file => file.name === destination)92 .pop()93 expect(destFile.type).to.equal(FILE_TYPES.file)94 })95 })96 it('copies a directory', () => {97 const source = `source-dir-${Math.random()}`98 const destination = `destination-dir-${Math.random()}`99 return ipfs.files.mkdir(`/${source}`)100 .then(() => ipfs.files.cp(`/${source}`, `/${destination}`))101 .then(() => ipfs.files.ls(`/`, {102 long: true103 }))104 .then(files => {105 const sourceDir = files106 .filter(file => file.name === source)107 .pop()108 expect(sourceDir.type).to.equal(FILE_TYPES.directory)109 const destDir = files110 .filter(file => file.name === destination)111 .pop()112 expect(destDir.type).to.equal(FILE_TYPES.directory)113 })114 })115 it('copies a file with array args', () => {116 const source = `source-file-${Math.random()}.txt`117 const destination = `destination-file-${Math.random()}.txt`118 return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {119 create: true120 })121 .then(() => ipfs.files.cp([`/${source}`, `/${destination}`]))122 .then(() => ipfs.files.ls(`/`, {123 long: true124 }))125 .then(files => {126 const sourceFile = files127 .filter(file => file.name === source)128 .pop()129 expect(sourceFile.type).to.equal(FILE_TYPES.file)130 const destFile = files131 .filter(file => file.name === destination)132 .pop()133 expect(destFile.type).to.equal(FILE_TYPES.file)134 })135 })136 it('copies a directory with array args', () => {137 const source = `source-dir-${Math.random()}`138 const destination = `destination-dir-${Math.random()}`139 return ipfs.files.mkdir(`/${source}`)140 .then(() => ipfs.files.cp([`/${source}`, `/${destination}`]))141 .then(() => ipfs.files.ls(`/`, {142 long: true143 }))144 .then(files => {145 const sourceDir = files146 .filter(file => file.name === source)147 .pop()148 expect(sourceDir.type).to.equal(FILE_TYPES.directory)149 const destDir = files150 .filter(file => file.name === destination)151 .pop()152 expect(destDir.type).to.equal(FILE_TYPES.directory)153 })154 })155 })156 describe('.mkdir', function () {157 it('makes a directory', () => {158 const directory = `directory-${Math.random()}`159 return ipfs.files.mkdir(`/${directory}`)160 .then(() => ipfs.files.ls(`/`, {161 long: true162 }))163 .then(files => {164 const dir = files165 .filter(file => file.name === directory)166 .pop()167 expect(dir.type).to.equal(FILE_TYPES.directory)168 })169 })170 })171 describe('.mv', function () {172 it('moves a file', () => {173 const source = `source-file-${Math.random()}.txt`174 const destination = `destination-file-${Math.random()}.txt`175 return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {176 create: true177 })178 .then(() => ipfs.files.mv(`/${source}`, `/${destination}`))179 .then(() => ipfs.files.ls(`/`))180 .then(files => {181 const sourceFile = files182 .filter(file => file.name === source)183 .pop()184 expect(sourceFile).to.not.exist()185 const destFile = files186 .filter(file => file.name === destination)187 .pop()188 expect(destFile.type).to.equal(FILE_TYPES.file)189 })190 })191 it('moves a directory', () => {192 const source = `source-dir-${Math.random()}`193 const destination = `destination-dir-${Math.random()}`194 return ipfs.files.mkdir(`/${source}`)195 .then(() => ipfs.files.mv(`/${source}`, `/${destination}`))196 .then(() => ipfs.files.ls(`/`, {197 long: true198 }))199 .then(files => {200 const sourceDir = files201 .filter(file => file.name === source)202 .pop()203 expect(sourceDir).to.not.exist()204 const destDir = files205 .filter(file => file.name === destination)206 .pop()207 expect(destDir.type).to.equal(FILE_TYPES.directory)208 })209 })210 it('moves a file with array args', () => {211 const source = `source-file-${Math.random()}.txt`212 const destination = `destination-file-${Math.random()}.txt`213 return ipfs.files.write(`/${source}`, Buffer.from('Hello world'), {214 create: true215 })216 .then(() => ipfs.files.mv([`/${source}`, `/${destination}`]))217 .then(() => ipfs.files.ls(`/`))218 .then(files => {219 const sourceFile = files220 .filter(file => file.name === source)221 .pop()222 expect(sourceFile).to.not.exist()223 const destFile = files224 .filter(file => file.name === destination)225 .pop()226 expect(destFile.type).to.equal(FILE_TYPES.file)227 })228 })229 it('moves a directory with array args', () => {230 const source = `source-dir-${Math.random()}`231 const destination = `destination-dir-${Math.random()}`232 return ipfs.files.mkdir(`/${source}`)233 .then(() => ipfs.files.mv([`/${source}`, `/${destination}`]))234 .then(() => ipfs.files.ls(`/`, {235 long: true236 }))237 .then(files => {238 const sourceDir = files239 .filter(file => file.name === source)240 .pop()241 expect(sourceDir).to.not.exist()242 const destDir = files243 .filter(file => file.name === destination)244 .pop()245 expect(destDir.type).to.equal(FILE_TYPES.directory)246 })247 })248 })249 describe('.read', function () {250 it('reads a file', () => {251 const fileName = `single-file-${Math.random()}.txt`252 const content = Buffer.from('Hello world')253 return ipfs.files.write(`/${fileName}`, content, {254 create: true255 })256 .then(() => ipfs.files.read(`/${fileName}`))257 .then(buffer => {258 expect(buffer).to.deep.equal(content)259 })260 })261 })262 describe('.rm', function () {263 it('removes a file', () => {264 const fileName = `single-file-${Math.random()}.txt`265 return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {266 create: true267 })268 .then(() => ipfs.files.rm(`/${fileName}`))269 .then(() => ipfs.files.ls(`/`))270 .then(files => {271 const file = files272 .filter(file => file.name === fileName)273 .pop()274 expect(file).to.not.exist()275 })276 })277 it('removes a directory', () => {278 const dirName = `dir-${Math.random()}`279 const fileName = `file-in-dir-${Math.random()}.txt`280 return ipfs.files.write(`/${dirName}/${fileName}`, Buffer.from('Hello world'), {281 create: true,282 parents: true283 })284 .then(() => ipfs.files.rm(`/${dirName}`, {285 recursive: true286 }))287 .then(() => ipfs.files.ls(`/`))288 .then(files => {289 const dir = files290 .filter(file => file.name === dirName)291 .pop()292 expect(dir).to.not.exist()293 })294 })295 })296 describe('.stat', function () {297 it('stats a file', () => {298 const fileName = `single-file-${Math.random()}.txt`299 return ipfs.files.write(`/${fileName}`, Buffer.from('Hello world'), {300 create: true301 })302 .then(() => ipfs.files.stat(`/${fileName}`))303 .then(stats => {304 expect(stats).to.deep.equal({305 blocks: 1,306 cumulativeSize: 69,307 hash: 'Qmetpc7cZmN25Wcc6R27cGCAvCDqCS5GjHG4v7xABEfpmJ',308 local: undefined,309 size: 11,310 sizeLocal: undefined,311 type: 'file',312 withLocality: false313 })314 })315 })316 it('stats a directory', () => {317 const dirName = `dir-${Math.random()}`318 return ipfs.files.mkdir(`/${dirName}`)319 .then(() => ipfs.files.stat(`/${dirName}`))320 .then(stats => {321 expect(stats).to.deep.equal({322 blocks: 0,323 cumulativeSize: 4,324 hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',325 local: undefined,326 size: 0,327 sizeLocal: undefined,328 type: 'directory',329 withLocality: false330 })331 })332 })333 })...

Full Screen

Full Screen

filter.js

Source:filter.js Github

copy

Full Screen

1/* 2 * 3 * (c) Copyright Ascensio System Limited 2010-20144 * 5 * This program is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * License, or (at your option) any later version.9 * 10 * http://www.gnu.org/licenses/agpl.html 11 * 12 */13window.ASC.Files.Filter = (function () {14 var isInit = false;15 var advansedFilter = null;16 var init = function () {17 if (!isInit) {18 var startOrderBy = ASC.Files.Common.localStorageManager.getItem(ASC.Files.Constants.storageKeyOrderBy);19 startOrderBy = startOrderBy ||20 {21 property: "DateAndTime",22 is_asc: false23 };24 ASC.Files.Filter.advansedFilter =25 jq("#files_advansedFilter")26 .advansedFilter({27 anykey: true,28 anykeytimeout: 800,29 maxfilters: 1,30 maxlength: ASC.Files.Constants.MAX_NAME_LENGTH,31 filters: [32 {33 type: "combobox",34 id: "selected-type",35 title: ASC.Files.FilesJSResources.Types,36 options: [37 {value: ASC.Files.Constants.FilterType.FilesOnly, title: ASC.Files.FilesJSResources.ButtonFilterFile},38 {value: ASC.Files.Constants.FilterType.FoldersOnly, title: ASC.Files.FilesJSResources.ButtonFilterFolder, def: true},39 {value: ASC.Files.Constants.FilterType.DocumentsOnly, title: ASC.Files.FilesJSResources.ButtonFilterDocument},40 {value: ASC.Files.Constants.FilterType.PresentationsOnly, title: ASC.Files.FilesJSResources.ButtonFilterPresentation},41 {value: ASC.Files.Constants.FilterType.SpreadsheetsOnly, title: ASC.Files.FilesJSResources.ButtonFilterSpreadsheet},42 {value: ASC.Files.Constants.FilterType.ImagesOnly, title: ASC.Files.FilesJSResources.ButtonFilterImage}]43 },44 {type: "person", id: "selected-person", title: ASC.Files.FilesJSResources.Users},45 {type: "group", id: "selected-group", title: ASC.Files.FilesJSResources.Departments}46 ],47 sorters: [48 {id: "DateAndTime", title: ASC.Files.FilesJSResources.ButtonSortModified, def: (startOrderBy.property == "DateAndTime"), dsc: !startOrderBy.is_asc},49 {id: "AZ", title: ASC.Files.FilesJSResources.ButtonSortName, def: (startOrderBy.property == "AZ"), dsc: !startOrderBy.is_asc},50 {id: "Type", title: ASC.Files.FilesJSResources.ButtonSortType, def: (startOrderBy.property == "Type"), dsc: !startOrderBy.is_asc},51 {id: "Size", title: ASC.Files.FilesJSResources.ButtonSortSize, def: (startOrderBy.property == "Size"), dsc: !startOrderBy.is_asc},52 {id: "Author", title: ASC.Files.FilesJSResources.ButtonSortAuthor, def: (startOrderBy.property == "Author"), dsc: !startOrderBy.is_asc},53 {id: "New", title: ASC.Files.FilesJSResources.ButtonSortNew, def: (startOrderBy.property == "New"), dsc: !startOrderBy.is_asc}54 ]55 })56 .bind("setfilter", ASC.Files.Filter.setFilter)57 .bind("resetfilter", ASC.Files.Filter.setFilter);58 }59 };60 var disableFilter = function () {61 var isMy = ASC.Files.Folders.folderContainer == "my";62 var isForMe = ASC.Files.Folders.folderContainer == "forme";63 var isRootProject = ASC.Files.Folders.currentFolder.id == ASC.Files.Constants.FOLDER_ID_PROJECT;64 var isYourDocs = ASC.Resources.Master.YourDocsDemo == true;65 ASC.Files.Filter.advansedFilter.advansedfilter("sort", !isForMe && !isRootProject);66 if (isForMe) {67 ASC.Files.Filter.advansedFilter.advansedFilter({68 sorters: [{id: "New", def: true, dsc: true}]69 });70 }71 if (isRootProject) {72 ASC.Files.Filter.advansedFilter.advansedFilter({73 sorters: [{id: "AZ", def: true, dsc: false}]74 });75 }76 ASC.Files.Filter.advansedFilter.advansedFilter({77 filters: [78 {id: "selected-type", visible: !isRootProject},79 {id: "selected-person", visible: !isMy && !isRootProject && !isYourDocs},80 {id: "selected-group", visible: !isMy && !isRootProject && !isYourDocs}81 ],82 sorters: [83 {id: "Author", visible: !isMy}84 ]85 });86 ASC.Files.Filter.advansedFilter.advansedFilter({87 nonetrigger: true,88 hasButton: !isRootProject,89 sorters: [90 {id: "New", visible: isForMe}91 ]92 });93 };94 var setFilter = function (evt, $container, filter, params, selectedfilters) {95 if (!isInit) {96 isInit = true;97 return;98 }99 ASC.Files.Anchor.navigationSet(ASC.Files.Folders.currentFolder.id, false, true);100 };101 var clearFilter = function (safeMode) {102 safeMode = safeMode === true;103 var mustTrue = false;104 if (safeMode && isInit) {105 mustTrue = true;106 isInit = false;107 }108 ASC.Files.Filter.advansedFilter.advansedFilter(null);109 if (safeMode && mustTrue) {110 isInit = true;111 }112 };113 var resize = function () {114 ASC.Files.Filter.advansedFilter.resize();115 };116 var getFilterSettings = function (currentFolderId) {117 var settings =118 {119 sorter: ASC.Files.Filter.getOrderDefault(),120 text: "",121 filter: 0,122 subject: ""123 };124 if (ASC.Files.Filter.advansedFilter == null) {125 return settings;126 }127 var param = ASC.Files.Filter.advansedFilter.advansedFilter();128 jq(param).each(function (i, item) {129 switch (item.id) {130 case "sorter":131 var curOrderBy = getOrderBy(item.params.id, !item.params.dsc);132 settings.sorter = curOrderBy;133 ASC.Files.Common.localStorageManager.setItem(ASC.Files.Constants.storageKeyOrderBy, curOrderBy);134 break;135 case "text":136 settings.text = item.params.value;137 break;138 case "selected-person":139 settings.filter = 8;140 settings.subject = item.params.id;141 break;142 case "selected-group":143 settings.filter = 9;144 settings.subject = item.params.id;145 break;146 case "selected-type":147 settings.filter = parseInt(item.params.value || 0);148 break;149 }150 });151 currentFolderId = currentFolderId || ASC.Files.Folders.currentFolder.id;152 if (currentFolderId == ASC.Files.Constants.FOLDER_ID_SHARE || ASC.Files.Folders.folderContainer == "forme") {153 settings.sorter = ASC.Files.Filter.getOrderByNew(false);154 }155 if (currentFolderId == ASC.Files.Constants.FOLDER_ID_PROJECT) {156 settings.sorter = ASC.Files.Filter.getOrderByAZ(true);157 }158 return settings;159 };160 var getOrderDefault = function () {161 return ASC.Files.Filter.getOrderByDateAndTime(false);162 };163 var getOrderByDateAndTime = function (asc) {164 return getOrderBy("DateAndTime", asc);165 };166 var getOrderByAZ = function (asc) {167 return getOrderBy("AZ", asc);168 };169 var getOrderByNew = function (asc) {170 return getOrderBy("New", asc);171 };172 var getOrderBy = function (name, asc) {173 name = (typeof name != "undefined" && name != "" ? name : "DateAndTime");174 asc = asc === true;175 return {176 is_asc: asc,177 property: name178 };179 };180 return {181 init: init,182 advansedFilter: advansedFilter,183 disableFilter: disableFilter,184 getFilterSettings: getFilterSettings,185 getOrderDefault: getOrderDefault,186 getOrderByDateAndTime: getOrderByDateAndTime,187 getOrderByAZ: getOrderByAZ,188 getOrderByNew: getOrderByNew,189 setFilter: setFilter,190 clearFilter: clearFilter,191 resize: resize192 };193})();194(function ($) {195 $(function () {196 ASC.Files.Filter.init();197 jq("#files_clearFilter").click(function () {198 ASC.Files.Filter.clearFilter();199 return false;200 });201 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs');2const { promisify } = require('util');3const readdir = promisify(fs.readdir);4const stat = promisify(fs.stat);5async function isDirectory(source) {6 return (await stat(source)).isDirectory();7}8async function getDirectories(source) {9 const files = await readdir(source);10 const directories = await Promise.all(files.map(async (file) => {11 const res = source + '/' + file;12 return (await isDirectory(res)) ? res : false;13 }));14 return directories.filter((directory) => directory);15}16async function getFiles(source) {17 const files = await readdir(source);18 const directories = await Promise.all(files.map(async (file) => {19 const res = source + '/' + file;20 return (await isDirectory(res)) ? false : res;21 }));22 return directories.filter((directory) => directory);23}24async function getFilesAndDirectories(source) {25 const files = await readdir(source);26 const directories = await Promise.all(files.map(async (file) => {27 const res = source + '/' + file;28 return (await isDirectory(res)) ? res : res;29 }));30 return directories.filter((directory) => directory);31}32async function getFilesAndDirectoriesAndFiles(source) {33 const files = await readdir(source);34 const directories = await Promise.all(files.map(async (file) => {35 const res = source + '/' + file;36 return (await isDirectory(res)) ? res : res;37 }));38 return directories.filter((directory) => directory);39}40async function getAllFilesAndDirectories(source) {41 const files = await readdir(source);42 const directories = await Promise.all(files.map(async (file) => {43 const res = source + '/' + file;44 return (await isDirectory(res)) ? res : res;45 }));46 return directories.filter((directory) => directory);47}48async function getAllFilesAndDirectoriesAndFiles(source) {49 const files = await readdir(source);50 const directories = await Promise.all(files.map(async (file) => {51 const res = source + '/' + file;52 return (await isDirectory(res)) ? res : res;53 }));54 return directories.filter((directory) => directory);55}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require('qawolf');2const path = require('path');3const { promisify } = require('util');4const fs = require('fs');5const readdir = promisify(fs.readdir);6const getFiles = async () => {7 const filesInDir = await readdir(__dirname);8 console.log(filesInDir);9 const filteredFiles = await files.filter(__dirname, {10 });11 console.log(filteredFiles);12};13getFiles();

Full Screen

Using AI Code Generation

copy

Full Screen

1var files = require("qawolf/files");2var filteredFiles = files.filter("*.js");3console.log(filteredFiles);4var files = require("qawolf/files");5var filteredFiles = files.filter("*.js");6console.log(filteredFiles);7var files = require("qawolf/files");8var filteredFiles = files.filter("*.js");9console.log(filteredFiles);10var files = require("qawolf/files");11var filteredFiles = files.filter("*.js");12console.log(filteredFiles);13var files = require("qawolf/files");14var filteredFiles = files.filter("*.js");15console.log(filteredFiles);16var files = require("qawolf/files");17var filteredFiles = files.filter("*.js");18console.log(filteredFiles);19var files = require("qawolf/files");20var filteredFiles = files.filter("*.js");21console.log(filteredFiles);22var files = require("qawolf/files");23var filteredFiles = files.filter("*.js");24console.log(filteredFiles);25var files = require("qawolf/files");26var filteredFiles = files.filter("*.js");27console.log(filteredFiles);28var files = require("qawolf/files");29var filteredFiles = files.filter("*.js");30console.log(filteredFiles);31var files = require("qawolf/files");32var filteredFiles = files.filter("*.js");33console.log(filteredFiles);34var files = require("qawolf/files");35var filteredFiles = files.filter("*.js");36console.log(filteredFiles);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require('qawolf');2const fs = require('fs');3const path = require('path');4files.filter(__dirname).then(files => {5 fs.readdir(__dirname, (err, files) => {6 files.forEach(file => {7 const ext = path.extname(file);8 if (ext === '.js') {9 console.log(file);10 }11 });12 });13});14{15 "scripts": {16 },17 "dependencies": {18 }19}20const { files } = require('qawolf');21const fs = require('fs');22const path = require('path');23files.filter(__dirname).then(files => {24 fs.readdir(__dirname, (err, files) => {25 files.forEach(file => {26 const ext = path.extname(file);27 if (ext === '.js') {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require('qawolf');2const filteredFiles = files.filter((file) => file.includes('myFile'));3console.log(filteredFiles);4const { files } = require('qawolf');5const foundFile = files.find((file) => file.includes('myFile'));6console.log(foundFile);7const { files } = require('qawolf');8const foundFile = files.find((file) => file.includes('myFile'));9console.log(foundFile);10const { files } = require('qawolf');11const mappedFiles = files.map((file) => file.split('.')[0]);12console.log(mappedFiles);13const { files } = require('qawolf');14const hasSomeFiles = files.some((file) => file.includes('myFile'));15console.log(hasSomeFiles);16const { files } = require('qawolf');17const hasEveryFile = files.every((file) => file.includes('myFile'));18console.log(hasEveryFile);19const { files } = require('qawolf');20const reducedFiles = files.reduce((acc, file) => {21 const [fileName, fileExt] = file.split('.');22 return {23 };24}, {});25console.log(reducedFiles);26const { files } = require('qawolf');27files.forEach((file) => console.log(file));28const { files } = require('qawolf');29const hasFile = files.includes('myFile');30console.log(hasFile);31const { files } = require('qawolf');32const sortedFiles = files.sort((a, b) => a.localeCompare(b));33console.log(sortedFiles);

Full Screen

Using AI Code Generation

copy

Full Screen

1const files = require('qawolf/files');2const filteredFiles = files.filter('/path/to/dir', (file, index) => {3 return true;4});5console.log(filteredFiles);6const files = require('qawolf/files');7const file = files.find('/path/to/dir', (file, index) => {8 return true;9});10console.log(file);11const files = require('qawolf/files');12const file = files.read('/path/to/dir');13console.log(file);14const files = require('qawolf/files');15const file = files.readJson('/path/to/dir');16console.log(file);17const files = require('qawolf/files');18const file = files.readText('/path/to/dir');19console.log(file);20const files = require('qawolf/files');21const file = files.remove('/path/to/dir');22console.log(file);23const files = require('qawolf/files');24const file = files.write('/path/to/dir', 'content');25console.log(file);26const files = require('qawolf/files');27const file = files.writeJson('/path/to/dir', { key: 'value' });28console.log(file);29const files = require('qawolf/files');30const file = files.writeText('/path/to/dir', 'content');31console.log(file);32const files = require('qawolf/files');33const file = files.writeZip('/path/to/dir', 'content');34console.log(file);35const { generate

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require("qawolf");2const { join } = require("path");3const testPath = join(__dirname, "test.js");4const filtered = files.filter(testPath);5console.log(filtered);6const { files } = require("qawolf");7const { join } = require("path");8const testPath = join(__dirname, "test.js");9const found = files.find(testPath);10console.log(found);11const { files } = require("qawolf");12const { join } = require("path");13const testPath = join(__dirname, "test.js");14const found = files.find(testPath);15console.log(found);16const { files } = require("qawolf");17const { join } = require("path");18const testPath = join(__dirname, "test.js");19const found = files.find(testPath);20console.log(found);21const { files } = require("qawolf");22const { join } = require("path");23const testPath = join(__dirname, "test.js");24const found = files.find(testPath);25console.log(found);26const { files } = require("qawolf");27const { join } = require("path");28const testPath = join(__dirname, "test.js");29const found = files.find(testPath);30console.log(found);31const { files } = require("qawolf

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require("qawolf");2const filteredFiles = files.filter((file) => file.includes("test"));3console.log(filteredFiles);4const { files } = require("qawolf");5const foundFile = files.find((file) => file.includes("test"));6console.log(foundFile);7const { files } = require("qawolf");8const foundFile = files.find((file) => file.includes("test"));9console.log(foundFile);10const { files } = require("qawolf");11const foundFile = files.find((file) => file.includes("test"));12console.log(foundFile);13const { files } = require("qawolf");14const foundFile = files.find((file) => file.includes("test"));15console.log(foundFile);16const { files } = require("qawolf");17const foundFile = files.find((file) => file.includes("test"));18console.log(foundFile);19const { files } = require("qawolf");20const foundFile = files.find((file) => file.includes("test"));21console.log(foundFile);22const { files } = require("qawolf");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { files } = require("@qawolf/files");2const fileList = files.filter({3});4console.log(fileList);5[ { name: 'test.js',6 modified: 2020-03-31T18:30:38.000Z },7 { name: 'test.txt',8 modified: 2020-03-31T18:30:38.000Z } ]9const fileList = files.filter({10});11console.log(fileList);12[ { name: 'test.js',13 modified: 2020-03-31T18:30:38.000Z },14 { name: 'test.txt',15 modified: 2020-03-31T18:30:38.000Z } ]16const fileList = files.filter({17});18console.log(fileList);19[ { name: 'test.js',

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 qawolf 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