コード例 #1
0
test('queryRecord calls _getContent with correct parameters', function(assert) {
  let actualParams = null;
  let done = assert.async();

  let ApplicationAdapter = ContentfulAdapter.extend({
    _getContent(type, params) {
      actualParams = params;
      this._super(...arguments);
    }
  });

  this.registry.register('adapter:application', ApplicationAdapter);

  return run(() => {
    return this.store().queryRecord('post', { order: 'fields.title' })
    .then(() => {
      assert.deepEqual(actualParams, {
        content_type: 'post',
        order: 'fields.title',
        skip: 0,
        limit: 1
      });
      done();
    });
  });
});
コード例 #2
0
import ContentfulAdapter from 'ember-data-contentful/adapters/contentful';

export default ContentfulAdapter.extend({});
コード例 #3
0
import { test, only, moduleForModel } from 'ember-qunit';
import ContentfulModel from 'ember-data-contentful/models/contentful';
import ContentfulAsset from 'ember-data-contentful/models/contentful-asset';
import ContentfulAdapter from 'ember-data-contentful/adapters/contentful';
import ContentfulSerializer from 'ember-data-contentful/serializers/contentful';

import attr from 'ember-data/attr';
import { belongsTo } from 'ember-data/relationships';

var Post, post, image;


moduleForModel('contentful', 'Unit | Serializer | contentful', {
  needs: ['model:contentful-asset'],
  beforeEach() {
    const ApplicationAdapter = ContentfulAdapter.extend({});
    this.registry.register('adapter:application', ApplicationAdapter);

    const ApplicationSerializer = ContentfulSerializer.extend({});
    this.registry.register('serializer:application', ApplicationSerializer);

    Post = ContentfulModel.extend({
      title: attr('string'),
      image: belongsTo('contentful-asset')
    });

    this.registry.register('model:post', Post);
    post = {
      "sys": {
        "space": {
          "sys": {