Skip to content
Snippets Groups Projects
Commit 378fcce2 authored by Behrisch, M. (Michael)'s avatar Behrisch, M. (Michael)
Browse files

test: :sparkles: adds mock-data shared library that should hold all data for testing

Provides schema, queryresult, etc. in one place
parent 30834c21
No related branches found
Tags v1.32.3
1 merge request!13merge develop into main
Showing
with 476 additions and 332 deletions
...@@ -12,6 +12,22 @@ ...@@ -12,6 +12,22 @@
"console": "integratedTerminal", "console": "integratedTerminal",
"internalConsoleOptions": "neverOpen", "internalConsoleOptions": "neverOpen",
"port": 9229 "port": 9229
},
{
// Requires the extension Debugger for Chrome: https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
"type": "chrome",
"request": "launch",
"name": "Storybook Debug",
"breakOnLoad": true,
"url": "http://localhost:4400/?path=/story/",
"sourceMaps": true,
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:///*": "${webRoot}/*",
"webpack:///./*": "${webRoot}/*",
"webpack:///src/*": "${webRoot}/*",
"webpack:///./~/*": "${webRoot}/node_modules/*"
}
} }
] ]
} }
import { import {
handleSchemaLayout, // handleSchemaLayout,
parseSchemaFromBackend parseSchemaFromBackend
} from '@graphpolaris/schema/schema-usecases'; } from '@graphpolaris/schema/schema-usecases';
import { import {
...@@ -143,5 +143,5 @@ TestWithSchema.play = async () => { ...@@ -143,5 +143,5 @@ TestWithSchema.play = async () => {
}); });
//dispatch(setSchema(schema)); //dispatch(setSchema(schema));
handleSchemaLayout(schema); // handleSchemaLayout(schema);
}; };
...@@ -24,6 +24,11 @@ const initialElements = [ ...@@ -24,6 +24,11 @@ const initialElements = [
const Schema = (props: Props) => { const Schema = (props: Props) => {
const dbschema = useSchema(); const dbschema = useSchema();
console.log(dbschema);
const flowElements = createReactFlowElements(dbschema);
console.log(flowElements);
// const [dbschema, setSchema] = useState(useSchema()); // const [dbschema, setSchema] = useState(useSchema());
// const [flowElements, setFlowElements] = useState(initialElements); // const [flowElements, setFlowElements] = useState(initialElements);
......
export * from './lib/schema-usecases'; export * from './lib/schema-usecases';
\ No newline at end of file
{
"nodes": [
{
"name": "Me",
"attributes": [
{
"name": "screen_name",
"type": "string"
},
{
"name": "name",
"type": "string"
},
{
"name": "location",
"type": "string"
},
{
"name": "followers",
"type": "int"
},
{
"name": "following",
"type": "int"
},
{
"name": "url",
"type": "string"
},
{
"name": "profile_image_url",
"type": "string"
}
]
},
{
"name": "Link",
"attributes": [
{
"name": "url",
"type": "string"
}
]
},
{
"name": "Source",
"attributes": [
{
"name": "name",
"type": "string"
}
]
},
{
"name": "Hashtag",
"attributes": [
{
"name": "name",
"type": "string"
}
]
},
{
"name": "User",
"attributes": [
{
"name": "screen_name",
"type": "string"
},
{
"name": "name",
"type": "string"
},
{
"name": "location",
"type": "string"
},
{
"name": "followers",
"type": "int"
},
{
"name": "following",
"type": "int"
},
{
"name": "url",
"type": "string"
},
{
"name": "profile_image_url",
"type": "string"
},
{
"name": "screen_name",
"type": "string"
},
{
"name": "name",
"type": "string"
},
{
"name": "location",
"type": "string"
},
{
"name": "followers",
"type": "int"
},
{
"name": "following",
"type": "int"
},
{
"name": "statuses",
"type": "int"
},
{
"name": "url",
"type": "string"
},
{
"name": "profile_image_url",
"type": "string"
}
]
},
{
"name": "Tweet",
"attributes": [
{
"name": "id",
"type": "int"
},
{
"name": "id_str",
"type": "string"
},
{
"name": "text",
"type": "string"
},
{
"name": "favorites",
"type": "int"
},
{
"name": "import_method",
"type": "string"
}
]
}
],
"edges": [
{
"name": "USING",
"collection": "USING",
"from": "Tweet",
"to": "Source",
"attributes": []
},
{
"name": "SIMILAR_TO",
"collection": "SIMILAR_TO",
"from": "User",
"to": "User",
"attributes": [
{
"name": "score",
"type": "float"
}
]
},
{
"name": "SIMILAR_TO",
"collection": "SIMILAR_TO",
"from": "User",
"to": "Me",
"attributes": [
{
"name": "score",
"type": "float"
}
]
},
{
"name": "AMPLIFIES",
"collection": "AMPLIFIES",
"from": "Me",
"to": "User",
"attributes": []
},
{
"name": "AMPLIFIES",
"collection": "AMPLIFIES",
"from": "User",
"to": "User",
"attributes": []
},
{
"name": "RT_MENTIONS",
"collection": "RT_MENTIONS",
"from": "Me",
"to": "User",
"attributes": []
},
{
"name": "RT_MENTIONS",
"collection": "RT_MENTIONS",
"from": "User",
"to": "User",
"attributes": []
},
{
"name": "FOLLOWS",
"collection": "FOLLOWS",
"from": "User",
"to": "Me",
"attributes": []
},
{
"name": "FOLLOWS",
"collection": "FOLLOWS",
"from": "Me",
"to": "User",
"attributes": []
},
{
"name": "FOLLOWS",
"collection": "FOLLOWS",
"from": "User",
"to": "User",
"attributes": []
},
{
"name": "FOLLOWS",
"collection": "FOLLOWS",
"from": "Me",
"to": "Me",
"attributes": []
},
{
"name": "INTERACTS_WITH",
"collection": "INTERACTS_WITH",
"from": "User",
"to": "User",
"attributes": []
},
{
"name": "INTERACTS_WITH",
"collection": "INTERACTS_WITH",
"from": "Me",
"to": "User",
"attributes": []
},
{
"name": "RETWEETS",
"collection": "RETWEETS",
"from": "Tweet",
"to": "Tweet",
"attributes": []
},
{
"name": "REPLY_TO",
"collection": "REPLY_TO",
"from": "Tweet",
"to": "Tweet",
"attributes": []
},
{
"name": "CONTAINS",
"collection": "CONTAINS",
"from": "Tweet",
"to": "Link",
"attributes": []
},
{
"name": "MENTIONS",
"collection": "MENTIONS",
"from": "Tweet",
"to": "User",
"attributes": []
},
{
"name": "MENTIONS",
"collection": "MENTIONS",
"from": "Tweet",
"to": "Me",
"attributes": []
},
{
"name": "TAGS",
"collection": "TAGS",
"from": "Tweet",
"to": "Hashtag",
"attributes": []
},
{
"name": "POSTS",
"collection": "POSTS",
"from": "User",
"to": "Tweet",
"attributes": []
},
{
"name": "POSTS",
"collection": "POSTS",
"from": "Me",
"to": "Tweet",
"attributes": []
}
]
}
\ No newline at end of file
...@@ -2,17 +2,19 @@ import { SchemaFromBackend } from '@graphpolaris/shared/data-access/store'; ...@@ -2,17 +2,19 @@ import { SchemaFromBackend } from '@graphpolaris/shared/data-access/store';
import { MultiGraph } from 'graphology'; import { MultiGraph } from 'graphology';
import { parse } from 'path/posix'; import { parse } from 'path/posix';
import { parseSchemaFromBackend } from '..'; import { parseSchemaFromBackend } from '..';
import * as simpleSchema from './mockdata/simple.json';
import * as moviewSchema from './mockdata/moviesSchema.json';
import * as northwindSchema from './mockdata/northwindSchema.json';
import * as twitterSchema from './mockdata/twitterSchema.json';
import { Attributes } from 'graphology-types'; import { Attributes } from 'graphology-types';
import {
movieSchema,
northWindSchema,
simpleSchema,
twitterSchema,
} from 'libs/shared/mock-data/src';
describe('SchemaUsecases', () => { describe('SchemaUsecases', () => {
test.each([ test.each([
{ data: simpleSchema }, { data: simpleSchema },
{ data: moviewSchema }, { data: movieSchema },
{ data: northwindSchema }, { data: northWindSchema },
{ data: twitterSchema }, { data: twitterSchema },
])('parseSchemaFromBackend parsing should work', ({ data }) => { ])('parseSchemaFromBackend parsing should work', ({ data }) => {
// console.log('testinput', input); // console.log('testinput', input);
...@@ -20,7 +22,7 @@ describe('SchemaUsecases', () => { ...@@ -20,7 +22,7 @@ describe('SchemaUsecases', () => {
const parsed = parseSchemaFromBackend(data as SchemaFromBackend); const parsed = parseSchemaFromBackend(data as SchemaFromBackend);
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
let parsedNodeAttributes: Attributes[] = []; let parsedNodeAttributes: Attributes[] = [];
parsed.forEachNode((node, attr) => { parsed.forEachNode((node, attr) => {
// console.log('Node', node, attr); // console.log('Node', node, attr);
parsedNodeAttributes.push(attr.attributes); parsedNodeAttributes.push(attr.attributes);
...@@ -57,13 +59,9 @@ describe('SchemaUsecases', () => { ...@@ -57,13 +59,9 @@ describe('SchemaUsecases', () => {
}); });
test.each([ test.each([
// import * as simpleSchema from './mockdata/simple.json';
// import * as moviewSchema from './mockdata/moviesSchema.json';
// import * as northwindSchema from './mockdata/northwindSchema.json';
// import * as twitterSchema from './mockdata/twitterSchema.json';
{ data: simpleSchema }, { data: simpleSchema },
{ data: moviewSchema }, { data: movieSchema },
{ data: northwindSchema }, { data: northWindSchema },
{ data: twitterSchema }, { data: twitterSchema },
])('should load my test json $data', ({ data }) => { ])('should load my test json $data', ({ data }) => {
expect(data).toBeDefined(); expect(data).toBeDefined();
......
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
# shared-mock-data
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test shared-mock-data` to execute the unit tests via [Jest](https://jestjs.io).
module.exports = {
displayName: 'shared-mock-data',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/shared/mock-data',
};
{
"root": "libs/shared/mock-data",
"sourceRoot": "libs/shared/mock-data/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/shared/mock-data/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/shared/mock-data"],
"options": {
"jestConfig": "libs/shared/mock-data/jest.config.js",
"passWithNoTests": true
}
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"commitMessageFormat": "chore(${projectName}): release version ${version}"
}
}
},
"tags": []
}
export * from './schema/simple';
export * from './schema/moviesSchema';
export * from './schema/northwindSchema';
export * from './schema/twitterSchema';
{ export const movieSchema = {
"nodes": [ "nodes": [
{ {
"name": "Movie", "name": "Movie",
......
{ export const northWindSchema = {
"nodes": [ "nodes": [
{ {
"name": "Order", "name": "Order",
......
{ export const simpleSchema = {
"nodes": [ "nodes": [
{ {
"name": "Thijs", "name": "Thijs",
......
export const twitterSchema = {
nodes: [
{
name: 'Me',
attributes: [
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
],
},
{
name: 'Link',
attributes: [
{
name: 'url',
type: 'string',
},
],
},
{
name: 'Source',
attributes: [
{
name: 'name',
type: 'string',
},
],
},
{
name: 'Hashtag',
attributes: [
{
name: 'name',
type: 'string',
},
],
},
{
name: 'User',
attributes: [
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
{
name: 'screen_name',
type: 'string',
},
{
name: 'name',
type: 'string',
},
{
name: 'location',
type: 'string',
},
{
name: 'followers',
type: 'int',
},
{
name: 'following',
type: 'int',
},
{
name: 'statuses',
type: 'int',
},
{
name: 'url',
type: 'string',
},
{
name: 'profile_image_url',
type: 'string',
},
],
},
{
name: 'Tweet',
attributes: [
{
name: 'id',
type: 'int',
},
{
name: 'id_str',
type: 'string',
},
{
name: 'text',
type: 'string',
},
{
name: 'favorites',
type: 'int',
},
{
name: 'import_method',
type: 'string',
},
],
},
],
edges: [
{
name: 'USING',
collection: 'USING',
from: 'Tweet',
to: 'Source',
attributes: [],
},
{
name: 'SIMILAR_TO',
collection: 'SIMILAR_TO',
from: 'User',
to: 'User',
attributes: [
{
name: 'score',
type: 'float',
},
],
},
{
name: 'SIMILAR_TO',
collection: 'SIMILAR_TO',
from: 'User',
to: 'Me',
attributes: [
{
name: 'score',
type: 'float',
},
],
},
{
name: 'AMPLIFIES',
collection: 'AMPLIFIES',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'AMPLIFIES',
collection: 'AMPLIFIES',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'RT_MENTIONS',
collection: 'RT_MENTIONS',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'RT_MENTIONS',
collection: 'RT_MENTIONS',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'User',
to: 'Me',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'FOLLOWS',
collection: 'FOLLOWS',
from: 'Me',
to: 'Me',
attributes: [],
},
{
name: 'INTERACTS_WITH',
collection: 'INTERACTS_WITH',
from: 'User',
to: 'User',
attributes: [],
},
{
name: 'INTERACTS_WITH',
collection: 'INTERACTS_WITH',
from: 'Me',
to: 'User',
attributes: [],
},
{
name: 'RETWEETS',
collection: 'RETWEETS',
from: 'Tweet',
to: 'Tweet',
attributes: [],
},
{
name: 'REPLY_TO',
collection: 'REPLY_TO',
from: 'Tweet',
to: 'Tweet',
attributes: [],
},
{
name: 'CONTAINS',
collection: 'CONTAINS',
from: 'Tweet',
to: 'Link',
attributes: [],
},
{
name: 'MENTIONS',
collection: 'MENTIONS',
from: 'Tweet',
to: 'User',
attributes: [],
},
{
name: 'MENTIONS',
collection: 'MENTIONS',
from: 'Tweet',
to: 'Me',
attributes: [],
},
{
name: 'TAGS',
collection: 'TAGS',
from: 'Tweet',
to: 'Hashtag',
attributes: [],
},
{
name: 'POSTS',
collection: 'POSTS',
from: 'User',
to: 'Tweet',
attributes: [],
},
{
name: 'POSTS',
collection: 'POSTS',
from: 'Me',
to: 'Tweet',
attributes: [],
},
],
};
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": [],
"composite": true
},
"include": ["**/*.ts"],
"exclude": ["**/*.spec.ts"]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.test.ts",
"**/*.spec.ts",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.test.js",
"**/*.spec.js",
"**/*.test.jsx",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
], ],
"@graphpolaris/shared/data-access/theme": [ "@graphpolaris/shared/data-access/theme": [
"libs/shared/data-access/theme/src/index.ts" "libs/shared/data-access/theme/src/index.ts"
],
"@graphpolaris/shared/mock-data": [
"libs/shared/mock-data/src/index.ts"
] ]
} }
}, },
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"schema-schema-usecases": "libs/schema/schema-usecases", "schema-schema-usecases": "libs/schema/schema-usecases",
"shared-data-access-store": "libs/shared/data-access/store", "shared-data-access-store": "libs/shared/data-access/store",
"shared-data-access-theme": "libs/shared/data-access/theme", "shared-data-access-theme": "libs/shared/data-access/theme",
"shared-mock-data": "libs/shared/mock-data",
"web-graphpolaris": "apps/web-graphpolaris", "web-graphpolaris": "apps/web-graphpolaris",
"web-graphpolaris-e2e": "apps/web-graphpolaris-e2e" "web-graphpolaris-e2e": "apps/web-graphpolaris-e2e"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment