Skip to content

Commit

Permalink
fix(*): set typescript enum values to strings (resolves #362)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Stone <[email protected]>
  • Loading branch information
Simon Stone authored and Simon Stone committed Dec 15, 2021
1 parent 87bc9c2 commit b570b20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ class TypescriptVisitor {
* @private
*/
visitEnumValueDeclaration(enumValueDeclaration, parameters) {
parameters.fileWriter.writeLine(1, enumValueDeclaration.getName() + ',');
const name = enumValueDeclaration.getName();
parameters.fileWriter.writeLine(1,`${name} = '${name}',`);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ describe('TypescriptVisitor', function () {
});

describe('visitEnumValueDeclaration', () => {
it('should write a line with the name of the enum value', () => {
it('should write a line with the name and value of the enum value', () => {
let param = {
fileWriter: mockFileWriter
};
Expand All @@ -454,7 +454,7 @@ describe('TypescriptVisitor', function () {

typescriptVisitor.visitEnumValueDeclaration(mockEnumValueDeclaration, param);

param.fileWriter.writeLine.withArgs(1, 'Bob,').calledOnce.should.be.ok;
param.fileWriter.writeLine.withArgs(1, 'Bob = \'Bob\',').calledOnce.should.be.ok;
});
});

Expand Down

0 comments on commit b570b20

Please sign in to comment.