diff options
author | Sonsino, Ofir (os0695) <os0695@intl.att.com> | 2018-07-10 15:57:37 +0300 |
---|---|---|
committer | Sonsino, Ofir (os0695) <os0695@intl.att.com> | 2018-07-10 15:57:37 +0300 |
commit | ff76b5ed0aa91d5fdf9dc4f95e8b20f91ed9d072 (patch) | |
tree | aae42404a93fdffdd16ff050eaa28129959f7577 /vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts | |
parent | c72d565bb58226b20625b2bce5f0019046bee649 (diff) |
New Angular UI from 1806
Change-Id: I39c160db0e0a6ec2e587ccf007ee1b23c6a08666
Issue-ID: VID-208
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
Diffstat (limited to 'vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts')
-rw-r--r-- | vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts b/vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts new file mode 100644 index 000000000..0bab4e1da --- /dev/null +++ b/vid-webpack-master/cypress/support/jsonBuilders/jsonBuilder.ts @@ -0,0 +1,31 @@ +export class JsonBuilder<T> implements IJsonBuilder<T>{ + currentValue: T; + + public basicJson(json: JSON, url: string, status: number, delay: number, alias: string, changeResFunc?: Function) : void { + this.currentValue = <T>JSON.parse(JSON.stringify(json)); + this.currentValue = changeResFunc ? changeResFunc(this.currentValue) : this.currentValue; + return this.initMockCall(url, status, delay, alias); + } + + public initMockCall(url: string, status: number, delay: number, alias: string) { + cy.server() + .route({ + method: 'GET', + status: status, + delay : delay ? delay : 0, + url: url, + response: JSON.stringify(this.currentValue) + }).as(alias); + } + public basicMock(jsonPath: string, url: string) { + cy.readFile(jsonPath).then((res) => { + this.basicJson(res, url, 200, 0, url,); + }) + } +} + +export interface IJsonBuilder<T>{ + basicJson(json: JSON, url: string, status: number, delay: number, alias: string, changeResFunc?: Function) : void; + initMockCall(url: string, status: number, delay: number, alias: string): void; + basicMock(jsonPath: string, url: string): void; +} |