datahub/wherehows-web/tests/unit/utils/datasets/create-search-entries-test.js
Seyi Adebajo 1c02e757ab for TypeScript breaking change with keyof operator now supporting number and symbol type, use extract to specify string type
upgrades various dependencies. renames mirage .js files to .ts. fixes linting issues. rebuilds lock file

removes redux deps

upgrades to latest

Revert "upgrades to latest"

This reverts commit 45d2d45b0a28db3217863b2ac9492c5bfe67bf0a.

 Committer: Seyi Adebajo <sadebajo@linkedin.com>

reoders tsconfig keys
2018-08-05 14:24:09 -07:00

35 lines
1.3 KiB
JavaScript

import { module, test } from 'qunit';
import { startMirage } from 'wherehows-web/initializers/ember-cli-mirage';
import datasetsCreateSearchEntries from 'wherehows-web/utils/datasets/create-search-entries';
import { testSchemaA } from 'wherehows-web/mirage/fixtures/schema';
module('Unit | Utility | datasets/create search entries', {
beforeEach() {
this.server = startMirage();
},
afterEach() {
this.server.shutdown();
}
});
test('it works base case', function(assert) {
const { server } = this;
const dataset = server.create('dataset', 'forUnitTests');
const result = datasetsCreateSearchEntries([]);
assert.ok(!result, 'Returns without error for nothing case');
datasetsCreateSearchEntries([dataset]);
assert.equal(dataset.id, 0, 'Sanity check: Created model successfully');
assert.equal(dataset.schema, testSchemaA.slice(0, 499), 'Partial schema from beginning if no keyword found');
});
test('it works for keyword cases', function(assert) {
const { server } = this;
const dataset = server.create('dataset', 'forUnitTests');
datasetsCreateSearchEntries([dataset], 'Rebel');
assert.equal(dataset.id, 0, 'Sanity check: Created model successfully again');
assert.equal(dataset.schema, testSchemaA.slice(29, 529), 'Partial schema starts from keyword index');
});