-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ahmed AlSammany <[email protected]>
- Loading branch information
1 parent
dec742b
commit ed0d428
Showing
12 changed files
with
338 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "@incorta-org/create-incorta-component", | ||
"description": "Generate a new incorta component", | ||
"main": "index.js", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"repository": "[email protected]:Incorta/create-incorta-component.git", | ||
"license": "MIT", | ||
"private": false, | ||
|
@@ -21,7 +21,7 @@ | |
"shelljs": "^0.8.5", | ||
"socket.io": "^4.1.3", | ||
"uuid": "^8.3.2", | ||
"vite": "^2.7.13", | ||
"vite": "^4.3.9", | ||
"prettier": "^2.5.0" | ||
}, | ||
"bin": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { cleanup } from '@testing-library/react'; | ||
import 'vitest-dom/extend-expect'; | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
environment: 'jsdom', | ||
setupFiles: ['vitest-setup.ts'], | ||
globals: true | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
const { camelCase, startCase } = require('lodash'); | ||
|
||
const componentIndexGenerator = ({ directory }) => { | ||
const pascalCaseName = startCase(camelCase(directory)).replace(/ /g, ''); | ||
return { | ||
pascalCaseName, | ||
component: `import React from 'react'; | ||
import { vi } from 'vitest'; | ||
import { render } from '@testing-library/react'; | ||
import ${pascalCaseName} from './${pascalCaseName}'; | ||
import { Context, ResponseData, TContext } from '@incorta-org/component-sdk'; | ||
const exampleContext: Context<TContext> = { | ||
app: { | ||
color_palette: [], | ||
features: {}, | ||
loginInfo: {}, | ||
locale: { | ||
locale: 'en', | ||
formatMessage(key) { | ||
return ''; | ||
} | ||
} | ||
}, | ||
component: { | ||
dimensions: { | ||
width: 862, | ||
height: 1070 | ||
}, | ||
settings: { | ||
key1: true | ||
}, | ||
bindings: { | ||
'tray-key': [ | ||
{ | ||
id: 'h-06D4X-Svy', | ||
name: 'Cost', | ||
field: { | ||
column: 'SALES.SALES.COST_OF_GOODS', | ||
datatype: 'double', | ||
supportHierarchy: false, | ||
function: 'measure' | ||
}, | ||
settings: {} | ||
} | ||
] | ||
}, | ||
id: 'e95dafdc-bf08-451f-bb0d-f451496e22d4', | ||
version: '0.0.1', | ||
numberOfElementsInRow: 1, | ||
widthScale: 1, | ||
automaticHeight: 0 | ||
} | ||
}; | ||
const exampleData: ResponseData = { | ||
isSampled: false, | ||
subqueryComplete: true, | ||
rowHeaders: [], | ||
measureHeaders: [ | ||
{ | ||
label: 'Cost', | ||
dataType: 'double', | ||
id: 'h-06D4X-Svy', | ||
index: 0 | ||
} | ||
], | ||
data: [ | ||
[ | ||
{ | ||
value: '1670.79', | ||
formatted: '1,670.79' | ||
} | ||
] | ||
], | ||
isAggregated: false, | ||
startRow: 0, | ||
endRow: 1000, | ||
totalRows: 918843, | ||
complete: false, | ||
raw: false | ||
}; | ||
describe('<${pascalCaseName} />', () => { | ||
it('should render Hello Incorta Component', () => { | ||
let drilldown = vi.fn(); | ||
let { getByText } = render( | ||
<${pascalCaseName} context={exampleContext} data={exampleData} drillDown={drilldown} prompts={{}} /> | ||
); | ||
expect(getByText(/Hello Incorta Component/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
` | ||
}; | ||
}; | ||
|
||
module.exports = componentIndexGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { spawn } = require('child_process'); | ||
|
||
async function runTest() { | ||
try { | ||
// use spawn to run an interactive command | ||
const shell = spawn('npx vitest', [], { stdio: 'inherit', shell: true }); | ||
shell.on('close', code => console.log('[shell] terminated :', code)); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
module.exports = runTest; |
Oops, something went wrong.