diff --git a/app/adapters/application.js b/app/adapters/application.js new file mode 100644 index 0000000..1ea38f9 --- /dev/null +++ b/app/adapters/application.js @@ -0,0 +1,5 @@ +import RESTAdapter from '@ember-data/adapter/rest'; + +export default class ApplicationAdapter extends RESTAdapter { + host = 'http://127.0.0.1:7700'; +} diff --git a/app/initializers/custom-inflector-rules.js b/app/initializers/custom-inflector-rules.js new file mode 100644 index 0000000..351a500 --- /dev/null +++ b/app/initializers/custom-inflector-rules.js @@ -0,0 +1,11 @@ +import Inflector from 'ember-inflector'; + +export function initialize(/* application */) { + const inflector = Inflector.inflector; + + inflector.irregular('index', 'indexes'); +} + +export default { + initialize +}; diff --git a/app/models/index.js b/app/models/index.js new file mode 100644 index 0000000..453c9b8 --- /dev/null +++ b/app/models/index.js @@ -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; +} diff --git a/app/routes/application.js b/app/routes/application.js new file mode 100644 index 0000000..8bacc07 --- /dev/null +++ b/app/routes/application.js @@ -0,0 +1,7 @@ +import Route from '@ember/routing/route'; + +export default class ApplicationRoute extends Route { + model() { + return this.store.findAll('index'); + } +} diff --git a/app/serializers/application.js b/app/serializers/application.js new file mode 100644 index 0000000..5e440c8 --- /dev/null +++ b/app/serializers/application.js @@ -0,0 +1,5 @@ +import JSONSerializer from '@ember-data/serializer/json'; + +export default class ApplicationSerializer extends JSONSerializer { + primaryKey = 'uid'; +} diff --git a/app/templates/application.hbs b/app/templates/application.hbs index 3eb4a51..c4cb938 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -1,6 +1,3 @@ {{page-title "MeiliSearch Admin"}} {{outlet}} -
-

Hello Tailwind

-
diff --git a/tests/unit/adapters/application-test.js b/tests/unit/adapters/application-test.js new file mode 100644 index 0000000..eff23bb --- /dev/null +++ b/tests/unit/adapters/application-test.js @@ -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); + }); +}); diff --git a/tests/unit/initializers/custom-inflector-rules-test.js b/tests/unit/initializers/custom-inflector-rules-test.js new file mode 100644 index 0000000..b90e410 --- /dev/null +++ b/tests/unit/initializers/custom-inflector-rules-test.js @@ -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); + }); +}); diff --git a/tests/unit/models/index-test.js b/tests/unit/models/index-test.js new file mode 100644 index 0000000..cfc9cf3 --- /dev/null +++ b/tests/unit/models/index-test.js @@ -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); + }); +}); diff --git a/tests/unit/routes/application-test.js b/tests/unit/routes/application-test.js new file mode 100644 index 0000000..21e9fb3 --- /dev/null +++ b/tests/unit/routes/application-test.js @@ -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); + }); +}); diff --git a/tests/unit/serializers/application-test.js b/tests/unit/serializers/application-test.js new file mode 100644 index 0000000..d197afe --- /dev/null +++ b/tests/unit/serializers/application-test.js @@ -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); + }); +});