Skip to content

Commit

Permalink
housekeeping: use debounce for validation helper promise timing (via s…
Browse files Browse the repository at this point in the history
…wagger-api#1963)

* use debounce for validation helper promise timing

* reduce ASYNC_TEST_DELAY default
  • Loading branch information
shockey authored Mar 12, 2019
1 parent 7d4ed91 commit 5d3783e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions test/unit/plugins/validate-semantic/validate-helper.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import expect from "expect"
import SwaggerUi from "swagger-ui"
import throttle from "lodash/throttle"
import debounce from "lodash/debounce"

import ValidateBasePlugin from "plugins/validate-base"
import ValidateSemanticPlugin from "plugins/validate-semantic"
import ASTPlugin from "plugins/ast"

const envDelay = process.env.ASYNC_TEST_DELAY

const DELAY_MS = (typeof envDelay === "string" ? parseInt(envDelay) : envDelay) || 200
const DELAY_MS = (typeof envDelay === "string" ? parseInt(envDelay) : envDelay) || 50

export default function validateHelper(spec) {
return new Promise((resolve) => {
Expand Down Expand Up @@ -47,9 +47,7 @@ export default function validateHelper(spec) {

system.validateActions.all()

const registerActivity = throttle(() => resolve(system), DELAY_MS, {
leading: false
})
const registerActivity = debounce(() => resolve(system), DELAY_MS)

system.getStore().subscribe(registerActivity)
})
Expand Down

0 comments on commit 5d3783e

Please sign in to comment.