Skip to content

Commit 026ab83

Browse files
committed
test with Error
1 parent 3b102c3 commit 026ab83

File tree

13 files changed

+4580
-31
lines changed

13 files changed

+4580
-31
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: github-actions
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- uses: actions/setup-node@v4
12+
13+
- run: make install
14+
15+
- name: run tests
16+
run: make lint
17+
18+
- name: run tests
19+
run: make test

.github/workflows/hexlet-check.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-options=--no-warnings --experimental-vm-modules

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ link:
1111
sudo npm link
1212

1313
gendiff.js:
14-
node bin/gendiff.js -h
14+
node bin/gendiff.js -h
15+
16+
lint:
17+
npx eslint .
18+
19+
watch:
20+
npx jest --watch
21+
22+
test:
23+
npm test

__fixtures__/expectDiffFiles.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
- follow: false
3+
host: hexlet.io
4+
- proxy: 123.234.53.22
5+
- timeout: 50
6+
+ timeout: 20
7+
+ verbose: true
8+
}

__fixtures__/file1.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"host": "hexlet.io",
3+
"timeout": 50,
4+
"proxy": "123.234.53.22",
5+
"follow": false
6+
}

__fixtures__/file2.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"timeout": 20,
3+
"verbose": true,
4+
"host": "hexlet.io"
5+
}

__test__/diffFiles.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import compareFiles from '../src/diffFiles.js';
4+
import { fileURLToPath } from 'url';
5+
import { dirname } from 'path';
6+
import parseFile from '../src/fileParser.js';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = dirname(__filename);
10+
11+
const getFixturePath = (filename) =>
12+
path.join(__dirname, '..', '__fixtures__', filename);
13+
const readFile = (filename) =>
14+
fs.readFileSync(getFixturePath(filename), 'utf-8');
15+
16+
test('compareFiles',()=>{
17+
const diffFiles = readFile('expectDiffFiles.txt')
18+
const file1 = parseFile(getFixturePath('file1.json'));
19+
const file2 = parseFile(getFixturePath('file2.json'));
20+
expect(compareFiles(file1,file2)).toEqual(diffFiles);
21+
})

bin/gendiff.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ program
2121
console.log(diffFiles(file1, file2));
2222
});
2323

24+
// eslint-disable-next-line no-undef
2425
program.parse(process.argv);
2526

2627
if (program.opts().help) {

eslint.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
4+
5+
/** @type {import('eslint').Linter.Config[]} */
6+
export default [
7+
{languageOptions: { globals: globals.browser }},
8+
pluginJs.configs.recommended,
9+
];

0 commit comments

Comments
 (0)