mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-17 21:56:56 +00:00
37 lines
1.4 KiB
JavaScript
37 lines
1.4 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';
|
|
import mirageScenario from 'wherehows-web/mirage/scenarios/default';
|
|
|
|
module('Unit | Utility | datasets/create search entries', function(hooks) {
|
|
hooks.beforeEach(function() {
|
|
this.server = startMirage();
|
|
});
|
|
|
|
hooks.afterEach(function() {
|
|
this.server.shutdown();
|
|
});
|
|
|
|
test('it works base case', function(assert) {
|
|
const { server } = this;
|
|
const dataset = server.create('dataset', 'forUnitTests').attrs;
|
|
|
|
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').attrs;
|
|
|
|
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');
|
|
});
|
|
});
|