import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { IFileViewerComponent, IFileViewerItem } from '@datahub/data-models/types/entity/rendering/page-components'; module('Integration | Component | entity-page/entity-page-content/json-viewer', function(hooks): void { setupRenderingTest(hooks); test('it renders', async function(assert): Promise { const entity: { file: IFileViewerItem; } = { file: { content: 'some text', type: 'text' } }; const options: IFileViewerComponent['options'] = { emptyStateMessage: 'empty', propertyName: 'file' }; this.setProperties({ options, entity }); await render(hbs``); assert.dom('.ace_text-layer').hasText('some text'); this.setProperties({ options, entity: {} }); assert.dom('.empty-state').hasText('empty'); this.setProperties({ options, entity: { file: { content: '{ "property": "value" }', type: 'json' } } }); assert.dom('.ace_variable').hasText('"property"'); assert.dom('.ace_string').hasText('"value"'); this.setProperties({ options, entity: { file: { content: 'type Meta { count: Int }', type: 'graphqlschema' } } }); assert.dom('.ace_keyword').hasText('type'); assert.dom('.ace_identifier').hasText('Meta'); assert.dom('.ace_storage').hasText('Int'); }); });