11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ciconst tmock = require('../../fixtures/tmock') 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cilet pulseStarted = null 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst pulseTillDone = tmock(t, '{LIB}/utils/pulse-till-done.js', { 71cb0ef41Sopenharmony_ci npmlog: { 81cb0ef41Sopenharmony_ci gauge: { 91cb0ef41Sopenharmony_ci pulse: () => { 101cb0ef41Sopenharmony_ci if (pulseStarted) { 111cb0ef41Sopenharmony_ci pulseStarted() 121cb0ef41Sopenharmony_ci } 131cb0ef41Sopenharmony_ci }, 141cb0ef41Sopenharmony_ci }, 151cb0ef41Sopenharmony_ci }, 161cb0ef41Sopenharmony_ci}) 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cit.test('pulses (with promise)', async (t) => { 191cb0ef41Sopenharmony_ci t.teardown(() => { 201cb0ef41Sopenharmony_ci pulseStarted = null 211cb0ef41Sopenharmony_ci }) 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci let resolver 241cb0ef41Sopenharmony_ci const promise = new Promise(resolve => { 251cb0ef41Sopenharmony_ci resolver = resolve 261cb0ef41Sopenharmony_ci }) 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci const result = pulseTillDone.withPromise(promise) 291cb0ef41Sopenharmony_ci // wait until the gauge has fired at least once 301cb0ef41Sopenharmony_ci await new Promise(resolve => { 311cb0ef41Sopenharmony_ci pulseStarted = resolve 321cb0ef41Sopenharmony_ci }) 331cb0ef41Sopenharmony_ci resolver('value') 341cb0ef41Sopenharmony_ci t.resolveMatch(result, 'value', 'returned the resolved promise') 351cb0ef41Sopenharmony_ci}) 36