Skip to content

Commit

Permalink
added tests for generate code method
Browse files Browse the repository at this point in the history
  • Loading branch information
oyilmaztekin committed Nov 3, 2018
1 parent 446a0a4 commit 8fcf26b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/astStages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ suite("AST Stages", function() {
const parsedFile = fnParser(reactFilePath)
const returnedAST = require('./mockData/reactCodeASTMock').reactFileAST
const returnedCode = fs.readFileSync(reactFilePath,'utf-8');
const generatedCode = require('./mockData/generatedCodeMock').generatedCode

suite("Parser", () => {
/**
Expand Down Expand Up @@ -73,7 +74,7 @@ suite("AST Stages", function() {
})
})

// FIXME: after code transform... leadcomment does not exist

suite("Code Generation", () => {
suite("given parameter to the generator is testing", () => {
test("it should be defined", function() {
Expand All @@ -90,11 +91,23 @@ suite("AST Stages", function() {
expect(fnGenerate).withArgs(parsedFile).to.not.throwException();
})

test("it should be a valid code", () => {
expect(fnGenerate(parsedFile).code).to.be(returnedCode)
})
suite("Generated code object is testing...", () => {
test("it should be a string", () => {
expect(fnGenerate(parsedFile)).to.be.an('object');
})

test("it should not be an empy object", () => {
expect(fnGenerate(parsedFile)).to.not.be.empty();
})

test("generated code should be a string", () => {
expect(fnGenerate(parsedFile).code).to.be.an('string');
})

test("it should be a valid code", () => {
assert.deepEqual(fnGenerate(parsedFile), generatedCode)
})
})
})

Expand Down
3 changes: 3 additions & 0 deletions test/mockData/generatedCodeMock.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8fcf26b

Please sign in to comment.