BREAKING CHANGE(switch scope): update
This commit is contained in:
		
							
								
								
									
										74
									
								
								test/test.ts
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								test/test.ts
									
									
									
									
									
								
							@@ -1,51 +1,51 @@
 | 
			
		||||
import { expect, tap } from 'tapbundle'
 | 
			
		||||
import { expect, tap } from 'tapbundle';
 | 
			
		||||
 | 
			
		||||
import * as smartdelay from '../ts/index'
 | 
			
		||||
import * as smartdelay from '../ts/index';
 | 
			
		||||
 | 
			
		||||
tap.test('.delayFor should delay async', async (tools) => {
 | 
			
		||||
  tools.timeout(5000)
 | 
			
		||||
  let timePassed = false
 | 
			
		||||
tap.test('.delayFor should delay async', async tools => {
 | 
			
		||||
  tools.timeout(5000);
 | 
			
		||||
  let timePassed = false;
 | 
			
		||||
  setTimeout(() => {
 | 
			
		||||
    timePassed = true
 | 
			
		||||
  }, 2000)
 | 
			
		||||
    timePassed = true;
 | 
			
		||||
  }, 2000);
 | 
			
		||||
  await smartdelay.delayFor(3000).then(async () => {
 | 
			
		||||
    // tslint:disable-next-line:no-unused-expression
 | 
			
		||||
    expect(timePassed).to.be.true
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
    expect(timePassed).to.be.true;
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.test('.delayForRandpm should delay async for a random time period', async (tools) => {
 | 
			
		||||
  tools.timeout(5000)
 | 
			
		||||
  let timePassed = false
 | 
			
		||||
tap.test('.delayForRandpm should delay async for a random time period', async tools => {
 | 
			
		||||
  tools.timeout(5000);
 | 
			
		||||
  let timePassed = false;
 | 
			
		||||
  setTimeout(() => {
 | 
			
		||||
    timePassed = true
 | 
			
		||||
  }, 3000)
 | 
			
		||||
  await smartdelay.delayForRandom(3000,4900).then(async () => {
 | 
			
		||||
    timePassed = true;
 | 
			
		||||
  }, 3000);
 | 
			
		||||
  await smartdelay.delayForRandom(3000, 4900).then(async () => {
 | 
			
		||||
    // tslint:disable-next-line:no-unused-expression
 | 
			
		||||
    expect(timePassed).to.be.true
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
    expect(timePassed).to.be.true;
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.test('.delayFor should pass on a type', async (tools) => {
 | 
			
		||||
  tools.timeout(5000)
 | 
			
		||||
  let timePassed = false
 | 
			
		||||
tap.test('.delayFor should pass on a type', async tools => {
 | 
			
		||||
  tools.timeout(5000);
 | 
			
		||||
  let timePassed = false;
 | 
			
		||||
  setTimeout(() => {
 | 
			
		||||
    timePassed = true
 | 
			
		||||
  }, 2000)
 | 
			
		||||
  let hey = 'heyThere'
 | 
			
		||||
  await smartdelay.delayFor<string>(3000, hey).then(async (stringArg) => {
 | 
			
		||||
    expect(stringArg).equal('heyThere')
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
    timePassed = true;
 | 
			
		||||
  }, 2000);
 | 
			
		||||
  let hey = 'heyThere';
 | 
			
		||||
  await smartdelay.delayFor<string>(3000, hey).then(async stringArg => {
 | 
			
		||||
    expect(stringArg).equal('heyThere');
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.test('smartdelay.Timeout', async () => {
 | 
			
		||||
  let timeout = new smartdelay.Timeout(2000)
 | 
			
		||||
  await timeout.promise
 | 
			
		||||
})
 | 
			
		||||
  let timeout = new smartdelay.Timeout(2000);
 | 
			
		||||
  await timeout.promise;
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.test('smartdelay.Timeout should cancel', async (tools) => {
 | 
			
		||||
  let timeout = new smartdelay.Timeout(60000)
 | 
			
		||||
  timeout.cancel()
 | 
			
		||||
})
 | 
			
		||||
tap.test('smartdelay.Timeout should cancel', async tools => {
 | 
			
		||||
  let timeout = new smartdelay.Timeout(60000);
 | 
			
		||||
  timeout.cancel();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.start()
 | 
			
		||||
tap.start();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user