Skip to content

Commit

Permalink
[Test] Add two ProjectTests (ComplexTest01, ImportTest)
Browse files Browse the repository at this point in the history
  • Loading branch information
koczkatamas committed Feb 19, 2020
1 parent 5937bd8 commit ece6a9e
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -11,4 +11,5 @@ tmp/
.secret_token
*.tsbuildinfo
build/*.js
packages/bundle.json
packages/bundle.json
dist/
@@ -0,0 +1,8 @@
import { GroupManager } from "./Model/GroupManager";
import { StringUtil } from "./Utils/StringUtil";

const gm = new GroupManager();
gm.generateANewGroup();
gm.importGroup('{"name":"importedGroup", "users":[{"name":"imported user1"}]}');
const groupNames = StringUtil.concatTwoStrings(gm.groups[0].name, gm.groups[1].name);
console.log(`Group names: ${groupNames}`);
@@ -0,0 +1,6 @@
import { User } from "./User";

export class Group {
public name: string;
public users: User[];
}
@@ -0,0 +1,3 @@
export class User {
constructor(public name: string) { }
}
@@ -0,0 +1,22 @@
import { OneJson } from "@one/One.Json-v0.1";

import { Group } from "./Db/Group";
import { User } from "./Db/User";
import { StringUtil } from "../Utils/StringUtil";

export class GroupManager {
public groups: Group[] = [];

generateANewGroup() {
const g = new Group();
g.name = "MyGroup";
g.users = [new User("user1"), new User("user2")];
this.groups.push(g);
}

importGroup(exportedJson: string) {
const g = <Group> OneJson.deserialize(exportedJson);
g.name = StringUtil.ucFirst(g.name);
this.groups.push(g);
}
}
@@ -0,0 +1,4 @@
export class StringUtil {
static ucFirst(str: string) { return str[0].toUpperCase() + str.substr(1); }
static concatTwoStrings(str1: string, str2: string) { return str1 + ", " + str2; }
}
11 changes: 11 additions & 0 deletions test/testSuites/ProjectTest/ComplexTest01/tsconfig.json
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": "./",
"target": "es2017",
"module": "CommonJS",
"outDir": "dist",
"moduleResolution": "node",
"paths": { "@one/*": ["../../../../packages/interfaces/*"]}
},
"include": ["src/**/*.ts"],
}
4 changes: 4 additions & 0 deletions test/testSuites/ProjectTest/ImportTest/src/ImportTest.ts
@@ -0,0 +1,4 @@
import { OneJson } from "One.Json-v0.1";

const value = OneJson.parse("5");
console.log(`isNumber: ${value.isNumber}`);
10 changes: 10 additions & 0 deletions test/testSuites/ProjectTest/ImportTest/tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": "./",
"target": "es2017",
"outDir": "dist",
"moduleResolution": "node",
"paths": { "*": ["../../../../packages/interfaces/*" ]}
},
"include": ["src/**/*.ts"],
}

0 comments on commit ece6a9e

Please sign in to comment.