Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* Releases updated version of datahub-web client UI code

* Fix typo in yarn lock

* Change yarn lock to match yarn registry directories

* Previous commit missed some paths

* Even more changes to yarnlock missing in previous commit

* Include codegen file for typings

* Add files to get parity for datahub-web and current OS datahub-midtier

* Add in typo fix from previous commit - change to proper license

* Implement proper OS fix for person entity picture url

* Workarounds for open source DH issues

* Fixes institutional memory api and removes unopensourced tabs for datasets

* Fixes search dataset deprecation and user search issue as a result of changes

* Remove internal only options in the avatar menu
2020-08-26 15:44:50 -07:00

64 lines
1.7 KiB
TypeScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
// Helps us convert to rgb to compare to window computed styles for our component
function hexToRgb(
hex: string
): {
r: number;
g: number;
b: number;
asString(): string;
} {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex) || [];
return {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16),
asString(): string {
return `rgb(${this.r}, ${this.g}, ${this.b})`;
}
};
}
module('Unit | Styles Testing', function(hooks) {
setupRenderingTest(hooks);
test('function tests', async function(assert) {
await render(hbs`<div id="color-div" class="test-color"></div>`);
const expectedHex = '#665ed0';
let myEl = find('#color-div');
assert.equal(
myEl && window.getComputedStyle(myEl).color,
hexToRgb(expectedHex).asString(),
'get-color function adds style as expected'
);
await render(hbs`<div id="spacing-div" class="test-item-spacing"></div>`);
myEl = find('#spacing-div');
assert.equal(
myEl && window.getComputedStyle(myEl).marginLeft,
'24px',
'item-spacing function adds style as expected'
);
});
test('mixin tests', async function(assert) {
await render(hbs`<div id="nacho-container-div" class="test-nacho-container"></div>`);
const myEl = find('#nacho-container-div');
assert.equal(
myEl && window.getComputedStyle(myEl).borderRadius,
'2px',
'nacho-container mixin was included as expected'
);
});
});