Skip to content

Commit

Permalink
Missing import of sleep.
Browse files Browse the repository at this point in the history
  • Loading branch information
legander committed Jul 10, 2019
1 parent 01df4ad commit e44bf0f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "har-to-k6",
"description": "Convert LI-HAR to k6 script",
"version": "0.1.1",
"version": "0.1.2",
"license": "Apache-2.0",
"keywords": [
"k6",
Expand Down
8 changes: 5 additions & 3 deletions src/render/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ function any (spec) {
}

function k6 (spec, lines) {
const items = ['sleep']

if (spec.check || spec.group) {
const items = []
if (spec.check) {
items.push('check')
}
if (spec.group) {
items.push('group')
}
const content = items.join(`, `)
lines.push(`import { ${content} } from "k6";`)
}

const content = items.join(`, `)
lines.push(`import { ${content} } from "k6";`)
}

function http (spec, lines) {
Expand Down
11 changes: 7 additions & 4 deletions test/unit/render/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ test('k6', t => {
spec.group = true
spec.check = true
const result = imports(spec)
t.is(result, `import { check, group } from "k6";`)
t.is(result, `import { sleep, check, group } from "k6";`)
})

test('http', t => {
const spec = makeImports()
spec.http = true
const result = imports(spec)
t.is(result, `import http from "k6/http";`)
t.is(result, `import { sleep } from "k6";\nimport http from "k6/http";`)
})

// TODO: update when K6 remote js lib is up.
Expand All @@ -31,7 +31,10 @@ test('compat', t => {
const result = imports(spec)
t.is(
result,
`import formurlencoded from "jslib.k6.io/form-urlencoded/3.0.0/index.js"
`import { sleep } from "k6";
import formurlencoded from "jslib.k6.io/form-urlencoded/3.0.0/index.js"
import jsonpath from "jslib.k6.io/jsonpath/1.0.2/index.js"`
)
})
Expand All @@ -47,7 +50,7 @@ test('combined', t => {
spec.MimeBuilder = true
const result = imports(spec)
t.is(result, '' +
`import { check, group } from "k6";
`import { sleep, check, group } from "k6";
import http from "k6/http";
Expand Down

0 comments on commit e44bf0f

Please sign in to comment.