Skip to content

Commit

Permalink
mocks: init fs index file.
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Sep 25, 2023
1 parent 4fb10da commit e7f0c81
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/__mocks__/fs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {expect} from '@jest/globals';

import * as YAML from 'js-yaml';

export const readFile = async (_filePath: string, _format: string) => {

Check warning on line 5 in src/__mocks__/fs/index.ts

View workflow job for this annotation

GitHub Actions / build

'_filePath' is defined but never used

Check warning on line 5 in src/__mocks__/fs/index.ts

View workflow job for this annotation

GitHub Actions / build

'_format' is defined but never used
return `
name: gsf-demo
description:
Hello
tags:
kind: web
complexity: moderate
category: cloud
initialize:
models:
- name: boavizta-cpu
kind: builtin
config:
allocation: LINEAR
verbose: true
graph:
children:
front-end:
pipeline:
- boavizta-cpu
config:
boavizta-cpu:
core-units: 24
processor: Intel® Core™ i7-1185G7
observations:
- timestamp: 2023-07-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600 # Secs
cpu-util: 18.392
- timestamp: 2023-08-06T00:00 # [KEYWORD] [NO-SUBFIELDS] time when measurement occurred
duration: 3600 # Secs
cpu-util: 16`;
};

export const mkdir = (dirPath: string, _object: any) => dirPath;

Check warning on line 39 in src/__mocks__/fs/index.ts

View workflow job for this annotation

GitHub Actions / build

'_object' is defined but never used

export const writeFile = async (pathToFile: string, content: string) => {
if (pathToFile === 'reject') {
throw Error('Wrong file path');
}

const mockPathToFile = 'mock-pathToFile';
const mockContent = {
name: 'mock-name',
};
const mockObject = YAML.dump(mockContent, {noRefs: true});

expect(pathToFile).toBe(mockPathToFile);
expect(content).toBe(mockObject);
};

0 comments on commit e7f0c81

Please sign in to comment.