Added index

This commit is contained in:
Stanislav Romanov 2021-01-27 17:12:19 +03:00
parent 72f59d6ced
commit 9740deb496
11 changed files with 123 additions and 3 deletions

View file

@ -0,0 +1,5 @@
import RESTAdapter from '@ember-data/adapter/rest';
export default class ApplicationAdapter extends RESTAdapter {
host = 'http://127.0.0.1:7700';
}

View file

@ -0,0 +1,11 @@
import Inflector from 'ember-inflector';
export function initialize(/* application */) {
const inflector = Inflector.inflector;
inflector.irregular('index', 'indexes');
}
export default {
initialize
};

7
app/models/index.js Normal file
View file

@ -0,0 +1,7 @@
import Model, { attr } from '@ember-data/model';
export default class IndexModel extends Model {
@attr('string') primaryKey;
@attr('date') createdAt;
@attr('date') updatedAt;
}

View file

@ -0,0 +1,7 @@
import Route from '@ember/routing/route';
export default class ApplicationRoute extends Route {
model() {
return this.store.findAll('index');
}
}

View file

@ -0,0 +1,5 @@
import JSONSerializer from '@ember-data/serializer/json';
export default class ApplicationSerializer extends JSONSerializer {
primaryKey = 'uid';
}

View file

@ -1,6 +1,3 @@
{{page-title "MeiliSearch Admin"}}
{{outlet}}
<div class="container mx-auto">
<h1 class="font-mono text-blue-500">Hello Tailwind</h1>
</div>

View file

@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Adapter | application', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let adapter = this.owner.lookup('adapter:application');
assert.ok(adapter);
});
});

View file

@ -0,0 +1,29 @@
import Application from '@ember/application';
import { initialize } from 'meilisearch-admin/initializers/custom-inflector-rules';
import { module, test } from 'qunit';
import Resolver from 'ember-resolver';
import { run } from '@ember/runloop';
module('Unit | Initializer | custom-inflector-rules', function(hooks) {
hooks.beforeEach(function() {
this.TestApplication = class TestApplication extends Application {}
this.TestApplication.initializer({
name: 'initializer under test',
initialize
});
this.application = this.TestApplication.create({ autoboot: false, Resolver });
});
hooks.afterEach(function() {
run(this.application, 'destroy');
});
// TODO: Replace this with your real tests.
test('it works', async function(assert) {
await this.application.boot();
assert.ok(true);
});
});

View file

@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | index', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('index', {});
assert.ok(model);
});
});

View file

@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | application', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:application');
assert.ok(route);
});
});

View file

@ -0,0 +1,23 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Serializer | application', function(hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function(assert) {
let store = this.owner.lookup('service:store');
let serializer = store.serializerFor('application');
assert.ok(serializer);
});
test('it serializes records', function(assert) {
let store = this.owner.lookup('service:store');
let record = store.createRecord('application', {});
let serializedRecord = record.serialize();
assert.ok(serializedRecord);
});
});