Skip to content

Commit

Permalink
[CHORE] Fixing tests
Browse files Browse the repository at this point in the history
1. Changed the kinds of prop,method, boolean and string to new values
  • Loading branch information
rajasegar committed Jan 23, 2020
1 parent 2687ff7 commit 0b94c7a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"deploy": "npm version patch && git push && git push --tags && npm publish",
"deploy-feat": "npm version minor && git push && git push --tags && npm publish",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint src/"
"lint": "eslint src/",
"debug": "node --inspect-brk ./node_modules/.bin/mocha --forbid-only tests/*.test.js"
},
"author": "Rajasegar Chandran",
"bugs": "https://github.com/rajasegar/ember-gen-uml/issues",
Expand Down
14 changes: 8 additions & 6 deletions src/transform-typescript.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const ts = require('typescript');

const KIND_PROPERTY_DECLARATION = 155;
const KIND_METHOD_DECLARATION = 157;
const KIND_PROPERTY_DECLARATION = 158;
const KIND_METHOD_DECLARATION = 160;

const filterKinds = [KIND_PROPERTY_DECLARATION, KIND_METHOD_DECLARATION];

const kindMap = {
'124': 'Boolean',
'139': 'String',
'127': 'Boolean',
'142': 'String',
};

function transform(fileName, code, componentName) {
Expand Down Expand Up @@ -44,8 +46,8 @@ class ${componentName} {
if (_extends === 'Component') {
node.members
.filter(
prop =>
prop.kind === KIND_PROPERTY_DECLARATION || prop.kind === KIND_METHOD_DECLARATION
prop => filterKinds.includes(prop.kind)
//prop.kind === KIND_PROPERTY_DECLARATION || prop.kind === KIND_METHOD_DECLARATION
)
.forEach(prop => {
//console.log(prop.name.text);
Expand Down
41 changes: 15 additions & 26 deletions tests/transform-typescript.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const assert = require("assert");
const transform = require("../src/transform-typescript");

describe("transform typescript test: ", function() {

it("should generate transform public property properly", function() {
const assert = require('assert');
const transform = require('../src/transform-typescript');

describe('transform typescript test: ', function() {
it('should generate transform public property properly', function() {
const input = `
export default class MyClass extends Component{
prop1: boolean = true;
Expand All @@ -20,13 +18,12 @@ class MyClass {
@enduml`;

const uml = transform("my-class.ts", input, "MyClass");
const uml = transform('my-class.ts', input, 'MyClass');

assert.strictEqual(uml,output);
assert.strictEqual(uml, output);
});

it("should generate multiple properties properly", function() {

it('should generate multiple properties properly', function() {
const input = `
export default class MyClass extends Component{
prop1: boolean = true;
Expand All @@ -44,15 +41,12 @@ class MyClass {
@enduml`;

const uml = transform("my-class.ts", input, "MyClass");
const uml = transform('my-class.ts', input, 'MyClass');

assert.strictEqual(uml,output);
assert.strictEqual(uml, output);
});



it("should generate public method properly", function() {

it('should generate public method properly', function() {
const input = `
export default class MyClass extends Component{
method1() {
Expand All @@ -69,14 +63,12 @@ class MyClass {
@enduml`;

const uml = transform("my-class.ts", input, "MyClass");
const uml = transform('my-class.ts', input, 'MyClass');

assert.strictEqual(uml,output);
assert.strictEqual(uml, output);
});


it("should generate transform service properties properly", function() {

it('should generate transform service properties properly', function() {
const input = `
export default class MyClass extends Component{
@service i18n!: I18N;
Expand All @@ -96,11 +88,8 @@ class MyClass {
@enduml`;

const uml = transform("my-class.ts", input, "MyClass");
const uml = transform('my-class.ts', input, 'MyClass');

assert.strictEqual(uml,output);
assert.strictEqual(uml, output);
});



});

0 comments on commit 0b94c7a

Please sign in to comment.