How to use putObject method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

iam-statement.js

Source:iam-statement.js Github

copy

Full Screen

1'use strict';2const assert = require('assert').strict;3const { iamStatement } = require('../../.././../lib/plugins/core');4describe('Core plugins', () => {5 describe('IAM Statement', () => {6 it('Should throw if an empty effect is passed', () => {7 assert.throws(() => iamStatement({}, {8 effect: '',9 action: 's3:putObject',10 resource: 'my-bucket-resource'11 }));12 });13 it('Should throw if an invalid effect is passed', () => {14 assert.throws(() => iamStatement({}, {15 effect: 'Not valid',16 action: 's3:putObject',17 resource: 'my-bucket-resource'18 }));19 });20 it('Should throw if no action is passed', () => {21 assert.throws(() => iamStatement({}, {22 effect: 'Allow',23 resource: 'my-bucket-resource'24 }));25 });26 it('Should throw if an invalid action is passed', () => {27 assert.throws(() => iamStatement({}, {28 effect: 'Allow',29 action: { foo: 'bar' },30 resource: 'my-bucket-resource'31 }));32 });33 it('Should throw if some valid and some invalid actions are passed', () => {34 assert.throws(() => iamStatement({}, {35 effect: 'Allow',36 action: ['s3:putObject', { foo: 'bar' }],37 resource: 'my-bucket-resource'38 }));39 });40 it('Should throw if no resource is passed', () => {41 assert.throws(() => iamStatement({}, {42 effect: 'Allow',43 action: 's3:putObject'44 }));45 });46 it('Should throw if an invalid resource is passed', () => {47 assert.throws(() => iamStatement({}, {48 effect: 'Allow',49 action: 's3:putObject',50 resource: { foo: 'bar' }51 }));52 });53 it('Should throw if some valid and some invalid resources are passed', () => {54 assert.throws(() => iamStatement({}, {55 effect: 'Allow',56 action: 's3:putObject',57 resource: ['my-bucket-resource', { foo: 'bar' }]58 }));59 });60 it('Should generate a new statement with the default effect', () => {61 const result = iamStatement({}, {62 action: 's3:putObject',63 resource: 'my-bucket-resource'64 });65 assert.deepStrictEqual(result, {66 provider: {67 iamRoleStatements: [68 {69 Effect: 'Allow',70 Action: 's3:putObject',71 Resource: 'my-bucket-resource'72 }73 ]74 }75 });76 });77 it('Should generate a new statement with one action and resource', () => {78 const result = iamStatement({}, {79 effect: 'Allow',80 action: 's3:putObject',81 resource: 'my-bucket-resource'82 });83 assert.deepStrictEqual(result, {84 provider: {85 iamRoleStatements: [86 {87 Effect: 'Allow',88 Action: 's3:putObject',89 Resource: 'my-bucket-resource'90 }91 ]92 }93 });94 });95 it('Should generate a new statement with multiple actions and resources', () => {96 const result = iamStatement({}, {97 effect: 'Allow',98 action: ['s3:putObject', 's3:getObject'],99 resource: ['my-bucket-resource', 'my-other-bucket-resource']100 });101 assert.deepStrictEqual(result, {102 provider: {103 iamRoleStatements: [104 {105 Effect: 'Allow',106 Action: ['s3:putObject', 's3:getObject'],107 Resource: ['my-bucket-resource', 'my-other-bucket-resource']108 }109 ]110 }111 });112 });113 it('Should append to previous IAM statements', () => {114 const result = iamStatement({115 provider: {116 iamRoleStatements: [117 {118 Effect: 'Allow',119 Action: 's3:putObject',120 Resource: 'my-previous-bucket-resource'121 }122 ]123 }124 }, {125 effect: 'Deny',126 action: 's3:putObject',127 resource: 'my-bucket-resource'128 });129 assert.deepStrictEqual(result, {130 provider: {131 iamRoleStatements: [132 {133 Effect: 'Allow',134 Action: 's3:putObject',135 Resource: 'my-previous-bucket-resource'136 },137 {138 Effect: 'Deny',139 Action: 's3:putObject',140 Resource: 'my-bucket-resource'141 }142 ]143 }144 });145 });146 context('When a custom role is defined', () => {147 it('Should throw if custom role is not a string', () => {148 assert.throws(() => iamStatement({149 provider: {150 role: ['ServiceExecutionRole']151 }152 }, {153 action: 's3:putObject',154 resource: 'my-bucket-resource'155 }));156 });157 it('Should throw if custom role is an external ARN', () => {158 assert.throws(() => iamStatement({159 provider: {160 role: 'aws:arn:xxxxxxx:some:resource'161 }162 }, {163 action: 's3:putObject',164 resource: 'my-bucket-resource'165 }));166 });167 it('Should throw if resources property is not defined', () => {168 assert.throws(() => iamStatement({169 provider: {170 role: 'ServiceExecutionRole'171 }172 }, {173 action: 's3:putObject',174 resource: 'my-bucket-resource'175 }));176 });177 it('Should throw if resources.Resources property is not defined', () => {178 assert.throws(() => iamStatement({179 provider: {180 role: 'ServiceExecutionRole'181 },182 resources: {}183 }, {184 action: 's3:putObject',185 resource: 'my-bucket-resource'186 }));187 });188 it('Should throw if the role is not in the Resources (as object)', () => {189 assert.throws(() => iamStatement({190 provider: {191 role: 'ServiceExecutionRole'192 },193 resources: {194 Resources: {195 MyBucket: {196 Type: 'AWS::Bucket'197 }198 }199 }200 }, {201 action: 's3:putObject',202 resource: 'my-bucket-resource'203 }));204 });205 it('Should throw if the role is not in the Resources (as array of objects)', () => {206 assert.throws(() => iamStatement({207 provider: {208 role: 'ServiceExecutionRole'209 },210 resources: {211 Resources: [212 {213 MyBucket: {214 Type: 'AWS::Bucket'215 }216 }217 ]218 }219 }, {220 action: 's3:putObject',221 resource: 'my-bucket-resource'222 }));223 });224 it('Should create and update the policy on consecutive calls if the role resource is found in the Resources (as object)', () => {225 const result = iamStatement(iamStatement({226 provider: {227 role: 'ServiceExecutionRole'228 },229 resources: {230 Resources: {231 ServiceExecutionRole: {232 Type: 'AWS::IAM::Role',233 Properties: {234 RoleName: 'MyCustomService-lambdaRole',235 Path: '/',236 AssumeRolePolicyDocument: {237 Version: '2012-10-17',238 Statement: [239 {240 Effect: 'Allow',241 Principal: {242 Service: [243 'lambda.amazonaws.com'244 ]245 },246 Action: 'sts:AssumeRole'247 }248 ]249 },250 Policies: [251 {252 PolicyName: 'some-other-policy',253 PolicyDocument: {254 Version: '2012-10-17',255 Statement: [256 {257 Effect: 'Allow',258 Action: [259 'logs:CreateLogGroup',260 'logs:CreateLogStream',261 'logs:PutLogEvents'262 ],263 Resource: [264 {265 'Fn::Join': [266 ':',267 [268 'arn:aws:logs',269 { Ref: 'AWS::Region' },270 { Ref: 'AWS::AccountId' },271 'log-group:/aws/lambda/*:*'272 ]273 ]274 }275 ]276 }277 ]278 }279 }280 ]281 }282 }283 }284 }285 }, {286 action: 's3:putObject',287 resource: 'my-bucket-resource'288 }), {289 action: 's3:getObject',290 resource: 'my-bucket-resource'291 });292 assert.deepStrictEqual(result, {293 provider: {294 role: 'ServiceExecutionRole'295 },296 resources: {297 Resources: {298 ServiceExecutionRole: {299 Type: 'AWS::IAM::Role',300 Properties: {301 RoleName: 'MyCustomService-lambdaRole',302 Path: '/',303 AssumeRolePolicyDocument: {304 Version: '2012-10-17',305 Statement: [306 {307 Effect: 'Allow',308 Principal: {309 Service: [310 'lambda.amazonaws.com'311 ]312 },313 Action: 'sts:AssumeRole'314 }315 ]316 },317 Policies: [318 {319 PolicyName: 'some-other-policy',320 PolicyDocument: {321 Version: '2012-10-17',322 Statement: [323 {324 Effect: 'Allow',325 Action: [326 'logs:CreateLogGroup',327 'logs:CreateLogStream',328 'logs:PutLogEvents'329 ],330 Resource: [331 {332 'Fn::Join': [333 ':',334 [335 'arn:aws:logs',336 { Ref: 'AWS::Region' },337 { Ref: 'AWS::AccountId' },338 'log-group:/aws/lambda/*:*'339 ]340 ]341 }342 ]343 }344 ]345 }346 },347 {348 PolicyName: 'sls-helper-custom-policy',349 PolicyDocument: {350 Version: '2012-10-17',351 Statement: [352 {353 Effect: 'Allow',354 Action: 's3:putObject',355 Resource: 'my-bucket-resource'356 },357 {358 Effect: 'Allow',359 Action: 's3:getObject',360 Resource: 'my-bucket-resource'361 }362 ]363 }364 }365 ]366 }367 }368 }369 }370 });371 });372 it('Should create and update the policy on consecutive calls if the role resource is found in the Resources (as array of object)', () => {373 const result = iamStatement(iamStatement({374 provider: {375 role: 'ServiceExecutionRole'376 },377 resources: {378 Resources: [{379 ServiceExecutionRole: {380 Type: 'AWS::IAM::Role',381 Properties: {382 RoleName: 'MyCustomService-lambdaRole',383 Path: '/',384 AssumeRolePolicyDocument: {385 Version: '2012-10-17',386 Statement: [387 {388 Effect: 'Allow',389 Principal: {390 Service: [391 'lambda.amazonaws.com'392 ]393 },394 Action: 'sts:AssumeRole'395 }396 ]397 },398 Policies: [399 {400 PolicyName: 'some-other-policy',401 PolicyDocument: {402 Version: '2012-10-17',403 Statement: [404 {405 Effect: 'Allow',406 Action: [407 'logs:CreateLogGroup',408 'logs:CreateLogStream',409 'logs:PutLogEvents'410 ],411 Resource: [412 {413 'Fn::Join': [414 ':',415 [416 'arn:aws:logs',417 { Ref: 'AWS::Region' },418 { Ref: 'AWS::AccountId' },419 'log-group:/aws/lambda/*:*'420 ]421 ]422 }423 ]424 }425 ]426 }427 }428 ]429 }430 }431 }]432 }433 }, {434 action: 's3:putObject',435 resource: 'my-bucket-resource'436 }), {437 action: 's3:getObject',438 resource: 'my-bucket-resource'439 });440 assert.deepStrictEqual(result, {441 provider: {442 role: 'ServiceExecutionRole'443 },444 resources: {445 Resources: [{446 ServiceExecutionRole: {447 Type: 'AWS::IAM::Role',448 Properties: {449 RoleName: 'MyCustomService-lambdaRole',450 Path: '/',451 AssumeRolePolicyDocument: {452 Version: '2012-10-17',453 Statement: [454 {455 Effect: 'Allow',456 Principal: {457 Service: [458 'lambda.amazonaws.com'459 ]460 },461 Action: 'sts:AssumeRole'462 }463 ]464 },465 Policies: [466 {467 PolicyName: 'some-other-policy',468 PolicyDocument: {469 Version: '2012-10-17',470 Statement: [471 {472 Effect: 'Allow',473 Action: [474 'logs:CreateLogGroup',475 'logs:CreateLogStream',476 'logs:PutLogEvents'477 ],478 Resource: [479 {480 'Fn::Join': [481 ':',482 [483 'arn:aws:logs',484 { Ref: 'AWS::Region' },485 { Ref: 'AWS::AccountId' },486 'log-group:/aws/lambda/*:*'487 ]488 ]489 }490 ]491 }492 ]493 }494 },495 {496 PolicyName: 'sls-helper-custom-policy',497 PolicyDocument: {498 Version: '2012-10-17',499 Statement: [500 {501 Effect: 'Allow',502 Action: 's3:putObject',503 Resource: 'my-bucket-resource'504 },505 {506 Effect: 'Allow',507 Action: 's3:getObject',508 Resource: 'my-bucket-resource'509 }510 ]511 }512 }513 ]514 }515 }516 }]517 }518 });519 });520 });521 });...

Full Screen

Full Screen

AmazonStorage.test.js

Source:AmazonStorage.test.js Github

copy

Full Screen

1import fs from 'fs';2import { assert } from 'chai';3import sinon from 'sinon';4import AmazonStorage from '../../src/AmazonStorage';5describe('AmazonStorage', () => {6 it('Should properly export Amazon Storage Service', () => {7 assert.isFunction(AmazonStorage);8 });9 it('Should properly create Amazon Storage', () => {10 let storage = new AmazonStorage();11 assert.instanceOf(storage, AmazonStorage);12 });13 it('Should properly upload file', done => {14 let storage = new AmazonStorage();15 sinon.stub(storage.getProvider(), 'putObject', (config, cb) => cb(null, 'RESULT'));16 storage17 .upload(new Buffer('test'), 'BUCKET:KEY')18 .then(result => {19 assert.equal(result, 'RESULT');20 assert.ok(storage.getProvider().putObject.calledOnce);21 assert.deepEqual(storage.getProvider().putObject.getCall(0).args[0], {22 Bucket: 'BUCKET',23 Key: 'KEY',24 Body: new Buffer('test')25 });26 assert.isFunction(storage.getProvider().putObject.getCall(0).args[1]);27 storage.getProvider().putObject.restore();28 done();29 })30 .catch(done);31 });32 it('Should properly upload without specifying bucket in .upload()', done => {33 let storage = new AmazonStorage({34 bucket: 'BUCKET'35 });36 sinon.stub(storage.getProvider(), 'putObject', (config, cb) => cb(null, 'RESULT'));37 storage38 .upload(new Buffer('test'), 'KEY')39 .then(result => {40 assert.equal(result, 'RESULT');41 assert.ok(storage.getProvider().putObject.calledOnce);42 assert.deepEqual(storage.getProvider().putObject.getCall(0).args[0], {43 Bucket: 'BUCKET',44 Key: 'KEY',45 Body: new Buffer('test')46 });47 assert.isFunction(storage.getProvider().putObject.getCall(0).args[1]);48 storage.getProvider().putObject.restore();49 done();50 })51 .catch(done);52 });53 it('Should properly upload source as a path to file', done => {54 let storage = new AmazonStorage();55 sinon.stub(storage.getProvider(), 'putObject', (config, cb) => cb(null, 'RESULT'));56 storage57 .upload('.editorconfig', 'BUCKET:KEY')58 .then(result => {59 assert.equal(result, 'RESULT');60 assert.ok(storage.getProvider().putObject.calledOnce);61 assert.deepEqual(storage.getProvider().putObject.getCall(0).args[0], {62 Bucket: 'BUCKET',63 Key: 'KEY',64 Body: fs.readFileSync('.editorconfig')65 });66 assert.isFunction(storage.getProvider().putObject.getCall(0).args[1]);67 storage.getProvider().putObject.restore();68 done();69 })70 .catch(done);71 });72 it('Should properly mixin other config in upload', done => {73 let storage = new AmazonStorage();74 sinon.stub(storage.getProvider(), 'putObject', (config, cb) => cb(null, 'RESULT'));75 storage76 .upload('.editorconfig', 'BUCKET:KEY', {77 ACL: 'public-read'78 })79 .then(result => {80 assert.equal(result, 'RESULT');81 assert.ok(storage.getProvider().putObject.calledOnce);82 assert.deepEqual(storage.getProvider().putObject.getCall(0).args[0], {83 Bucket: 'BUCKET',84 Key: 'KEY',85 Body: fs.readFileSync('.editorconfig'),86 ACL: 'public-read'87 });88 assert.isFunction(storage.getProvider().putObject.getCall(0).args[1]);89 storage.getProvider().putObject.restore();90 done();91 })92 .catch(done);93 });94 it('Should properly throw error if upload unknown type', () => {95 let storage = new AmazonStorage();96 assert.throws(() => storage.upload(true, 'BUCKET:KEY'), Error);97 });98 it('Should properly reject on file uploading', done => {99 let storage = new AmazonStorage();100 sinon.stub(storage.getProvider(), 'putObject', (config, cb) => cb('ERROR'));101 storage102 .upload(new Buffer('test'), 'BUCKET:KEY')103 .then(done)104 .catch(error => {105 assert.equal(error, 'ERROR');106 assert.ok(storage.getProvider().putObject.calledOnce);107 assert.deepEqual(storage.getProvider().putObject.getCall(0).args[0], {108 Bucket: 'BUCKET',109 Key: 'KEY',110 Body: new Buffer('test')111 });112 assert.isFunction(storage.getProvider().putObject.getCall(0).args[1]);113 storage.getProvider().putObject.restore();114 done();115 });116 });117 it('Should properly download file', done => {118 let storage = new AmazonStorage();119 sinon.stub(storage.getProvider(), 'getObject', (config, cb) => cb(null, 'OBJECT'));120 storage121 .download('BUCKET:KEY')122 .then(result => {123 assert.equal(result, 'OBJECT');124 assert.ok(storage.getProvider().getObject.calledOnce);125 assert.deepEqual(storage.getProvider().getObject.getCall(0).args[0], {126 Bucket: 'BUCKET',127 Key: 'KEY'128 });129 assert.isFunction(storage.getProvider().getObject.getCall(0).args[1]);130 storage.getProvider().getObject.restore();131 done();132 })133 .catch(done);134 });135 it('Should properly reject on downloading file', done => {136 let storage = new AmazonStorage();137 sinon.stub(storage.getProvider(), 'getObject', (config, cb) => cb('ERROR'));138 storage139 .download('BUCKET:KEY')140 .then(done)141 .catch(error => {142 assert.equal(error, 'ERROR');143 assert.ok(storage.getProvider().getObject.calledOnce);144 assert.deepEqual(storage.getProvider().getObject.getCall(0).args[0], {145 Bucket: 'BUCKET',146 Key: 'KEY'147 });148 assert.isFunction(storage.getProvider().getObject.getCall(0).args[1]);149 storage.getProvider().getObject.restore();150 done();151 });152 });153 it('Should properly remove file', done => {154 let storage = new AmazonStorage();155 sinon.stub(storage.getProvider(), 'deleteObject', (config, cb) => cb(null, 'OBJECT'));156 storage157 .remove('BUCKET:KEY')158 .then(result => {159 assert.equal(result, 'OBJECT');160 assert.ok(storage.getProvider().deleteObject.calledOnce);161 assert.deepEqual(storage.getProvider().deleteObject.getCall(0).args[0], {162 Bucket: 'BUCKET',163 Key: 'KEY'164 });165 assert.isFunction(storage.getProvider().deleteObject.getCall(0).args[1]);166 storage.getProvider().deleteObject.restore();167 done();168 })169 .catch(done);170 });171 it('Should properly reject on removing file', done => {172 let storage = new AmazonStorage();173 sinon.stub(storage.getProvider(), 'deleteObject', (config, cb) => cb('ERROR'));174 storage175 .remove('BUCKET:KEY')176 .then(done)177 .catch(error => {178 assert.equal(error, 'ERROR');179 assert.ok(storage.getProvider().deleteObject.calledOnce);180 assert.deepEqual(storage.getProvider().deleteObject.getCall(0).args[0], {181 Bucket: 'BUCKET',182 Key: 'KEY'183 });184 assert.isFunction(storage.getProvider().deleteObject.getCall(0).args[1]);185 storage.getProvider().deleteObject.restore();186 done();187 });188 });...

Full Screen

Full Screen

footer.component.ts

Source:footer.component.ts Github

copy

Full Screen

1import { Component, SimpleChanges, OnChanges, Input, HostListener } from '@angular/core';2import { LikesDislikesService } from '../services/likes-dislikes.service';3import { ILikesDislikesData } from '../models/likes-dislikes-data.model';4import { MatSnackBar } from '@angular/material';5@Component({6 selector: 'app-footer',7 templateUrl: './footer.component.html',8 styleUrls: ['./footer.component.scss']9})10export class FooterComponent implements OnChanges {11 @Input() pathString: string;12 projectData: ILikesDislikesData;13 putObject: ILikesDislikesData;14 currentProjectId: number = 1;15 noOfLikes: number = 0;16 noOfDislikes: number = 0;17 currentPath: string = "";18 flagCurrentPath: boolean = false;19 currentDate: Date;20 currentDateToPrint: string;21 public now: Date = new Date();22 constructor(private _likesDislikesService: LikesDislikesService,23 private _snackBar: MatSnackBar) { 24 setInterval(() => {25 this.now = new Date();26 }, 1);27 }28 29 ngOnChanges(changes: SimpleChanges) {30 for (let propName in changes) {31 let change = changes[propName];32 //console.log("Change: " + change.currentValue);33 this.currentPath = change.currentValue;34 this.flagCurrentPath = false;35 if (change.currentValue == "/solarproject") {36 this.flagCurrentPath = true;37 this.currentProjectId = 1;38 this._likesDislikesService.getLikesDislikes(this.currentProjectId).subscribe(39 (data) => {40 this.putObject = data;41 this.noOfLikes = this.putObject.likes;42 this.noOfDislikes = this.putObject.dislikes;43 }44 );45 }46 if (change.currentValue == "/cryptoproject") {47 this.flagCurrentPath = true;48 this.currentProjectId = 2;49 this._likesDislikesService.getLikesDislikes(this.currentProjectId).subscribe(50 (data) => {51 this.putObject = data;52 this.noOfLikes = this.putObject.likes;53 this.noOfDislikes = this.putObject.dislikes;54 }55 );56 }57 if (change.currentValue == "/temperatureproject") {58 this.flagCurrentPath = true;59 this.currentProjectId = 3;60 this._likesDislikesService.getLikesDislikes(this.currentProjectId).subscribe(61 (data) => {62 this.putObject = data;63 this.noOfLikes = this.putObject.likes;64 this.noOfDislikes = this.putObject.dislikes;65 }66 );67 }68 if (change.currentValue == "/gpsproject") {69 this.flagCurrentPath = true;70 this.currentProjectId = 4;71 this._likesDislikesService.getLikesDislikes(this.currentProjectId).subscribe(72 (data) => {73 this.putObject = data;74 this.noOfLikes = this.putObject.likes;75 this.noOfDislikes = this.putObject.dislikes;76 }77 );78 }79 }80 }81 likesIncrease(): void {82 if (sessionStorage.getItem(this.putObject.projectName + ' likes') === '1') {83 this.snackBarLike('Like button was already clicked!!', 'Close', 'arduino-snackbar');84 }85 if (sessionStorage.getItem(this.putObject.projectName + ' dislikes') === '1' && sessionStorage.getItem(this.putObject.projectName + ' likes') !== '1') {86 this.noOfDislikes--;87 this.putObject.dislikes = this.noOfDislikes;88 this._likesDislikesService.putLikesDislikes(this.putObject).subscribe(89 () => {90 sessionStorage.setItem(this.putObject.projectName + ' likes', '0');91 sessionStorage.setItem(this.putObject.projectName + ' dislikes', '0');92 }93 );94 }95 if (sessionStorage.getItem(this.putObject.projectName + ' likes') !== '1' && sessionStorage.getItem(this.putObject.projectName + ' dislikes') !== '1') {96 this.noOfLikes++;97 this.putObject.likes = this.noOfLikes;98 this._likesDislikesService.putLikesDislikes(this.putObject).subscribe(99 () => {100 sessionStorage.setItem(this.putObject.projectName + ' likes', '1');101 }102 );103 }104 }105 dislikesIncrease(): void {106 if (sessionStorage.getItem(this.putObject.projectName + ' dislikes') === '1') {107 this.snackBarDislike('Dislike button was already clicked!!', 'Close', 'arduino-snackbar');108 }109 if (sessionStorage.getItem(this.putObject.projectName + ' likes') === '1' && sessionStorage.getItem(this.putObject.projectName + ' dislikes') !== '1') {110 this.noOfLikes--;111 this.putObject.likes = this.noOfLikes;112 113 this._likesDislikesService.putLikesDislikes(this.putObject).subscribe(114 () => {115 sessionStorage.setItem(this.putObject.projectName + ' likes', '0');116 sessionStorage.setItem(this.putObject.projectName + ' dislikes', '0');117 }118 );119 }120 if (sessionStorage.getItem(this.putObject.projectName + ' dislikes') !== '1' && sessionStorage.getItem(this.putObject.projectName + ' likes') !== '1') {121 this.noOfDislikes++;122 this.putObject.dislikes = this.noOfDislikes;123 this._likesDislikesService.putLikesDislikes(this.putObject).subscribe(124 () => {125 sessionStorage.setItem(this.putObject.projectName + ' dislikes', '1');126 }127 );128 }129 }130 snackBarLike(message: string, action: string, className: string) {131 this._snackBar.open(message, action, {132 duration: 1000,133 panelClass: [className]134 });135 }136 snackBarDislike(message: string, action: string, className: string) {137 this._snackBar.open(message, action, {138 duration: 1000,139 panelClass: [className]140 });141 }142 dateAndTime(): void {143 console.log("Date and time invoked");144 this.currentDateToPrint = this.currentDate.toISOString();145 }146 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var fs = require('fs');3var client = stf.createClient({4});5client.connect().then(function() {6 var file = fs.createReadStream('D:\\test.txt');7 return client.putObject('test.txt', file);8}).then(function() {9 console.log('file uploaded');10}).catch(function(err) {11 console.error(err);12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var device = client.getDevice('emulator-5554');3device.putObject('test.txt', 'test content');4var stf = require('devicefarmer-stf-client');5var device = client.getDevice('emulator-5554');6device.getObject('/sdcard/test.txt', 'test.txt');7var stf = require('devicefarmer-stf-client');8var device = client.getDevice('emulator-5554');9device.deleteObject('/sdcard/test.txt');10var stf = require('devicefarmer-stf-client');11var device = client.getDevice('emulator-5554');12device.getLog(function(err, data) {13 console.log(data);14});15var stf = require('devicefarmer-stf-client');16var device = client.getDevice('emulator-5554');17device.getLog(function(err, data) {18 console.log(data);19});20var stf = require('devicefarmer-stf-client');21var device = client.getDevice('emulator-5554');22device.getLog(function(err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var client = stf.connect({ host: 'localhost', port: 7100 });3var device = client.getDevice(1);4var file = '/Users/username/Downloads/test.png';5var remotePath = '/sdcard/test.png';6device.putObject(file, remotePath, function(err, data) {7 if (err) {8 console.log(err);9 } else {10 console.log(data);11 }12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var obj = {3};4client.putObject(obj, function(err, res){5 if(err){6 console.log("Error: ", err);7 } else {8 console.log("Response: ", res);9 }10});11var client = require('devicefarmer-stf-client');12client.getObject("device", "emulator-5554", function(err, res){13 if(err){14 console.log("Error: ", err);15 } else {16 console.log("Response: ", res);17 }18});19var client = require('devicefarmer-stf-client');20client.deleteObject("device", "emulator-5554", function(err, res){21 if(err){22 console.log("Error: ", err);23 } else {24 console.log("Response: ", res);25 }26});27var client = require('devicefarmer-stf-client');28client.getObjects("device", function(err, res){29 if(err){30 console.log("Error: ", err);31 } else {32 console.log("Response: ", res);33 }34});35var client = require('devicefarmer-stf-client');36client.getObjects("device", function(err, res){37 if(err){38 console.log("Error: ", err);39 } else {40 console.log("Response: ", res);41 }42});43var client = require('devicefarmer-stf-client');44client.getObjects("device", function(err, res){45 if(err){46 console.log("Error: ", err);47 } else {48 console.log("Response: ", res);49 }50});51var client = require('devicefarmer-stf-client');52client.getObjects("device",

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var deviceId = 'device-id';3var filePath = 'file-path';4var remotePath = 'remote-path';5var mode = 'mode';6var owner = 'owner';7var group = 'group';8var size = 'size';9var mtime = 'mtime';10var atime = 'atime';11var ctime = 'ctime';12var type = 'type';

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 devicefarmer-stf 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