mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { module, test } from 'qunit';
 | |
| import { setupRenderingTest } from 'ember-qunit';
 | |
| import { render, fillIn } from '@ember/test-helpers';
 | |
| import hbs from 'htmlbars-inline-precompile';
 | |
| import sinon from 'sinon';
 | |
| 
 | |
| module('Integration | Component | ttl-form', function (hooks) {
 | |
|   setupRenderingTest(hooks);
 | |
| 
 | |
|   hooks.beforeEach(function () {
 | |
|     this.changeSpy = sinon.spy();
 | |
|     this.set('onChange', this.changeSpy);
 | |
|   });
 | |
| 
 | |
|   test('it shows no initial time and initial unit of s when not time or unit passed in', async function (assert) {
 | |
|     await render(hbs`<TtlForm @onChange={{this.onChange}} />`);
 | |
|     assert.dom('[data-test-ttlform-value]').hasValue('');
 | |
|     assert.dom('[data-test-select="ttl-unit"]').hasValue('s');
 | |
|   });
 | |
| 
 | |
|   test('it calls the change fn with the correct values', async function (assert) {
 | |
|     await render(hbs`<TtlForm @onChange={{this.onChange}} @unit="m" />`);
 | |
| 
 | |
|     assert.dom('[data-test-select="ttl-unit"]').hasValue('m', 'unit value initially shows m (minutes)');
 | |
|     await fillIn('[data-test-ttlform-value]', '10');
 | |
|     await assert.ok(this.changeSpy.calledOnce, 'it calls the passed onChange');
 | |
|     assert.ok(
 | |
|       this.changeSpy.calledWith({
 | |
|         seconds: 600,
 | |
|         timeString: '10m',
 | |
|       }),
 | |
|       'Passes the default values back to onChange'
 | |
|     );
 | |
|   });
 | |
| 
 | |
|   test('it correctly shows initial unit', async function (assert) {
 | |
|     const changeSpy = sinon.spy();
 | |
|     this.set('onChange', changeSpy);
 | |
|     await render(hbs`
 | |
|       <TtlForm
 | |
|         @unit="h"
 | |
|         @time="3"
 | |
|         @onChange={{this.onChange}}
 | |
|       />
 | |
|     `);
 | |
| 
 | |
|     assert.dom('[data-test-select="ttl-unit"]').hasValue('h', 'unit value initially shows as h (hours)');
 | |
|   });
 | |
| });
 | 
