How to use createEnvironmentVariable method in qawolf

Best JavaScript code snippet using qawolf

Serializer.spec.js

Source:Serializer.spec.js Github

copy

Full Screen

1/* eslint-disable max-nested-callbacks */2import expect, { spyOn, restoreSpies } from 'expect'3import { OrderedMap, List } from 'immutable'4import { DynamicString, DynamicValue, RecordParameter } from '../../../mocks/PawMocks'5import Api from '../../../models/Api'6import Info from '../../../models/Info'7import Store from '../../../models/Store'8import Constraint from '../../../models/Constraint'9import URLComponent from '../../../models/URLComponent'10import URL from '../../../models/URL'11import Parameter from '../../../models/Parameter'12import Auth from '../../../models/Auth'13import Variable from '../../../models/Variable'14import Reference from '../../../models/Reference'15import ParameterContainer from '../../../models/ParameterContainer'16import Context from '../../../models/Context'17import Request from '../../../models/Request'18import Resource from '../../../models/Resource'19import Group from '../../../models/Group'20import Serializer, { __internals__ } from '../Serializer'21describe('serializers/paw/Serializer.js', () => {22 afterEach(() => restoreSpies())23 describe('{ Serializer }', () => {24 describe('@serialize', () => {25 it('should call __internals__.serialize', () => {26 const expected = 123427 spyOn(__internals__, 'serialize').andReturn(expected)28 const actual = Serializer.serialize()29 expect(__internals__.serialize).toHaveBeenCalled()30 expect(actual).toEqual(expected)31 })32 it('should call __internals__.serialize with the correct arguments', () => {33 const expected = 123434 spyOn(__internals__, 'serialize').andReturn(expected)35 const args = { options: { context: 123, items: 321 }, api: 234 }36 const actual = Serializer.serialize(args)37 expect(__internals__.serialize).toHaveBeenCalledWith(args)38 expect(actual).toEqual(expected)39 })40 })41 })42 describe('@wrapDV', () => {43 it('should return a DynamicString', () => {44 const dv = new DynamicValue('some.dv.name', {})45 const actual = __internals__.wrapDV(dv)46 expect(actual).toBeA(DynamicString)47 })48 it('should work', () => {49 const dv = new DynamicValue('some.dv.name', {})50 const expected = new DynamicString(dv)51 const actual = __internals__.wrapDV(dv)52 expect(actual).toEqual(expected)53 })54 })55 describe('@createJSONDV', () => {56 it('should return a DynamicValue', () => {57 const json = { some: 'json' }58 const actual = __internals__.createJSONDV(json)59 expect(actual).toBeA(DynamicValue)60 })61 it('should work', () => {62 const json = { some: 'json' }63 const expected = new DynamicValue('com.luckymarmot.JSONDynamicValue', {64 json: '{"some":"json"}'65 })66 const actual = __internals__.createJSONDV(json)67 expect(actual).toEqual(expected)68 })69 })70 describe('@createUrlEncodedBodyDV', () => {71 it('should return a DynamicValue', () => {72 const keyValues = [ new RecordParameter(123, 321, true) ]73 const actual = __internals__.createUrlEncodedBodyDV(keyValues)74 expect(actual).toBeA(DynamicValue)75 })76 it('should work', () => {77 const keyValues = [ new RecordParameter(123, 321, true) ]78 const expected = new DynamicValue(79 'com.luckymarmot.BodyFormKeyValueDynamicValue', {80 keyValues: keyValues81 }82 )83 const actual = __internals__.createUrlEncodedBodyDV(keyValues)84 expect(actual).toEqual(expected)85 })86 })87 describe('@createMultipartBodyDV', () => {88 it('should return a DynamicValue', () => {89 const keyValues = [ new RecordParameter(123, 321, true) ]90 const actual = __internals__.createMultipartBodyDV(keyValues)91 expect(actual).toBeA(DynamicValue)92 })93 it('should work', () => {94 const keyValues = [ new RecordParameter(123, 321, true) ]95 const expected = new DynamicValue(96 'com.luckymarmot.BodyMultipartFormDataDynamicValue', {97 keyValues: keyValues98 }99 )100 const actual = __internals__.createMultipartBodyDV(keyValues)101 expect(actual).toEqual(expected)102 })103 })104 describe('@createMultiSelectorDv', () => {105 it('should work', () => {106 const inputs = [107 [ 123, 234, 345 ]108 ]109 const expected = [110 new DynamicValue('me.elliotchance.MultiSelectorDynamicValue', {111 choices: [ 123, 234, 345 ],112 separator: ','113 })114 ]115 const actual = inputs.map(input => __internals__.createMultiSelectorDv(input))116 expect(actual).toEqual(expected)117 })118 })119 describe('@getTitleFromApi', () => {120 it('should work', () => {121 const api = new Api({122 info: new Info({123 title: 'this should work'124 })125 })126 const expected = 'this should work'127 const actual = __internals__.getTitleFromApi(api)128 expect(actual).toEqual(expected)129 })130 it('should work if no title', () => {131 const api = new Api({132 info: new Info({133 title: null134 })135 })136 const expected = 'Imports'137 const actual = __internals__.getTitleFromApi(api)138 expect(actual).toEqual(expected)139 })140 })141 describe('@createStandardEnvironmentDomain', () => {142 it('should call getTitleFromApi', () => {143 spyOn(__internals__, 'getTitleFromApi').andReturn('hello')144 const context = {145 createEnvironmentDomain: () => {}146 }147 spyOn(context, 'createEnvironmentDomain').andReturn('done')148 const api = new Api()149 __internals__.createStandardEnvironmentDomain(context, api)150 expect(__internals__.getTitleFromApi).toHaveBeenCalledWith(api)151 })152 it('should call context.createEnvironmentDomain', () => {153 spyOn(__internals__, 'getTitleFromApi').andReturn('hello')154 const context = {155 createEnvironmentDomain: () => {}156 }157 spyOn(context, 'createEnvironmentDomain').andReturn('done')158 const api = new Api()159 __internals__.createStandardEnvironmentDomain(context, api)160 expect(context.createEnvironmentDomain).toHaveBeenCalledWith('hello')161 })162 })163 describe('@getStandardEnvironmentDomainSize', () => {164 it('should return 0 if no record in store', () => {165 const api = new Api({166 store: new Store()167 })168 const expected = 0169 const actual = __internals__.getStandardEnvironmentDomainSize(api)170 expect(actual).toEqual(expected)171 })172 it('should return 0 if only variable in store', () => {173 const api = new Api({174 store: new Store({175 variable: new OrderedMap({176 abc: 123,177 bca: 231178 })179 })180 })181 const expected = 0182 const actual = __internals__.getStandardEnvironmentDomainSize(api)183 expect(actual).toEqual(expected)184 })185 it('should work otherwise', () => {186 const api = new Api({187 store: new Store({188 endpoint: new OrderedMap({ abc: 123, cba: 321 }),189 auth: new OrderedMap({ qwe: 234, ewq: 432 }),190 variable: new OrderedMap({ asd: 345, dsa: 543 })191 })192 })193 const expected = 4194 const actual = __internals__.getStandardEnvironmentDomainSize(api)195 expect(actual).toEqual(expected)196 })197 })198 describe('@needsStandardEnvironmentDomain', () => {199 it('should return false if domain size is 0', () => {200 spyOn(__internals__, 'getStandardEnvironmentDomainSize').andReturn(0)201 const api = new Api()202 const expected = false203 const actual = __internals__.needsStandardEnvironmentDomain(api)204 expect(__internals__.getStandardEnvironmentDomainSize).toHaveBeenCalled()205 expect(actual).toEqual(expected)206 })207 it('should return true if domain size is 1 or more', () => {208 spyOn(__internals__, 'getStandardEnvironmentDomainSize').andReturn(10)209 const api = new Api()210 const expected = true211 const actual = __internals__.needsStandardEnvironmentDomain(api)212 expect(__internals__.getStandardEnvironmentDomainSize).toHaveBeenCalled()213 expect(actual).toEqual(expected)214 })215 })216 describe('@createVariableEnvironmentDomain', () => {217 it('should call getTitleFromApi', () => {218 spyOn(__internals__, 'getTitleFromApi').andReturn('hello')219 const context = {220 createEnvironmentDomain: () => {}221 }222 spyOn(context, 'createEnvironmentDomain').andReturn('done')223 const api = new Api()224 __internals__.createVariableEnvironmentDomain(context, api)225 expect(__internals__.getTitleFromApi).toHaveBeenCalledWith(api)226 })227 it('should call context.createEnvironmentDomain', () => {228 spyOn(__internals__, 'getTitleFromApi').andReturn('hello')229 const context = {230 createEnvironmentDomain: () => {}231 }232 spyOn(context, 'createEnvironmentDomain').andReturn('done')233 const api = new Api()234 __internals__.createVariableEnvironmentDomain(context, api)235 expect(context.createEnvironmentDomain).toHaveBeenCalledWith('Vars - hello')236 })237 })238 describe('@addConstraintToDomain', () => {239 /* eslint-disable max-statements */240 it('should work if underlying methods are correct', () => {241 const domain = { createEnvironmentVariable: () => {} }242 const environment = {}243 const constraint = new Constraint.JSONSchema({ type: 'string' })244 const key = 'User'245 const variable = { setValue: () => {} }246 spyOn(domain, 'createEnvironmentVariable').andReturn(variable)247 spyOn(variable, 'setValue').andReturn(null)248 spyOn(__internals__, 'createJSONDV').andCallThrough()249 spyOn(__internals__, 'wrapDV').andReturn('123')250 const expected = variable251 const actual = __internals__.addConstraintToDomain(domain, environment, constraint, key)252 expect(domain.createEnvironmentVariable).toHaveBeenCalledWith(key)253 expect(__internals__.createJSONDV).toHaveBeenCalledWith({ type: 'string' })254 expect(__internals__.wrapDV).toHaveBeenCalled()255 expect(variable.setValue).toHaveBeenCalledWith('123', environment)256 expect(actual).toEqual(expected)257 })258 /* eslint-enable max-statements */259 })260 describe('@addConstraintsToDomain', () => {261 it('should work if underlying methods are correct', () => {262 spyOn(__internals__, 'addConstraintToDomain').andReturn('test')263 const domain = {}264 const environment = {}265 const api = new Api({266 store: new Store({267 constraint: new OrderedMap({268 abc: 123,269 bca: 231270 })271 })272 })273 const expected = new OrderedMap({ abc: 'test', bca: 'test' })274 const actual = __internals__.addConstraintsToDomain(domain, environment, api)275 expect(__internals__.addConstraintToDomain.calls.length).toEqual(2)276 expect(actual).toEqual(expected)277 })278 })279 describe('@removeDotsFromProtocol', () => {280 it('should work', () => {281 const input = [ 'http', 'https:' ]282 const expected = [ 'http', 'https' ]283 const actual = input.map(__internals__.removeDotsFromProtocol)284 expect(actual).toEqual(expected)285 })286 })287 describe('@convertProtocolIntoRecordParameter', () => {288 it('should work', () => {289 const inputs = [290 [ 'http', 0 ],291 [ 'https:', 1 ]292 ]293 const expected = [294 new RecordParameter('http', ', ', true),295 new RecordParameter('https', ', ', false)296 ]297 const actual = inputs.map(input => __internals__.convertProtocolIntoRecordParameter(...input))298 expect(actual).toEqual(expected)299 })300 })301 describe('@createProtocolDV', () => {302 it('should work if no protocol', () => {303 const protocol = null304 const expected = 'http'305 const actual = __internals__.createProtocolDV(protocol)306 expect(actual).toEqual(expected)307 })308 it('should work if single protocol', () => {309 const protocol = List([ 'https:' ])310 const expected = 'https'311 const actual = __internals__.createProtocolDV(protocol)312 expect(actual).toEqual(expected)313 })314 it('should work if multiple protocol', () => {315 spyOn(__internals__, 'convertProtocolIntoRecordParameter').andReturn(123)316 spyOn(__internals__, 'createMultiSelectorDv').andReturn(321)317 const protocol = List([ 'https:', 'http' ])318 const expected = 321319 const actual = __internals__.createProtocolDV(protocol)320 expect(__internals__.convertProtocolIntoRecordParameter.calls.length).toEqual(2)321 expect(__internals__.createMultiSelectorDv).toHaveBeenCalledWith([ 123, 123 ])322 expect(actual).toEqual(expected)323 })324 })325 describe('@convertURLComponentToDynamicString', () => {326 it('should work', () => {327 const urlComponent = new URLComponent({328 componentName: 'pathname',329 string: '/some/path',330 variableDelimiters: List([ '{', '}' ])331 })332 const expected = '/some/path'333 const actual = __internals__.convertURLComponentToDynamicString(urlComponent)334 expect(actual).toEqual(expected)335 })336 })337 describe('@createEndpointDynamicString', () => {338 it('should work', () => {339 const endpoint = new URL({340 url: 'https://echo.paw.cloud/{version}/users',341 variableDelimiters: List([ '{', '}' ])342 })343 const expected = new DynamicString(344 'https',345 '://',346 'echo.paw.cloud',347 '', '',348 '/{version}/users'349 )350 const actual = __internals__.createEndpointDynamicString(endpoint)351 expect(actual).toEqual(expected)352 })353 it('should work with port and dirty path', () => {354 const endpoint = new URL({355 url: 'https://echo.paw.cloud:8080/{version}/users/',356 variableDelimiters: List([ '{', '}' ])357 })358 const expected = new DynamicString(359 'https',360 '://',361 'echo.paw.cloud',362 ':', '8080',363 '/{version}/users'364 )365 const actual = __internals__.createEndpointDynamicString(endpoint)366 expect(actual).toEqual(expected)367 })368 })369 describe('@addEndpointToDomain', () => {370 /* eslint-disable max-statements */371 it('should work', () => {372 const domain = { createEnvironmentVariable: () => {} }373 const environment = {}374 const endpoint = new URL({375 url: 'https://echo.paw.cloud'376 })377 const key = 'server1'378 const variable = { setValue: () => {} }379 spyOn(domain, 'createEnvironmentVariable').andReturn(variable)380 spyOn(variable, 'setValue').andReturn(null)381 spyOn(__internals__, 'createEndpointDynamicString').andReturn('123')382 const expected = variable383 const actual = __internals__.addEndpointToDomain(domain, environment, endpoint, key)384 expect(domain.createEnvironmentVariable).toHaveBeenCalledWith(key)385 expect(__internals__.createEndpointDynamicString).toHaveBeenCalledWith(endpoint)386 expect(variable.setValue).toHaveBeenCalledWith('123', environment)387 expect(actual).toEqual(expected)388 })389 /* eslint-enable max-statements */390 })391 describe('@addEndpointsToDomain', () => {392 it('should work if underlying methods are correct', () => {393 spyOn(__internals__, 'addEndpointToDomain').andReturn('test')394 const domain = {}395 const environment = {}396 const api = new Api({397 store: new Store({398 endpoint: new OrderedMap({399 abc: 123,400 bca: 231401 })402 })403 })404 const expected = new OrderedMap({ abc: 'test', bca: 'test' })405 const actual = __internals__.addEndpointsToDomain(domain, environment, api)406 expect(__internals__.addEndpointToDomain.calls.length).toEqual(2)407 expect(actual).toEqual(expected)408 })409 })410 describe('@addParameterToDomain', () => {411 /* eslint-disable max-statements */412 it('should work if underlying methods are correct', () => {413 const domain = { createEnvironmentVariable: () => {} }414 const environment = {}415 const parameter = new Parameter({ type: 'string' })416 const key = 'User'417 const variable = { setValue: () => {} }418 spyOn(domain, 'createEnvironmentVariable').andReturn(variable)419 spyOn(variable, 'setValue').andReturn(null)420 spyOn(__internals__, 'createJSONDV').andCallThrough()421 spyOn(__internals__, 'wrapDV').andReturn('123')422 const expected = { variable, parameter }423 const actual = __internals__.addParameterToDomain(domain, environment, parameter, key)424 expect(domain.createEnvironmentVariable).toHaveBeenCalledWith(key)425 expect(__internals__.createJSONDV).toHaveBeenCalledWith({ type: 'string' })426 expect(__internals__.wrapDV).toHaveBeenCalled()427 expect(variable.setValue).toHaveBeenCalledWith('123', environment)428 expect(actual).toEqual(expected)429 })430 /* eslint-enable max-statements */431 })432 describe('@addParametersToDomain', () => {433 it('should work if underlying methods are correct', () => {434 spyOn(__internals__, 'addParameterToDomain').andReturn('test')435 const domain = {}436 const environment = {}437 const api = new Api({438 store: new Store({439 parameter: new OrderedMap({440 abc: 123,441 bca: 231442 })443 })444 })445 const expected = new OrderedMap({ abc: 'test', bca: 'test' })446 const actual = __internals__.addParametersToDomain(domain, environment, api)447 expect(__internals__.addParameterToDomain.calls.length).toEqual(2)448 expect(actual).toEqual(expected)449 })450 })451 describe('@convertBasicAuthIntoDynamicValue', () => {452 it('should work', () => {453 const auth = new Auth.Basic({454 username: 'user',455 password: 'pass'456 })457 const expected = new DynamicValue('com.luckymarmot.BasicAuthDynamicValue', {458 username: 'user',459 password: 'pass'460 })461 const actual = __internals__.convertBasicAuthIntoDynamicValue(auth)462 expect(actual).toEqual(expected)463 })464 it('should work with defaults', () => {465 const auth = new Auth.Basic()466 const expected = new DynamicValue('com.luckymarmot.BasicAuthDynamicValue', {467 username: '',468 password: ''469 })470 const actual = __internals__.convertBasicAuthIntoDynamicValue(auth)471 expect(actual).toEqual(expected)472 })473 })474 describe('@convertDigestAuthIntoDynamicValue', () => {475 it('should work', () => {476 const auth = new Auth.Digest({477 username: 'user',478 password: 'pass'479 })480 const expected = new DynamicValue('com.luckymarmot.PawExtensions.DigestAuthDynamicValue', {481 username: 'user',482 password: 'pass'483 })484 const actual = __internals__.convertDigestAuthIntoDynamicValue(auth)485 expect(actual).toEqual(expected)486 })487 it('should work with defaults', () => {488 const auth = new Auth.Digest()489 const expected = new DynamicValue('com.luckymarmot.PawExtensions.DigestAuthDynamicValue', {490 username: '',491 password: ''492 })493 const actual = __internals__.convertDigestAuthIntoDynamicValue(auth)494 expect(actual).toEqual(expected)495 })496 })497 describe('@convertOAuth1AuthIntoDynamicValue', () => {498 it('should work', () => {499 const auth = new Auth.OAuth1({500 callback: 'https://echo.paw.cloud/callback',501 consumerSecret: 'consumerSecret',502 tokenSecret: 'tokenSecret',503 consumerKey: 'consumerKey',504 algorithm: 'md5',505 nonce: '12345',506 additionalParameters: 'none',507 timestamp: 'some date',508 token: 'some token'509 })510 const expected = new DynamicValue('com.luckymarmot.OAuth1HeaderDynamicValue', {511 callback: 'https://echo.paw.cloud/callback',512 consumerSecret: 'consumerSecret',513 tokenSecret: 'tokenSecret',514 consumerKey: 'consumerKey',515 algorithm: 'md5',516 nonce: '12345',517 additionalParameters: 'none',518 timestamp: 'some date',519 token: 'some token'520 })521 const actual = __internals__.convertOAuth1AuthIntoDynamicValue(auth)522 expect(actual).toEqual(expected)523 })524 it('should work with default', () => {525 const auth = new Auth.OAuth1()526 const expected = new DynamicValue('com.luckymarmot.OAuth1HeaderDynamicValue', {527 callback: '',528 consumerSecret: '',529 tokenSecret: '',530 consumerKey: '',531 algorithm: '',532 nonce: '',533 additionalParameters: '',534 timestamp: '',535 token: ''536 })537 const actual = __internals__.convertOAuth1AuthIntoDynamicValue(auth)538 expect(actual).toEqual(expected)539 })540 })541 describe('@convertOAuth2AuthIntoDynamicValue', () => {542 it('should work', () => {543 const auth = new Auth.OAuth2({544 authorizationUrl: 'https://echo.paw.cloud/auth-portal',545 tokenUrl: 'https://echo.paw.cloud/token-portal',546 flow: 'implicit',547 scopes: List([ { key: 'write:self' } ])548 })549 const expected = new DynamicValue('com.luckymarmot.OAuth2DynamicValue', {550 authorizationURL: 'https://echo.paw.cloud/auth-portal',551 accessTokenURL: 'https://echo.paw.cloud/token-portal',552 grantType: 1,553 scopes: 'write:self'554 })555 const actual = __internals__.convertOAuth2AuthIntoDynamicValue(auth)556 expect(actual).toEqual(expected)557 })558 it('should work with defaults', () => {559 const auth = new Auth.OAuth2()560 const expected = new DynamicValue('com.luckymarmot.OAuth2DynamicValue', {561 authorizationURL: '',562 accessTokenURL: '',563 grantType: 0,564 scopes: ''565 })566 const actual = __internals__.convertOAuth2AuthIntoDynamicValue(auth)567 expect(actual).toEqual(expected)568 })569 })570 describe('@convertAuthIntoDynamicValue', () => {571 it('should work', () => {572 spyOn(__internals__, 'convertBasicAuthIntoDynamicValue').andReturn(123)573 spyOn(__internals__, 'convertDigestAuthIntoDynamicValue').andReturn(321)574 spyOn(__internals__, 'convertOAuth1AuthIntoDynamicValue').andReturn(234)575 spyOn(__internals__, 'convertOAuth2AuthIntoDynamicValue').andReturn(432)576 const input = [577 new Auth.Basic(),578 new Auth.Digest(),579 new Auth.OAuth1(),580 new Auth.OAuth2(),581 new Auth.Negotiate()582 ]583 const expected = [ 123, 321, 234, 432, '' ]584 const actual = input.map(__internals__.convertAuthIntoDynamicValue)585 expect(actual).toEqual(expected)586 })587 })588 describe('@addAuthToDomain', () => {589 /* eslint-disable max-statements */590 it('should work', () => {591 const domain = { createEnvironmentVariable: () => {} }592 const environment = {}593 const auth = new Auth.Basic()594 const key = 'basic_auth'595 const variable = { setValue: () => {} }596 spyOn(domain, 'createEnvironmentVariable').andReturn(variable)597 spyOn(variable, 'setValue').andReturn(null)598 spyOn(__internals__, 'convertAuthIntoDynamicValue').andReturn(123)599 spyOn(__internals__, 'wrapDV').andReturn('123')600 const expected = { variable, auth }601 const actual = __internals__.addAuthToDomain(domain, environment, auth, key)602 expect(domain.createEnvironmentVariable).toHaveBeenCalledWith(key)603 expect(__internals__.convertAuthIntoDynamicValue).toHaveBeenCalledWith(auth)604 expect(variable.setValue).toHaveBeenCalledWith('123', environment)605 expect(actual).toEqual(expected)606 })607 /* eslint-enable max-statements */608 })609 describe('@addAuthsToDomain', () => {610 it('should work if underlying methods are correct', () => {611 spyOn(__internals__, 'addAuthToDomain').andReturn('test')612 const domain = {}613 const environment = {}614 const api = new Api({615 store: new Store({616 auth: new OrderedMap({617 abc: 123,618 bca: 231619 })620 })621 })622 const expected = new OrderedMap({ abc: 'test', bca: 'test' })623 const actual = __internals__.addAuthsToDomain(domain, environment, api)624 expect(__internals__.addAuthToDomain.calls.length).toEqual(2)625 expect(actual).toEqual(expected)626 })627 })628 describe('@addVariablesToStandardDomain', () => {629 /* eslint-disable max-statements */630 it('should work if underlying methods are correct', () => {631 const domain = { createEnvironment: () => {} }632 spyOn(domain, 'createEnvironment').andReturn('env')633 spyOn(__internals__, 'addConstraintsToDomain').andReturn(123)634 spyOn(__internals__, 'addEndpointsToDomain').andReturn(321)635 spyOn(__internals__, 'addParametersToDomain').andReturn(234)636 spyOn(__internals__, 'addAuthsToDomain').andReturn(432)637 const api = new Api()638 const expected = new Store({639 constraint: 123,640 endpoint: 321,641 parameter: 234,642 auth: 432643 })644 const actual = __internals__.addVariablesToStandardDomain(domain, api)645 expect(domain.createEnvironment).toHaveBeenCalled()646 expect(__internals__.addConstraintsToDomain).toHaveBeenCalled()647 expect(__internals__.addEndpointsToDomain).toHaveBeenCalled()648 expect(__internals__.addParametersToDomain).toHaveBeenCalled()649 expect(__internals__.addAuthsToDomain).toHaveBeenCalled()650 expect(actual).toEqual(expected)651 })652 /* eslint-enable max-statements */653 })654 describe('@getVariableEnvironmentDomainSize', () => {655 it('should return 0 if variable TypedStore is empty', () => {656 const api = new Api({657 store: new Store()658 })659 const expected = 0660 const actual = __internals__.getVariableEnvironmentDomainSize(api)661 expect(actual).toEqual(expected)662 })663 it('should return the correct number otherwise', () => {664 const api = new Api({665 store: new Store({666 variable: new OrderedMap({667 abc: 123,668 bca: 231669 })670 })671 })672 const expected = 2673 const actual = __internals__.getVariableEnvironmentDomainSize(api)674 expect(actual).toEqual(expected)675 })676 })677 describe('@needsVariableEnvironmentDomain', () => {678 it('should return false if size is 0', () => {679 spyOn(__internals__, 'getVariableEnvironmentDomainSize').andReturn(0)680 const api = new Api()681 const expected = false682 const actual = __internals__.needsVariableEnvironmentDomain(api)683 expect(actual).toEqual(expected)684 })685 it('should return true if size is >= 1', () => {686 spyOn(__internals__, 'getVariableEnvironmentDomainSize').andReturn(10)687 const api = new Api()688 const expected = true689 const actual = __internals__.needsVariableEnvironmentDomain(api)690 expect(actual).toEqual(expected)691 })692 })693 describe('@updateEnvironmentVariableWithEnvironmentValue', () => {694 /* eslint-disable max-statements */695 it('should work', () => {696 const domain = {697 getEnvironmentByName: () => {},698 createEnvironment: () => {}699 }700 const variable = {701 setValue: () => {}702 }703 const value = '123'704 const envName = '321'705 spyOn(domain, 'getEnvironmentByName').andReturn(null)706 spyOn(domain, 'createEnvironment').andReturn(432)707 spyOn(variable, 'setValue').andReturn(345)708 const expected = variable709 const actual = __internals__.updateEnvironmentVariableWithEnvironmentValue(710 domain, variable, value, envName711 )712 expect(domain.getEnvironmentByName).toHaveBeenCalled()713 expect(domain.createEnvironment).toHaveBeenCalled()714 expect(variable.setValue).toHaveBeenCalledWith(value, 432)715 expect(actual).toEqual(expected)716 })717 it('should work if env already exists', () => {718 const domain = {719 getEnvironmentByName: () => {},720 createEnvironment: () => {}721 }722 const variable = {723 setValue: () => {}724 }725 const value = '123'726 const envName = '321'727 spyOn(domain, 'getEnvironmentByName').andReturn(432)728 spyOn(domain, 'createEnvironment').andReturn(null)729 spyOn(variable, 'setValue').andReturn(345)730 const expected = variable731 const actual = __internals__.updateEnvironmentVariableWithEnvironmentValue(732 domain, variable, value, envName733 )734 expect(domain.getEnvironmentByName).toHaveBeenCalled()735 expect(domain.createEnvironment).toNotHaveBeenCalled()736 expect(variable.setValue).toHaveBeenCalledWith(value, 432)737 expect(actual).toEqual(expected)738 })739 /* eslint-enable max-statements */740 })741 describe('@convertVariableIntoEnvironmentVariable', () => {742 it('should work', () => {743 const domain = {744 createEnvironmentVariable: () => {}745 }746 const variable = new Variable({747 values: OrderedMap({748 a: 321,749 b: 123750 })751 })752 const key = 'pet_name'753 spyOn(domain, 'createEnvironmentVariable').andReturn(234)754 spyOn(__internals__, 'updateEnvironmentVariableWithEnvironmentValue').andReturn(432)755 const expected = 432756 const actual = __internals__.convertVariableIntoEnvironmentVariable(domain, variable, key)757 expect(__internals__.updateEnvironmentVariableWithEnvironmentValue.calls.length).toEqual(2)758 expect(actual).toEqual(expected)759 })760 })761 describe('@addVariablesToVariableDomain', () => {762 it('should work', () => {763 spyOn(__internals__, 'convertVariableIntoEnvironmentVariable').andReturn('test')764 const domain = {}765 const api = new Api({766 store: new Store({767 variable: OrderedMap({768 a: 123, b: 312769 })770 })771 })772 const expected = new Store({773 variable: OrderedMap({774 a: 'test', b: 'test'775 })776 })777 const actual = __internals__.addVariablesToVariableDomain(domain, api)778 expect(__internals__.convertVariableIntoEnvironmentVariable.calls.length).toEqual(2)779 expect(actual).toEqual(expected)780 })781 })782 describe('@createEnvironments', () => {783 /* eslint-disable max-statements */784 it('should work', () => {785 spyOn(__internals__, 'needsStandardEnvironmentDomain').andReturn(true)786 spyOn(__internals__, 'createStandardEnvironmentDomain').andReturn(123)787 spyOn(__internals__, 'addVariablesToStandardDomain').andReturn(new Store({788 constraint: 234789 }))790 spyOn(__internals__, 'needsVariableEnvironmentDomain').andReturn(true)791 spyOn(__internals__, 'createVariableEnvironmentDomain').andReturn(123)792 spyOn(__internals__, 'addVariablesToVariableDomain').andReturn(new Store({793 variable: 432794 }))795 const context = {}796 const api = new Api({797 store: new Store({798 constraint: OrderedMap({799 a: 123800 }),801 variable: OrderedMap({802 b: 321803 })804 })805 })806 const expected = new Store({807 constraint: 234,808 variable: 432809 })810 const actual = __internals__.createEnvironments(context, api)811 expect(actual).toEqual(expected)812 })813 /* eslint-enable max-statements */814 it('should work if api does not need env domains', () => {815 spyOn(__internals__, 'needsStandardEnvironmentDomain').andReturn(false)816 spyOn(__internals__, 'needsVariableEnvironmentDomain').andReturn(false)817 const context = {}818 const api = new Api({819 store: new Store({820 constraint: OrderedMap({821 a: 123822 }),823 variable: OrderedMap({824 b: 321825 })826 })827 })828 const expected = new Store()829 const actual = __internals__.createEnvironments(context, api)830 expect(actual).toEqual(expected)831 })832 })833 describe('@convertSequenceParameterIntoVariableDS', () => {834 it('should work', () => {835 const pawreq = {}836 spyOn(__internals__, 'convertParameterIntoVariableDS').andReturn(123)837 const param = new Parameter({838 superType: 'sequence',839 value: List([840 new Parameter({ type: 'string', default: '/path' }),841 new Parameter({842 type: 'string',843 constraints: List([ new Constraint.Enum([ 'simple', 'long' ]) ])844 }),845 new Parameter({ type: 'string', default: '/users' })846 ])847 })848 const expected = new DynamicString('/path', 123, '/users')849 const actual = __internals__.convertSequenceParameterIntoVariableDS(pawreq, param)850 expect(actual).toEqual(expected)851 })852 })853 describe('@convertParameterIntoVariableDS', () => {854 it('should call convertSequenceParameterIntoVariableDS if superType is sequence', () => {855 const pawReq = {}856 const param = new Parameter({ superType: 'sequence' })857 spyOn(__internals__, 'convertSequenceParameterIntoVariableDS').andReturn(123)858 const expected = 123859 const actual = __internals__.convertParameterIntoVariableDS(pawReq, param)860 expect(__internals__.convertSequenceParameterIntoVariableDS).toHaveBeenCalled()861 expect(actual).toEqual(expected)862 })863 /* eslint-disable max-statements */864 it('should create variable otherwise', () => {865 const pawReq = {866 addVariable: () => {}867 }868 const param = new Parameter({869 key: 'user',870 type: 'string',871 constraints: List([ new Constraint.JSONSchema({ pattern: '^.{16}$' }) ])872 })873 const variable = {874 createDynamicString: () => {}875 }876 spyOn(__internals__, 'getVariableArgumentsFromParameter').andReturn({877 name: 'user',878 value: 'somerandomstring',879 description: 'dummy desc'880 })881 spyOn(pawReq, 'addVariable').andReturn(variable)882 spyOn(variable, 'createDynamicString').andReturn(123)883 const expected = 123884 const actual = __internals__.convertParameterIntoVariableDS(pawReq, param)885 expect(__internals__.getVariableArgumentsFromParameter).toHaveBeenCalled()886 expect(pawReq.addVariable).toHaveBeenCalled()887 expect(variable.createDynamicString).toHaveBeenCalled()888 expect(actual).toEqual(expected)889 })890 /* eslint-enable max-statements */891 })892 describe('@convertPathnameIntoDynamicString', () => {893 it('should return a string if param is not a sequence', () => {894 const component = new URLComponent({895 componentName: 'pathname',896 string: '/paths',897 variableDelimiters: List([ '{{', '}}' ])898 })899 const pawReq = {}900 const expected = '/paths'901 const actual = __internals__.convertPathnameIntoDynamicString(pawReq, component)902 expect(actual).toEqual(expected)903 })904 it('should call convertSequenceParameterIntoVariableDS if superType is sequence', () => {905 spyOn(__internals__, 'convertSequenceParameterIntoVariableDS').andReturn(123)906 const component = new URLComponent({907 componentName: 'pathname',908 string: '/paths/{{pathId}}',909 variableDelimiters: List([ '{{', '}}' ])910 })911 const pawReq = {}912 const expected = 123913 const actual = __internals__.convertPathnameIntoDynamicString(pawReq, component)914 expect(actual).toEqual(expected)915 })916 })917 describe('@convertEndpointOrReferenceIntoDS', () => {918 it('should work is endpoint is reference', () => {919 const variable = {920 createDynamicString: () => {}921 }922 spyOn(variable, 'createDynamicString').andReturn(123)923 const store = new Store({924 endpoint: OrderedMap({925 a: variable926 })927 })928 const endpoint = new Reference({929 uuid: 'a'930 })931 const expected = 123932 const actual = __internals__.convertEndpointOrReferenceIntoDS(store, endpoint)933 expect(actual).toEqual(expected)934 })935 it('should work is endpoint is reference and variable does not exist', () => {936 const variable = {937 createDynamicString: () => {}938 }939 spyOn(variable, 'createDynamicString').andReturn(123)940 const store = new Store({941 endpoint: OrderedMap({942 b: variable943 })944 })945 const endpoint = new Reference({946 uuid: 'a'947 })948 const expected = null949 const actual = __internals__.convertEndpointOrReferenceIntoDS(store, endpoint)950 expect(actual).toEqual(expected)951 })952 it('should work is endpoint is url', () => {953 spyOn(__internals__, 'createEndpointDynamicString').andReturn(123)954 const store = new Store({955 endpoint: 321956 })957 const endpoint = new URL({958 url: 'https://echo.paw.cloud'959 })960 const expected = 123961 const actual = __internals__.convertEndpointOrReferenceIntoDS(store, endpoint)962 expect(actual).toEqual(expected)963 })964 })965 describe('@convertEndpointsDSArrayIntoVariableDV', () => {966 it('should return first item in endpoint array is array.length === 1', () => {967 const pawRequest = {}968 const endpoints = [ 123 ]969 const expected = 123970 const actual = __internals__.convertEndpointsDSArrayIntoVariableDV(pawRequest, endpoints)971 expect(actual).toEqual(expected)972 })973 it('should create variable otherwise', () => {974 const variable = {975 createDynamicValue: () => {}976 }977 spyOn(variable, 'createDynamicValue').andReturn(234)978 const pawRequest = {979 addVariable: () => {}980 }981 spyOn(pawRequest, 'addVariable').andReturn(variable)982 const endpoints = [ 123, 321 ]983 const expected = 234984 const actual = __internals__.convertEndpointsDSArrayIntoVariableDV(pawRequest, endpoints)985 expect(actual).toEqual(expected)986 })987 })988 describe('@convertEndpointsAndPathnameIntoDS', () => {989 it('should work', () => {990 spyOn(__internals__, 'convertEndpointOrReferenceIntoDS').andReturn(234)991 spyOn(__internals__, 'convertEndpointsDSArrayIntoVariableDV').andReturn(432)992 spyOn(__internals__, 'convertPathnameIntoDynamicString').andReturn(345)993 const pawReq = {}994 const store = new Store()995 const endpoints = List([ 123, 321 ])996 const path = new URL({997 url: 'https://echo.paw.cloud'998 })999 const expected = new DynamicString(432, 345)1000 const actual = __internals__.convertEndpointsAndPathnameIntoDS(pawReq, store, endpoints, path)1001 expect(actual).toEqual(expected)1002 })1003 })1004 describe('getDefaultValueFromParameter', () => {1005 it('should work', () => {1006 const param = new Parameter({1007 default: 1231008 })1009 const expected = '123'1010 const actual = __internals__.getDefaultValueFromParameter(param)1011 expect(actual).toEqual(expected)1012 })1013 it('should work if defaultValue is string', () => {1014 const param = new Parameter({1015 default: '123'1016 })1017 const expected = '123'1018 const actual = __internals__.getDefaultValueFromParameter(param)1019 expect(actual).toEqual(expected)1020 })1021 it('should work if defaultValue is null', () => {1022 const param = new Parameter({1023 default: null1024 })1025 const expected = ''1026 const actual = __internals__.getDefaultValueFromParameter(param)1027 expect(actual).toEqual(expected)1028 })1029 })1030 describe('@getVariableArgumentsFromParameter', () => {1031 it('should work', () => {1032 spyOn(__internals__, 'getDefaultValueFromParameter').andReturn('123')1033 const param = new Parameter({1034 key: 'userId',1035 description: 'some userid desc',1036 default: 1231037 })1038 const expected = {1039 name: 'userId',1040 value: '123',1041 description: 'some userid desc'1042 }1043 const actual = __internals__.getVariableArgumentsFromParameter(param)1044 expect(actual).toEqual(expected)1045 })1046 it('should work if minimum info', () => {1047 spyOn(__internals__, 'getDefaultValueFromParameter').andReturn('123')1048 const param = new Parameter({1049 default: 1231050 })1051 const expected = {1052 name: '',1053 value: '123',1054 description: ''1055 }1056 const actual = __internals__.getVariableArgumentsFromParameter(param)1057 expect(actual).toEqual(expected)1058 })1059 it('should work if description in schema', () => {1060 spyOn(__internals__, 'getDefaultValueFromParameter').andReturn('123')1061 const param = new Parameter({1062 default: 123,1063 constraints: List([ new Constraint.JSONSchema({ description: 'some desc' }) ])1064 })1065 const expected = {1066 name: '',1067 value: '123',1068 description: 'some desc'1069 }1070 const actual = __internals__.getVariableArgumentsFromParameter(param)1071 expect(actual).toEqual(expected)1072 })1073 })1074 describe('@convertParameterFromReference', () => {1075 it('should work', () => {1076 spyOn(__internals__, 'getVariableArgumentsFromParameter').andReturn({1077 name: 321,1078 value: 345,1079 description: 5431080 })1081 const variable = {1082 createDynamicString: () => {}1083 }1084 spyOn(variable, 'createDynamicString').andReturn(123)1085 const pawReq = {1086 addVariable: () => {}1087 }1088 spyOn(pawReq, 'addVariable').andReturn(variable)1089 const store = new Store({1090 parameter: OrderedMap({1091 a: {1092 parameter: 234,1093 variable: 4321094 }1095 })1096 })1097 const reference = new Reference({1098 uuid: 'a'1099 })1100 const expected = { key: 321, value: 123 }1101 const actual = __internals__.convertParameterFromReference(pawReq, store, reference)1102 expect(actual).toEqual(expected)1103 })1104 it('should work if parameter is not found', () => {1105 spyOn(__internals__, 'getVariableArgumentsFromParameter').andReturn({1106 name: 321,1107 value: 345,1108 description: 5431109 })1110 const variable = {1111 createDynamicString: () => {}1112 }1113 spyOn(variable, 'createDynamicString').andReturn(123)1114 const pawReq = {1115 addVariable: () => {}1116 }1117 spyOn(pawReq, 'addVariable').andReturn(variable)1118 const store = new Store({1119 parameter: OrderedMap({1120 b: {1121 parameter: 234,1122 variable: 4321123 }1124 })1125 })1126 const reference = new Reference({1127 uuid: 'a'1128 })1129 const expected = { key: '', value: '' }1130 const actual = __internals__.convertParameterFromReference(pawReq, store, reference)1131 expect(actual).toEqual(expected)1132 })1133 })1134 describe('@convertReferenceOrParameterToDsEntry', () => {1135 it('should call convertParameterFromReference if param is reference', () => {1136 const pawReq = null1137 const store = null1138 const ref = new Reference()1139 spyOn(__internals__, 'convertParameterFromReference').andReturn({ key: 123, value: 321 })1140 const expected = { key: 123, value: 321 }1141 const actual = __internals__.convertReferenceOrParameterToDsEntry(pawReq, store, ref)1142 expect(actual).toEqual(expected)1143 })1144 it('should call convertParameterIntoVariableDS if param is Parameter', () => {1145 const pawReq = null1146 const store = null1147 const ref = new Parameter({1148 key: 1231149 })1150 spyOn(__internals__, 'convertParameterIntoVariableDS').andReturn(321)1151 const expected = { key: 123, value: 321 }1152 const actual = __internals__.convertReferenceOrParameterToDsEntry(pawReq, store, ref)1153 expect(actual).toEqual(expected)1154 })1155 })1156 describe('@addHeaderToRequest', () => {1157 it('should work', () => {1158 const pawReq = { addHeader: () => {} }1159 spyOn(pawReq, 'addHeader').andReturn(123)1160 const headerEntry = { key: 123, value: 321 }1161 const expected = pawReq1162 const actual = __internals__.addHeaderToRequest(pawReq, headerEntry)1163 expect(pawReq.addHeader).toHaveBeenCalledWith(123, 321)1164 expect(actual).toEqual(expected)1165 })1166 })1167 describe('@addHeadersToRequest', () => {1168 it('should work', () => {1169 spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn({ key: 12, value: 21 })1170 spyOn(__internals__, 'addHeaderToRequest').andReturn(123)1171 const pawReq = null1172 const store = null1173 const container = new ParameterContainer({1174 headers: OrderedMap({1175 a: 234,1176 b: 432,1177 c: 3451178 })1179 })1180 const expected = 1231181 const actual = __internals__.addHeadersToRequest(pawReq, store, container)1182 expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(3)1183 expect(__internals__.addHeaderToRequest.calls.length).toEqual(3)1184 expect(actual).toEqual(expected)1185 })1186 })1187 describe('@addUrlParamToRequest', () => {1188 it('should work', () => {1189 const pawReq = { addUrlParameter: () => {} }1190 spyOn(pawReq, 'addUrlParameter').andReturn(123)1191 const headerEntry = { key: 123, value: 321 }1192 const expected = pawReq1193 const actual = __internals__.addUrlParamToRequest(pawReq, headerEntry)1194 expect(pawReq.addUrlParameter).toHaveBeenCalledWith(123, 321)1195 expect(actual).toEqual(expected)1196 })1197 })1198 describe('@addUrlParamsToRequest', () => {1199 it('should work', () => {1200 spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn({ key: 12, value: 21 })1201 spyOn(__internals__, 'addUrlParamToRequest').andReturn(123)1202 const pawReq = null1203 const store = null1204 const container = new ParameterContainer({1205 queries: OrderedMap({1206 a: 234,1207 b: 432,1208 c: 3451209 })1210 })1211 const expected = 1231212 const actual = __internals__.addUrlParamsToRequest(pawReq, store, container)1213 expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(3)1214 expect(__internals__.addUrlParamToRequest.calls.length).toEqual(3)1215 expect(actual).toEqual(expected)1216 })1217 })1218 describe('@isParameterValidWithMultiPartContext', () => {1219 it('should work', () => {1220 const input = [1221 new Parameter(),1222 new Parameter({1223 applicableContexts: List([1224 new Parameter({1225 key: 'Content-Type',1226 constraints: List([1227 new Constraint.Enum([ 'multipart/form-data' ])1228 ])1229 })1230 ])1231 }),1232 new Parameter({1233 applicableContexts: List([1234 new Parameter({1235 key: 'Accept',1236 constraints: List([1237 new Constraint.Enum([ 'multipart/form-data' ])1238 ])1239 })1240 ])1241 })1242 ]1243 const expected = [ true, true, false ]1244 const actual = input.map(__internals__.isParameterValidWithMultiPartContext)1245 expect(actual).toEqual(expected)1246 })1247 })1248 describe('@isParameterValidWithUrlEncodedContext', () => {1249 it('should work', () => {1250 const input = [1251 new Parameter(),1252 new Parameter({1253 applicableContexts: List([1254 new Parameter({1255 key: 'Content-Type',1256 constraints: List([1257 new Constraint.Enum([ 'application/x-www-form-urlencoded' ])1258 ])1259 })1260 ])1261 }),1262 new Parameter({1263 applicableContexts: List([1264 new Parameter({1265 key: 'Accept',1266 constraints: List([1267 new Constraint.Enum([ 'multipart/form-data' ])1268 ])1269 })1270 ])1271 })1272 ]1273 const expected = [ true, true, false ]1274 const actual = input.map(__internals__.isParameterValidWithUrlEncodedContext)1275 expect(actual).toEqual(expected)1276 })1277 })1278 describe('@isBodyParameter', () => {1279 it('should work', () => {1280 const input = [1281 new Parameter(),1282 new Parameter({ in: 'body' }),1283 new Parameter({1284 in: 'body',1285 applicableContexts: List([1286 new Parameter({1287 key: 'Content-Type',1288 constraints: List([1289 new Constraint.Enum([ 'application/json' ])1290 ])1291 })1292 ])1293 }),1294 new Parameter({1295 in: 'body',1296 applicableContexts: List([1297 new Parameter({1298 key: 'Content-Type',1299 constraints: List([1300 new Constraint.Enum([ 'application/x-www-form-urlencoded' ])1301 ])1302 })1303 ])1304 }),1305 new Parameter({1306 in: 'body',1307 applicableContexts: List([1308 new Parameter({1309 key: 'Content-Type',1310 constraints: List([1311 new Constraint.Enum([ 'multipart/form-data' ])1312 ])1313 })1314 ])1315 })1316 ]1317 const expected = [ false, true, true, false, false ]1318 const actual = input.map(__internals__.isBodyParameter)1319 expect(actual).toEqual(expected)1320 })1321 })1322 describe('@setRawBody', () => {1323 it('should work', () => {1324 const pawReq = {}1325 const params = List([1326 new Parameter({ type: 'integer', constraints: List([ new Constraint.Enum([ 123 ]) ]) })1327 ])1328 const expected = {1329 body: new DynamicString(1330 new DynamicValue('com.luckymarmot.PawExtensions.JSONSchemaFakerDynamicValue', {1331 schema: JSON.stringify({ enum: [ 123 ], type: 'integer' })1332 })1333 )1334 }1335 const actual = __internals__.setRawBody(pawReq, params)1336 expect(actual).toEqual(expected)1337 })1338 })1339 describe('@isContextWithUrlEncoded', () => {1340 it('should work', () => {1341 const input = [1342 new Context({1343 constraints: List([1344 new Parameter({1345 key: 'Content-Type',1346 default: 'application/x-www-form-urlencoded'1347 })1348 ])1349 }),1350 new Context({1351 constraints: List([1352 new Parameter({1353 key: 'Content-Type',1354 default: 'multipart/form-data'1355 })1356 ])1357 }),1358 new Context({1359 constraints: List([1360 new Parameter({1361 key: 'Content-Type',1362 default: 'application/json'1363 })1364 ])1365 })1366 ]1367 const expected = [ true, false, false ]1368 const actual = input.map(__internals__.isContextWithUrlEncoded)1369 expect(actual).toEqual(expected)1370 })1371 })1372 describe('@isContextWithMultiPart', () => {1373 it('should work', () => {1374 const input = [1375 new Context({1376 constraints: List([1377 new Parameter({1378 key: 'Content-Type',1379 default: 'application/x-www-form-urlencoded'1380 })1381 ])1382 }),1383 new Context({1384 constraints: List([1385 new Parameter({1386 key: 'Content-Type',1387 default: 'multipart/form-data'1388 })1389 ])1390 }),1391 new Context({1392 constraints: List([1393 new Parameter({1394 key: 'Content-Type',1395 default: 'application/json'1396 })1397 ])1398 })1399 ]1400 const expected = [ false, true, false ]1401 const actual = input.map(__internals__.isContextWithMultiPart)1402 expect(actual).toEqual(expected)1403 })1404 })1405 describe('@addEntryToRecordParameterArray', () => {1406 it('should work', () => {1407 const kvList = [ 123 ]1408 const entry = { key: 234, value: 345 }1409 const expected = [ 123, new RecordParameter(234, 345, true) ]1410 const actual = __internals__.addEntryToRecordParameterArray(kvList, entry)1411 expect(actual).toEqual(expected)1412 })1413 })1414 describe('@setFormDataBody', () => {1415 /* eslint-disable max-statements */1416 it('should work with urlEncoded', () => {1417 const pawReq = {}1418 const store = new Store()1419 const params = [ 123, 321, 234, 432 ]1420 const context = new Context()1421 spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn(123)1422 spyOn(__internals__, 'addEntryToRecordParameterArray').andReturn([ 123, 234, 345, 456, 567 ])1423 spyOn(__internals__, 'isContextWithUrlEncoded').andReturn(true)1424 spyOn(__internals__, 'isContextWithMultiPart').andReturn(false)1425 spyOn(__internals__, 'createUrlEncodedBodyDV').andReturn(678)1426 spyOn(__internals__, 'wrapDV').andReturn('test')1427 const expected = {1428 body: 'test'1429 }1430 const actual = __internals__.setFormDataBody(pawReq, store, params, context)1431 expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(4)1432 expect(__internals__.addEntryToRecordParameterArray.calls.length).toEqual(4)1433 expect(__internals__.isContextWithUrlEncoded).toHaveBeenCalled()1434 expect(__internals__.isContextWithMultiPart).toHaveBeenCalled()1435 expect(__internals__.createUrlEncodedBodyDV).toHaveBeenCalled()1436 expect(__internals__.wrapDV).toHaveBeenCalled()1437 expect(actual).toEqual(expected)1438 })1439 it('should work with multipart', () => {1440 const pawReq = {}1441 const store = new Store()1442 const params = [ 123, 321, 234, 432 ]1443 const context = new Context()1444 spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn(123)1445 spyOn(__internals__, 'addEntryToRecordParameterArray').andReturn([ 123, 234, 345, 456, 567 ])1446 spyOn(__internals__, 'isContextWithUrlEncoded').andReturn(false)1447 spyOn(__internals__, 'isContextWithMultiPart').andReturn(true)1448 spyOn(__internals__, 'createMultipartBodyDV').andReturn(678)1449 spyOn(__internals__, 'wrapDV').andReturn('test')1450 const expected = {1451 body: 'test'1452 }1453 const actual = __internals__.setFormDataBody(pawReq, store, params, context)1454 expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(4)1455 expect(__internals__.addEntryToRecordParameterArray.calls.length).toEqual(4)1456 expect(__internals__.isContextWithUrlEncoded).toHaveBeenCalled()1457 expect(__internals__.isContextWithMultiPart).toHaveBeenCalled()1458 expect(__internals__.createMultipartBodyDV).toHaveBeenCalled()1459 expect(__internals__.wrapDV).toHaveBeenCalled()1460 expect(actual).toEqual(expected)1461 })1462 it('should work with no valid content type', () => {1463 const pawReq = {}1464 const store = new Store()1465 const params = [ 123, 321, 234, 432 ]1466 const context = new Context()1467 spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn(123)1468 spyOn(__internals__, 'addEntryToRecordParameterArray').andReturn([ 123, 234, 345, 456, 567 ])1469 spyOn(__internals__, 'isContextWithUrlEncoded').andReturn(false)1470 spyOn(__internals__, 'isContextWithMultiPart').andReturn(false)1471 spyOn(__internals__, 'wrapDV').andReturn('test')1472 const expected = {1473 body: 'test'1474 }1475 const actual = __internals__.setFormDataBody(pawReq, store, params, context)1476 expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(4)1477 expect(__internals__.addEntryToRecordParameterArray.calls.length).toEqual(4)1478 expect(__internals__.isContextWithUrlEncoded).toHaveBeenCalled()1479 expect(__internals__.isContextWithMultiPart).toHaveBeenCalled()1480 expect(__internals__.wrapDV).toHaveBeenCalled()1481 expect(actual).toEqual(expected)1482 })1483 /* eslint-enable max-statements */1484 })1485 describe('@addBodyToRequest', () => {1486 it('should work with raw body params', () => {1487 const pawReq = {}1488 const store = new Store()1489 const container = new ParameterContainer({1490 body: OrderedMap({1491 a: 123,1492 b: 3211493 })1494 })1495 const context = new Context()1496 spyOn(__internals__, 'isBodyParameter').andReturn(true)1497 spyOn(__internals__, 'setRawBody').andReturn(123)1498 const expected = 1231499 const actual = __internals__.addBodyToRequest(pawReq, store, container, context)1500 expect(__internals__.setRawBody).toHaveBeenCalled()1501 expect(actual).toEqual(expected)1502 })1503 it('should work with formdata body params', () => {1504 const pawReq = {}1505 const store = new Store()1506 const container = new ParameterContainer({1507 body: OrderedMap({1508 a: 123,1509 b: 3211510 })1511 })1512 const context = new Context()1513 spyOn(__internals__, 'isBodyParameter').andReturn(false)1514 spyOn(__internals__, 'setFormDataBody').andReturn(123)1515 const expected = 1231516 const actual = __internals__.addBodyToRequest(pawReq, store, container, context)1517 expect(__internals__.setFormDataBody).toHaveBeenCalled()1518 expect(actual).toEqual(expected)1519 })1520 it('should work with formdata body params and no context', () => {1521 const pawReq = {}1522 const store = new Store()1523 const container = new ParameterContainer({1524 body: OrderedMap({1525 a: 123,1526 b: 3211527 })1528 })1529 const context = null1530 spyOn(__internals__, 'isBodyParameter').andReturn(false)1531 spyOn(__internals__, 'setFormDataBody').andReturn(123)1532 const expected = pawReq1533 const actual = __internals__.addBodyToRequest(pawReq, store, container, context)1534 expect(__internals__.setFormDataBody).toNotHaveBeenCalled()1535 expect(actual).toEqual(expected)1536 })1537 it('should work with no formdata body params and context', () => {1538 const pawReq = {}1539 const store = new Store()1540 const container = new ParameterContainer({1541 body: OrderedMap()1542 })1543 const context = new Context()1544 spyOn(__internals__, 'isBodyParameter').andReturn(false)1545 spyOn(__internals__, 'setFormDataBody').andReturn(123)1546 const expected = pawReq1547 const actual = __internals__.addBodyToRequest(pawReq, store, container, context)1548 expect(__internals__.setFormDataBody).toNotHaveBeenCalled()1549 expect(actual).toEqual(expected)1550 })1551 })1552 describe('@getContainerFromRequest', () => {1553 it('should work with no context in request', () => {1554 const request = new Request({1555 parameters: new ParameterContainer({1556 headers: OrderedMap({ a: 123, b: 321 })1557 })1558 })1559 const expected = {1560 container: new ParameterContainer({1561 headers: OrderedMap({ a: 123, b: 321 })1562 })1563 }1564 const actual = __internals__.getContainerFromRequest(request)1565 expect(actual).toEqual(expected)1566 })1567 it('should work with context in request', () => {1568 const request = new Request({1569 parameters: new ParameterContainer({1570 headers: OrderedMap({1571 a: new Parameter({1572 key: 'a',1573 applicableContexts: List([1574 new Parameter({1575 key: 'a',1576 constraints: List([ new Constraint.Enum([ 123, 321 ]) ])1577 })1578 ])1579 }),1580 b: new Parameter({1581 key: 'a',1582 applicableContexts: List([1583 new Parameter({1584 key: 'a',1585 constraints: List([ new Constraint.Enum([ 234, 432 ]) ])1586 })1587 ])1588 })1589 })1590 }),1591 contexts: List([1592 new Context({1593 constraints: List([1594 new Parameter({1595 key: 'a',1596 default: 1231597 })1598 ])1599 })1600 ])1601 })1602 const expected = {1603 container: new ParameterContainer({1604 headers: OrderedMap({1605 a: new Parameter({1606 key: 'a',1607 applicableContexts: List([1608 new Parameter({1609 key: 'a',1610 constraints: List([ new Constraint.Enum([ 123, 321 ]) ])1611 })1612 ])1613 })1614 })1615 }),1616 requestContext: new Context({1617 constraints: List([1618 new Parameter({1619 key: 'a',1620 default: 1231621 })1622 ])1623 })1624 }1625 const actual = __internals__.getContainerFromRequest(request)1626 expect(actual).toEqual(expected)1627 })1628 })1629 describe('@convertAuthFromReference', () => {1630 it('should work', () => {1631 const variable = { createDynamicString: () => {} }1632 spyOn(variable, 'createDynamicString').andReturn(123)1633 const store = new Store({1634 auth: OrderedMap({ a: { variable: variable, auth: 'my-auth' } })1635 })1636 const ref = new Reference({ uuid: 'a' })1637 const expected = { auth: 'my-auth', variable: 123 }1638 const actual = __internals__.convertAuthFromReference(store, ref)1639 expect(actual).toEqual(expected)1640 })1641 })1642 describe('@convertReferenceOrAuthToDsEntry', () => {1643 it('should work with reference', () => {1644 spyOn(__internals__, 'convertAuthFromReference').andReturn(123)1645 const store = new Store()1646 const ref = new Reference()1647 const expected = 1231648 const actual = __internals__.convertReferenceOrAuthToDsEntry(store, ref)1649 expect(actual).toEqual(expected)1650 })1651 it('should work with auth', () => {1652 spyOn(__internals__, 'convertAuthIntoDynamicValue').andReturn(123)1653 spyOn(__internals__, 'wrapDV').andReturn('123')1654 const store = new Store()1655 const auth = new Auth.Basic()1656 const expected = { variable: '123', auth }1657 const actual = __internals__.convertReferenceOrAuthToDsEntry(store, auth)1658 expect(actual).toEqual(expected)1659 })1660 })1661 describe('@addAuthToRequest', () => {1662 it('should work', () => {1663 const pawReq = { setHeader: () => {} }1664 spyOn(pawReq, 'setHeader').andReturn(123)1665 const authData = { variable: 'some dynamic string', auth: new Auth.Basic() }1666 const expected = pawReq1667 const actual = __internals__.addAuthToRequest(pawReq, authData)1668 expect(pawReq.setHeader).toHaveBeenCalledWith('Authorization', authData.variable)1669 expect(actual).toEqual(expected)1670 })1671 it('should work with ApiKeys custom headers', () => {1672 const pawReq = { setHeader: () => {} }1673 spyOn(pawReq, 'setHeader').andReturn(123)1674 const authData = {1675 variable: 'some dynamic string',1676 auth: new Auth.ApiKey({ name: 'X-Auth-Token' })1677 }1678 const expected = pawReq1679 const actual = __internals__.addAuthToRequest(pawReq, authData)1680 expect(pawReq.setHeader).toHaveBeenCalledWith('X-Auth-Token', authData.variable)1681 expect(actual).toEqual(expected)1682 })1683 })1684 describe('@addAuthsToRequest', () => {1685 it('should work', () => {1686 const pawReq = {}1687 const store = new Store()1688 const request = new Request({ auths: List([ 1, 2, 3, 4 ]) })1689 spyOn(__internals__, 'convertReferenceOrAuthToDsEntry').andReturn(123)1690 spyOn(__internals__, 'addAuthToRequest').andReturn(234)1691 const expected = 2341692 const actual = __internals__.addAuthsToRequest(pawReq, store, request)1693 expect(__internals__.convertReferenceOrAuthToDsEntry.calls.length).toEqual(4)1694 expect(__internals__.addAuthToRequest.calls.length).toEqual(4)1695 expect(actual).toEqual(expected)1696 })1697 })1698 describe('@convertRequestIntoPawRequest', () => {1699 /* eslint-disable max-statements */1700 it('should work', () => {1701 const context = {1702 createRequest: () => {}1703 }1704 spyOn(context, 'createRequest').andReturn({})1705 spyOn(__internals__, 'convertEndpointsAndPathnameIntoDS').andReturn(123)1706 spyOn(__internals__, 'getContainerFromRequest').andReturn({ container: 1, requestContext: 2 })1707 spyOn(__internals__, 'addHeadersToRequest').andReturn(345)1708 spyOn(__internals__, 'addUrlParamsToRequest').andReturn(456)1709 spyOn(__internals__, 'addBodyToRequest').andReturn(567)1710 spyOn(__internals__, 'addAuthsToRequest').andReturn(678)1711 const store = new Store()1712 const path = new URL({1713 url: '/paths/simple'1714 })1715 const request = new Request()1716 const expected = {1717 url: 1231718 }1719 const actual = __internals__.convertRequestIntoPawRequest(context, store, path, request)1720 expect(__internals__.convertEndpointsAndPathnameIntoDS).toHaveBeenCalled()1721 expect(__internals__.getContainerFromRequest).toHaveBeenCalled()1722 expect(__internals__.addHeadersToRequest).toHaveBeenCalled()1723 expect(__internals__.addUrlParamsToRequest).toHaveBeenCalled()1724 expect(__internals__.addBodyToRequest).toHaveBeenCalled()1725 expect(__internals__.addAuthsToRequest).toHaveBeenCalled()1726 expect(actual).toEqual(expected)1727 })1728 /* eslint-enable max-statements */1729 })1730 describe('@convertResourceIntoGroup', () => {1731 /* eslint-disable max-statements */1732 it('should work', () => {1733 const context = { createRequestGroup: () => {} }1734 const group = { appendChild: () => {} }1735 spyOn(__internals__, 'convertRequestIntoPawRequest').andReturn(123)1736 spyOn(context, 'createRequestGroup').andReturn(group)1737 spyOn(group, 'appendChild').andReturn(123)1738 const store = new Store()1739 const resource = new Resource({1740 path: new URL({ url: '/paths/simple' }),1741 methods: OrderedMap({1742 get: 123,1743 post: 321,1744 put: 2341745 })1746 })1747 const expected = group1748 const actual = __internals__.convertResourceIntoGroup(context, store, resource)1749 expect(context.createRequestGroup).toHaveBeenCalled()1750 expect(__internals__.convertRequestIntoPawRequest.calls.length).toEqual(3)1751 expect(group.appendChild.calls.length).toEqual(3)1752 expect(actual).toEqual(expected)1753 })1754 /* eslint-enable max-statements */1755 })1756 describe('@createRequests', () => {1757 it('should work', () => {1758 const context = {}1759 const store = new Store()1760 const api = new Api({ resources: OrderedMap({ a: 1, b: 2, c: 3 }) })1761 spyOn(__internals__, 'convertResourceIntoGroup').andReturn(123)1762 const expected = OrderedMap({ a: 123, b: 123, c: 123 })1763 const actual = __internals__.createRequests(context, store, api)1764 expect(__internals__.convertResourceIntoGroup.calls.length).toEqual(3)1765 expect(actual).toEqual(expected)1766 })1767 })1768 describe('@createPawGroupFromGroup', () => {1769 it('should work', () => {1770 spyOn(__internals__, 'createGroups').andCall((_, __, v) => {1771 return v % 2 ? v : null1772 })1773 const children = []1774 const inputs = [1775 [ {}, {}, new Group(), 'abc' ],1776 [ {}, {}, new Group({ name: 'def', children: OrderedMap({ a: 123, b: 234 }) }), 'abc' ],1777 [ {1778 createRequestGroup: (name) => {1779 return {1780 name, children, appendChild: (v) => children.push(v)1781 }1782 }1783 }, {}, new Group({ name: 'def', children: OrderedMap({ a: 123, b: 234, c: 345 }) }) ]1784 ]1785 const expected = [1786 null,1787 123,1788 { name: 'def', children: [ 123, 345 ], appendChild: (v) => children.push(v) }1789 ]1790 const actual = inputs.map(input => __internals__.createPawGroupFromGroup(...input))1791 expect(JSON.stringify(actual)).toEqual(JSON.stringify(expected))1792 })1793 })1794 describe('@createGroups', () => {1795 it('should work', () => {1796 spyOn(__internals__, 'createPawGroupFromGroup').andCall((c, r, g, gn) => {1797 return gn1798 })1799 const inputs = [1800 [ {}, OrderedMap(), null, 'abc' ],1801 [ {}, OrderedMap(), 'some weird group', 'abc' ],1802 [ {}, OrderedMap(), new Group(), 'abc' ]1803 ]1804 const expected = [1805 null, null, 'abc'1806 ]1807 const actual = inputs.map(input => __internals__.createGroups(...input))1808 expect(actual).toEqual(expected)1809 })1810 })1811 describe('@serialize', () => {1812 it('should work', () => {1813 spyOn(__internals__, 'createEnvironments').andReturn(123)1814 spyOn(__internals__, 'createRequests').andReturn(321)1815 spyOn(__internals__, 'createGroups').andReturn(123)1816 spyOn(__internals__, 'getTitleFromApi').andReturn('someTitle')1817 const context = {}1818 const api = new Api()1819 __internals__.serialize({ options: { context }, api })1820 expect(__internals__.createEnvironments).toHaveBeenCalledWith(context, api)1821 expect(__internals__.createRequests).toHaveBeenCalledWith(context, 123, api)1822 expect(__internals__.createGroups).toHaveBeenCalledWith(context, 321, null, 'someTitle')1823 })1824 it('should work with minimum info', () => {1825 const expected = true1826 const actual = __internals__.serialize()1827 expect(actual).toEqual(expected)1828 })1829 })...

Full Screen

Full Screen

setup.js

Source:setup.js Github

copy

Full Screen

...101 console.log('Phone number sid updated: ' + phoneNumberSid);102 // With all of our entities created, we need to store some103 // of them inside our hosted ENV in order for use later104 const environment = await getCurrentEnvironment();105 await createEnvironmentVariable(environment, 'SYNC_SERVICE_SID', syncService.sid);106 await createEnvironmentVariable(environment, 'TWILIO_API_KEY', key.sid);107 await createEnvironmentVariable(environment, 'TWILIO_API_SECRET', key.secret);108 console.log('Hosted environment variables created');109 // This will end the function!110 return callback(null, 'Setup successfully ran!');111 /**112 *113 * HELPER FUNCTIONS114 *115 */116 117 // In the steps above we'll need to get the current environment118 // based on the domain name this function is running in119 async function getCurrentEnvironment() {120 if (context.DOMAIN_NAME && context.DOMAIN_NAME.startsWith("localhost")) {121 return;122 }123 const services = await client.serverless.services.list();124 for (let service of services) {125 console.log("Searching for environment. Looping through service: " + service.sid);126 const environments = await client.serverless127 .services(service.sid)128 .environments.list();129 const environment = environments.find(130 env => env.domainName === context.DOMAIN_NAME131 );132 if (environment) {133 // Exit the function134 return environment;135 }136 }137 }138 // With the environment specified, we use the Twilio REST API139 // to set new envronment variables. Note, this will throw an140 // error if exists. Hence the duplicate check up top.141 async function createEnvironmentVariable(environment, key, value) {142 try {143 if (!environment) {144 throw new Error('No Env!')145 }146 console.log(`Creating variable ${key}`);147 await client.serverless148 .services(environment.serviceSid)149 .environments(environment.sid)150 .variables.create({151 key: key,152 value: value153 });154 } catch (err) {155 console.error(`Error creating '${key}' with '${value}': ${err}`);...

Full Screen

Full Screen

cli.ts

Source:cli.ts Github

copy

Full Screen

1#! /usr/bin/env node2import {createErrorMessageAndExit} from '../error/errorHandling';3import {getConfig} from '../config';4import {createBucket, deleteBucket, generateS3Name} from '../s3/s3Interactor';5import {6 createDynamoTable,7 deleteDynamoTable,8 generateDynamoDbName,9} from '../dynamo/dynamoInteractor';10import {TestStructure} from '../test.types';11import {12 createSqsQueue,13 deleteSqsQueue,14 generateSqsName,15} from '../sqs/sqsInteractor';16import {TestlaConfig} from './testla.config.type';17const dateFormat = require('dateformat');18const path = require('path');19const fs = require('fs');20const ejs = require('ejs');21const yargs = require('yargs');22const usage = '\nUsage: testla [options]';23const options = yargs24 .usage(usage)25 .option('f', {26 alias: 'file',27 describe: 'tests given file',28 type: 'string',29 demandOption: false,30 })31 .option('teardown', {32 describe: 'destroys the services defined in the testla config',33 demandOption: false,34 })35 .help(true).argv;36const htmlTemplate = 'htmlTemplate/testResult.ejs';37const describeTests: TestStructure[] = [];38const runTests = async (testFiles: String[]) => {39 for (const filePath of testFiles) {40 await runTestFile(`${filePath}`);41 }42};43const fetchTestFiles = (44 testDirectories: string[],45 testFilesEnding: string46): string[] => {47 const fileSet = new Set<string>();48 if (testDirectories) {49 for (const dir of testDirectories) {50 for (const file of fs.readdirSync(dir)) {51 fileSet.add(`${dir}${file}`);52 }53 }54 }55 if (testFilesEnding) {56 const testFiles = fetchFilesFromDirectory(process.cwd()).map(file =>57 file.slice(process.cwd().length + 1)58 );59 testFiles60 .filter(file => file.split('.')[1] === testFilesEnding)61 .forEach(fileSet.add, fileSet);62 }63 return Array.from(fileSet);64};65const fetchFilesFromDirectory = (directory: string): string[] => {66 let files: string[] = [];67 for (const file of fs.readdirSync(directory)) {68 if (fs.statSync(`${directory}/${file}`).isDirectory()) {69 if (file != 'node_modules') {70 files = files.concat(fetchFilesFromDirectory(`${directory}/${file}`));71 }72 } else {73 files.push(`${directory}/${file}`);74 }75 }76 return files;77};78const runTestFile = async (path: string) => {79 let result: TestStructure = await require(fs.realpathSync(path));80 result.testFileName = path;81 describeTests.push(result);82};83const createEnvironmentvariable = (key: string, value: string) => {84 process.env[key] = value;85};86const generateHtmlOutput = (describeTests: TestStructure[]) => {87 const basePath = path.join(process.cwd(), '/html');88 const rawTemplate = fs.readFileSync(89 path.join(__dirname, `../../${htmlTemplate}`)90 );91 let html = ejs.render(rawTemplate.toString(), {92 descripes: describeTests,93 testDate: dateFormat(new Date(), 'dd.mm.yyyy HH:MM:ss'),94 });95 if (!fs.existsSync(basePath)) {96 fs.mkdirSync(basePath);97 }98 fs.writeFileSync(99 basePath + `/${dateFormat(new Date(), 'dd-mm-HH-MM')}-TestResult.html`,100 html101 );102};103const setUpServices = async (config: TestlaConfig) => {104 for (const sqs of config.sqsQeueus) {105 sqs.sqsName = sqs.sqsName ? sqs.sqsName : generateSqsName(sqs.fifo);106 const sqsUrl = await createSqsQueue(sqs.sqsName, sqs.fifo);107 if (sqsUrl) {108 createEnvironmentvariable(sqs.enviromentName, sqsUrl);109 } else {110 createErrorMessageAndExit(111 'Creating of sqs queue',112 'could not set enviroment varibale becuase sqsUrl is undefined'113 );114 }115 }116 for (const bucket of config.s3Buckets) {117 bucket.bucketName = bucket.bucketName118 ? bucket.bucketName119 : generateS3Name();120 await createBucket(121 bucket.bucketName,122 bucket.region ? bucket.region : 'eu-central-1'123 );124 createEnvironmentvariable(bucket.enviromentName, bucket.bucketName);125 }126 for (const table of config.dynamoDbs) {127 table.tableName = table.tableName128 ? table.tableName129 : generateDynamoDbName();130 await createDynamoTable(table.tableName, table.properties, table.keys);131 createEnvironmentvariable(table.enviromentName, table.tableName);132 }133};134const teardownServices = async (135 config: TestlaConfig,136 errorHandlingEnabled: boolean137) => {138 for (const bucket of config.s3Buckets) {139 await deleteBucket(bucket.bucketName, errorHandlingEnabled);140 }141 for (const table of config.dynamoDbs) {142 await deleteDynamoTable(table.tableName, errorHandlingEnabled);143 }144 for (const sqs of config.sqsQeueus) {145 await deleteSqsQueue(sqs.sqsName, errorHandlingEnabled);146 }147};148(async () => {149 let config = getConfig();150 if (!config) {151 console.error(`ERROR: Missing config file`);152 return;153 }154 if (options.teardown) {155 await teardownServices(config, false);156 return;157 }158 await setUpServices(config);159 if (options.f) {160 await runTestFile(options.f);161 } else {162 const testFiles = fetchTestFiles(config.testDirectory, config.testFiles);163 await runTests(testFiles);164 }165 await teardownServices(config, true);166 generateHtmlOutput(describeTests);...

Full Screen

Full Screen

createenvironmentvariable.component.spec.ts

Source:createenvironmentvariable.component.spec.ts Github

copy

Full Screen

1import { async, ComponentFixture, TestBed } from '@angular/core/testing';2import { CreateenvironmentvariableComponent } from './createenvironmentvariable.component';3describe('CreateenvironmentvariableComponent', () => {4 let component: CreateenvironmentvariableComponent;5 let fixture: ComponentFixture<CreateenvironmentvariableComponent>;6 beforeEach(async(() => {7 TestBed.configureTestingModule({8 declarations: [ CreateenvironmentvariableComponent ]9 })10 .compileComponents();11 }));12 beforeEach(() => {13 fixture = TestBed.createComponent(CreateenvironmentvariableComponent);14 component = fixture.componentInstance;15 fixture.detectChanges();16 });17 it('should create', () => {18 expect(component).toBeTruthy();19 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const browser = await qawolf.launch();3await qawolf.createEnvironmentVariable("qawolf_browser", browser);4const browser = process.env.qawolf_browser;5await qawolf.createEnvironmentVariable("qawolf_browser", browser);6const browser = process.env.qawolf_browser;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createEnvironmentVariable } = require("qawolf");2const { createEnvironmentVariable } = require("qawolf");3const { createEnvironmentVariable } = require("qawolf");4const { createEnvironmentVariable } = require("qawolf");5const { createEnvironmentVariable } = require("qawolf");6const { createEnvironmentVariable } = require("qawolf");7const { createEnvironmentVariable } = require("qawolf");8const { createEnvironmentVariable } = require("qawolf");9const { createEnvironmentVariable } = require("qawolf");10const { createEnvironmentVariable } = require("q

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createEnvironmentVariable } = require('qawolf');2createEnvironmentVariable('name', 'value');3const { createEnvironmentVariable } = require('qawolf');4createEnvironmentVariable('name', 'value');5const { createEnvironmentVariable } = require('qawolf');6createEnvironmentVariable('name', 'value');7const { createEnvironmentVariable } = require('qawolf');8createEnvironmentVariable('name', 'value');9const { createEnvironmentVariable } = require('qawolf');10createEnvironmentVariable('name', 'value');11const { createEnvironmentVariable } = require('qawolf');12createEnvironmentVariable('name', 'value');13const { createEnvironmentVariable } = require('qawolf');14createEnvironmentVariable('name', 'value');15const { createEnvironmentVariable } = require('qawolf');16createEnvironmentVariable('name', 'value');17const { createEnvironmentVariable } = require('qawolf');18createEnvironmentVariable('name', 'value');19const { createEnvironmentVariable } = require('qawolf');20createEnvironmentVariable('name', 'value');21const { createEnvironmentVariable } = require('qawolf');22createEnvironmentVariable('name', 'value');23const { createEnvironmentVariable } = require('qawolf');24createEnvironmentVariable('name

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require('qawolf');2const {createEnvironmentVariable} = qawolf;3createEnvironmentVariable('TEST', 'TEST_VALUE');4const qawolf = require('qawolf');5const {createEnvironmentVariable} = qawolf;6createEnvironmentVariable('TEST', 'TEST_VALUE');7const qawolf = require('qawolf');8const {createEnvironmentVariable} = qawolf;9createEnvironmentVariable('TEST', 'TEST_VALUE');10const qawolf = require('qawolf');11const {createEnvironmentVariable} = qawolf;12createEnvironmentVariable('TEST', 'TEST_VALUE');13const qawolf = require('qawolf');14const {createEnvironmentVariable} = qawolf;15createEnvironmentVariable('TEST', 'TEST_VALUE');16const qawolf = require('qawolf');17const {createEnvironmentVariable} = qawolf;18createEnvironmentVariable('TEST', 'TEST_VALUE');19const qawolf = require('qawolf');20const {createEnvironmentVariable} = qawolf;21createEnvironmentVariable('TEST', 'TEST_VALUE');22const qawolf = require('qawolf');23const {createEnvironmentVariable} = qawolf;24createEnvironmentVariable('TEST', 'TEST_VALUE');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createEnvironmentVariable } = require('qawolf');2await createEnvironmentVariable('my_variable', 'my_value');3const dotenv = require('dotenv');4dotenv.config();5const my_variable = process.env.MY_VARIABLE;6const { createEnvironmentVariable } = require('qawolf');7await createEnvironmentVariable('my_variable', 'my_value');8const dotenv = require('dotenv');9dotenv.config();10const my_variable = process.env.MY_VARIABLE;11const { createEnvironmentVariable } = require('qawolf');12await createEnvironmentVariable('my_variable', 'my_value');13const dotenv = require('dotenv');14dotenv.config();15const my_variable = process.env.MY_VARIABLE;16const { createEnvironmentVariable } = require('qawolf');17await createEnvironmentVariable('my_variable', 'my_value');18const dotenv = require('dotenv');19dotenv.config();20const my_variable = process.env.MY_VARIABLE;21const { createEnvironmentVariable } = require('qawolf');22await createEnvironmentVariable('my_variable', 'my_value');23const dotenv = require('dotenv');24dotenv.config();25const my_variable = process.env.MY_VARIABLE;26const { createEnvironmentVariable } = require('qawolf');27await createEnvironmentVariable('my_variable', 'my_value');28const dotenv = require('dotenv');29dotenv.config();30const my_variable = process.env.MY_VARIABLE;31const { createEnvironmentVariable } = require('qawolf');32await createEnvironmentVariable('my

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