Skip to content

Commit e473f8d

Browse files
authored
Merge pull request #14 from hadiindrawan/dev
add config path on test file
2 parents 58c7c20 + ef34fb8 commit e473f8d

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/component/tests.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import isFileExisted from "../utils/check_dir.js"
44
import basePath from "../utils/base_path.js"
55

66
// Test file generator
7-
async function writeTest(element, path, pagesPath, moduleType) {
7+
async function writeTest(element, path, pagesPath, moduleType, configPath) {
88
// template dir name
99
const templateDir = moduleType == "Javascript modules (import/export)" ? "lib/template/jsimport/test.dot" : "lib/template/commonjs/test.dot"
1010
// read template file
@@ -63,6 +63,7 @@ let data = [
6363

6464
code = code.replace("{{testFunc}}", testFunc)
6565
code = code.replace("{{dataDriven}}", dataDriven)
66+
code = code.replace("{{configPath}}", configPath)
6667
await waitFor(50);
6768

6869

lib/generate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function generate(file, moduleType) {
5151

5252
asyncForEach(element.item, async (second) => {
5353
if (second.hasOwnProperty('item') == false) {
54-
writeTest(second, testPath, pagesPathRelativePath, moduleType)
54+
writeTest(second, testPath, pagesPathRelativePath, moduleType, configPath)
5555
writePages(second, pagesPath, jsonSchemaRelativePath, helperPath, moduleType, configPath)
5656
writeJsonSchema(second, jsonSchemaPath, moduleType)
5757
await waitFor(10)
@@ -73,7 +73,7 @@ async function generate(file, moduleType) {
7373
fs.mkdirSync(third_runPath, { recursive: true })
7474
writeRunner(second, third_testRe, third_runPath, moduleType)
7575
if (third.hasOwnProperty('item') == false) {
76-
writeTest(third, third_test, third_pageRe, moduleType)
76+
writeTest(third, third_test, third_pageRe, moduleType, third_confRe)
7777
writePages(third, third_page, third_schRe, third_helpRe, moduleType, third_confRe)
7878
writeJsonSchema(third, third_sch, moduleType)
7979
await waitFor(10)
@@ -95,7 +95,7 @@ async function generate(file, moduleType) {
9595
fs.mkdirSync(fourth_runPath, { recursive: true })
9696
writeRunner(third, fourth_testRe, fourth_runPath, moduleType)
9797
if (fourth.hasOwnProperty('item') == false) {
98-
writeTest(fourth, fourth_test, fourth_pageRe, moduleType)
98+
writeTest(fourth, fourth_test, fourth_pageRe, moduleType, fourth_confRe)
9999
writePages(fourth, fourth_page, fourth_schRe, fourth_helpRe, moduleType, fourth_confRe)
100100
writeJsonSchema(fourth, fourth_sch, moduleType)
101101
await waitFor(10)
@@ -118,7 +118,7 @@ async function generate(file, moduleType) {
118118
writeRunner(fourth, fifth_testRe, fifth_runPath, moduleType)
119119
await waitFor(50)
120120
if (fifth.hasOwnProperty('item') == false) {
121-
writeTest(fifth, fifth_test, fifth_pageRe, moduleType)
121+
writeTest(fifth, fifth_test, fifth_pageRe, moduleType, fifth_confRe)
122122
writePages(fifth, fifth_page, fifth_schRe, fifth_helpRe, moduleType, fifth_confRe)
123123
writeJsonSchema(fifth, fifth_sch, moduleType)
124124
await waitFor(10)
@@ -141,7 +141,7 @@ async function generate(file, moduleType) {
141141
writeRunner(fifth, sixth_testRe, sixth_runPath, moduleType)
142142
await waitFor(50)
143143
if (sixth.hasOwnProperty('item') == false) {
144-
writeTest(sixth, sixth_test, sixth_pageRe, moduleType)
144+
writeTest(sixth, sixth_test, sixth_pageRe, moduleType, sixth_confRe)
145145
writePages(sixth, sixth_page, sixth_schRe, sixth_helpRe, moduleType, sixth_confRe)
146146
writeJsonSchema(sixth, sixth_sch, moduleType)
147147
await waitFor(10)
@@ -177,7 +177,7 @@ async function generate(file, moduleType) {
177177
fs.mkdirSync(runPath, { recursive: true })
178178

179179
writeRunner(element, testRelativePath, runPath, moduleType)
180-
writeTest(element, testPath, pagesPathRelativePath, moduleType)
180+
writeTest(element, testPath, pagesPathRelativePath, moduleType, configPath)
181181
writePages(element, pagesPath, jsonSchemaRelativePath, helperPath, moduleType, configPath)
182182
writeJsonSchema(element, jsonSchemaPath, moduleType)
183183
await waitFor(10)

lib/template/commonjs/test.dot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const expect = require('chai').expect
22
const chai = require('chai')
33
chai.use(require('chai-json-schema'))
4-
const pages = require('{{pagesPath}}');
4+
const pages = require('{{pagesPath}}')
5+
const config = require('{{configPath}}')
56
{{dataDriven}}
67

78
module.exports = () => {

lib/template/jsimport/test.dot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from 'chai'
22
import chai from 'chai'
33
import chaiJsonSchema from 'chai-json-schema'
44
import pages from '{{pagesPath}}'
5+
import config from '{{configPath}}'
56
chai.use(chaiJsonSchema)
67
{{dataDriven}}
78

0 commit comments

Comments
 (0)