mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 02:37:05 +00:00 
			
		
		
		
	Add tests for dataset health score table
This commit is contained in:
		
							parent
							
								
									3481848470
								
							
						
					
					
						commit
						8f49e5e7fd
					
				| @ -1,26 +1,48 @@ | |||||||
| import { module, test } from 'qunit'; | import { moduleForComponent, test } from 'ember-qunit'; | ||||||
| import { setupRenderingTest } from 'ember-qunit'; | import { run } from '@ember/runloop'; | ||||||
| import { render } from '@ember/test-helpers'; |  | ||||||
| import hbs from 'htmlbars-inline-precompile'; | import hbs from 'htmlbars-inline-precompile'; | ||||||
|  | import healthDetail from 'wherehows-web/mirage/fixtures/health-detail'; | ||||||
| 
 | 
 | ||||||
| module('Integration | Component | datasets/health/score-table', function(hooks) { | moduleForComponent('datasets/health/score-table', 'Integration | Component | datasets/health/score-table', { | ||||||
|   setupRenderingTest(hooks); |   integration: true | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | const table = '.dataset-health__score-table'; | ||||||
|  | const row = `${table}__row`; | ||||||
| 
 | 
 | ||||||
| test('it renders', async function(assert) { | test('it renders', async function(assert) { | ||||||
|     // Set any properties with this.set('myProperty', 'value');
 |   this.render(hbs`{{datasets/health/score-table}}`); | ||||||
|     // Handle any actions with this.set('myAction', function(val) { ... });
 |  | ||||||
| 
 | 
 | ||||||
|     await render(hbs`{{datasets/health/score-table}}`); |   assert.ok(this.$(), 'Renders without errors as standalone component'); | ||||||
| 
 |  | ||||||
|     assert.equal(this.element.textContent.trim(), ''); |  | ||||||
| 
 |  | ||||||
|     // Template block usage:
 |  | ||||||
|     await render(hbs` |  | ||||||
|       {{#datasets/health/score-table}} |  | ||||||
|         template block text |  | ||||||
|       {{/datasets/health/score-table}} |  | ||||||
|     `);
 |  | ||||||
| 
 |  | ||||||
|     assert.equal(this.element.textContent.trim(), 'template block text'); |  | ||||||
| }); | }); | ||||||
|  | 
 | ||||||
|  | test('it renders the correct information', async function(assert) { | ||||||
|  |   const tableData = healthDetail; | ||||||
|  | 
 | ||||||
|  |   this.set('tableData', tableData); | ||||||
|  |   this.render(hbs`{{datasets/health/score-table
 | ||||||
|  |                     tableData=tableData}}`);
 | ||||||
|  | 
 | ||||||
|  |   assert.ok(this.$(), 'Still renders without errors'); | ||||||
|  |   assert.equal(this.$(table).length, 1, 'Renders one table'); | ||||||
|  |   assert.equal(this.$(row).length, tableData.length, 'Renders one row for every detail data'); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it filters correctly', async function(assert) { | ||||||
|  |   const tableData = healthDetail; | ||||||
|  |   const numComplianceRows = tableData.reduce((sum, curr) => sum + (curr.category === 'Compliance' ? 1 : 0), 0); | ||||||
|  | 
 | ||||||
|  |   this.setProperties({ | ||||||
|  |     tableData, | ||||||
|  |     categoryFilter: 'Compliance', | ||||||
|  |     severityFilter: '' | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   this.render(hbs`{{datasets/health/score-table
 | ||||||
|  |                     tableData=tableData | ||||||
|  |                     currentCategoryFilter=categoryFilter | ||||||
|  |                     currentSeverityFilter=severityFilter}}`);
 | ||||||
|  | 
 | ||||||
|  |   assert.ok(this.$(), 'Still renders further without errors'); | ||||||
|  |   assert.equal(this.$(row).length, numComplianceRows, 'Show correct rows based on filter'); | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 cptran777
						cptran777