merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit 08a696ad83613da157c223caa9c7f75c49dc1df1
parent c9b0e41116d3347c844ac00bda401e84d67ffd4d
Author: Sebastian <sebasjm@gmail.com>
Date:   Tue, 27 Apr 2021 10:05:11 -0300

add copyrights and lint

Diffstat:
Mpackages/frontend/package.json | 5++---
Mpackages/frontend/tests/__mocks__/fileTransformer.js | 28+++++++++++++++++++++++++---
Mpackages/frontend/tests/stories.test.tsx | 51+++++++++++++++++++++++++++++++++++++--------------
3 files changed, 64 insertions(+), 20 deletions(-)

diff --git a/packages/frontend/package.json b/packages/frontend/package.json @@ -8,7 +8,7 @@ "compile": "tsc", "serve": "sirv build --port ${PORT:=8080} --cors --single", "dev": "preact watch --port ${PORT:=8080} --no-sw --no-esm", - "lint-check": "eslint 'src/**/*.{js,jsx,ts,tsx}'", + "lint-check": "eslint '{src,tests}/**/*.{js,jsx,ts,tsx}'", "lint-fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx}'", "test": "jest ./tests", "typedoc": "typedoc src", @@ -117,4 +117,4 @@ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|po)$": "<rootDir>/tests/__mocks__/fileTransformer.js" } } -} -\ No newline at end of file +} diff --git a/packages/frontend/tests/__mocks__/fileTransformer.js b/packages/frontend/tests/__mocks__/fileTransformer.js @@ -1,9 +1,31 @@ +/* + This file is part of GNU Taler + (C) 2021 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ // fileTransformer.js + +// eslint-disable-next-line @typescript-eslint/no-var-requires const path = require('path'); module.exports = { - process(src, filename, config, options) { - return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; - }, + process(src, filename, config, options) { + return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; + }, }; diff --git a/packages/frontend/tests/stories.test.tsx b/packages/frontend/tests/stories.test.tsx @@ -1,20 +1,40 @@ +/* + This file is part of GNU Taler + (C) 2021 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ import { mount } from 'enzyme'; import { h } from 'preact'; import * as ctx from '../src/context/backend'; -const fs = require('fs'); - -function getFiles (dir: string, files_: string[] = []){ - var files = fs.readdirSync(dir); - for (var i in files){ - var name = dir + '/' + files[i]; - if (fs.statSync(name).isDirectory()){ - getFiles(name, files_); - } else { - files_.push(name); - } +import fs from 'fs'; + +function getFiles(dir: string, files_: string[] = []) { + const files = fs.readdirSync(dir); + for (const i in files) { + const name = dir + '/' + files[i]; + if (fs.statSync(name).isDirectory()) { + getFiles(name, files_); + } else { + files_.push(name); } - return files_; + } + return files_; } const re = RegExp('.*\.stories.tsx') @@ -23,12 +43,15 @@ it('render every story', () => { jest.spyOn(ctx, 'useConfigContext').mockImplementation(() => ({ version: '1.0.0', currency: 'EUR' })); getFiles('./src').filter(f => re.test(f)).map(f => { - const s = require('../'+f) + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const s = require('../' + f) + delete s.default Object.keys(s).forEach(k => { const Component = s[k]; try { - mount(<Component {...Component.args}/>); + mount(<Component {...Component.args} />); } catch (error) { console.error(`problem rendering ${f} example ${k}`, error) }