How to use ember-data-factory-guy - 10 common examples

To help you get started, we’ve selected a few ember-data-factory-guy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CenterForOpenScience / ember-osf-web / tests / factories / file.ts View on Github external
import FactoryGuy from 'ember-data-factory-guy';
import faker from 'faker';

FactoryGuy.define('file', {
    default: {
        name: () => `${faker.lorem.words(1)}.txt`,
        kind: 'file',
        path: '/1234567890', // Faker.system.filePath may not yet be implemented
        size: () => faker.random.number(),
        provider: 'osfstorage',
        materializedPath: () => `/${faker.lorem.words(1)}.png`,
        lastTouched: null,

        dateModified: () => faker.date.recent(1),
        dateCreated: () => faker.date.past(1),

        isProvider: false,
        checkout: null,

        links: {
github CenterForOpenScience / ember-osf / test-support / factories / file-version.js View on Github external
import FactoryGuy from 'ember-data-factory-guy';
import faker from 'faker';

FactoryGuy.define('file-version', {
    default: {
        size: () => faker.random.number(),
        contentType: 'text/plain', // faker.system may not come with older versions of lib
    }
});
github CenterForOpenScience / ember-osf / test-support / factories / file.js View on Github external
import FactoryGuy from 'ember-data-factory-guy';
import faker from 'faker';

FactoryGuy.define('file', {
    default: {
        name: () => faker.lorem.words(1) + '.txt',
        kind: 'file',
        path: '/1234567890',  // Faker.system.filePath may not yet be implemented
        size: () => faker.random.number(),
        provider: 'osfstorage',
        materializedPath: () => '/' + faker.lorem.words(1) + '.png',
        lastTouched: null,

        dateModified: () => faker.date.recent(1),
        dateCreated: () => faker.date.past(1),

        isProvider: false,
        checkout: null,

        links: {
github CenterForOpenScience / ember-osf-web / tests / factories / node.ts View on Github external
},
    traits: {
        hasParent: { // Is a child of a public node
            parent: () => FactoryGuy.belongsTo('node'),
        },
        hasChildren: { // Has one layer of child projects
            children: FactoryGuy.hasMany('node', 3),
        },
        hasInstitution: {
            affiliatedInstitutions: FactoryGuy.hasMany('institution', 1),
        },
        hasComments: {
            comments: FactoryGuy.hasMany('comment', 3),
        },
        hasContributors: {
            contributors: FactoryGuy.hasMany('contributor', 3),
        },
        hasFiles: {
            files: FactoryGuy.hasMany('file-provider', 3, 'hasFiles'),
        },
        hasRegistrations: {
            registrations: FactoryGuy.hasMany('registration', 1),
        },
        hasLogs: {
            logs: FactoryGuy.hasMany('log', 5),
        },
        hasTags: {
            tags: () => [faker.lorem.words(1), faker.lorem.words(1), faker.lorem.words(1)],
        },
    },
});
github CenterForOpenScience / ember-osf-web / tests / factories / node.ts View on Github external
collection: false,
        registration: false,
        public: () => faker.random.boolean(),

        dateCreated: () => faker.date.past(1),
        dateModified: () => faker.date.recent(1),
    },
    traits: {
        hasParent: { // Is a child of a public node
            parent: () => FactoryGuy.belongsTo('node'),
        },
        hasChildren: { // Has one layer of child projects
            children: FactoryGuy.hasMany('node', 3),
        },
        hasInstitution: {
            affiliatedInstitutions: FactoryGuy.hasMany('institution', 1),
        },
        hasComments: {
            comments: FactoryGuy.hasMany('comment', 3),
        },
        hasContributors: {
            contributors: FactoryGuy.hasMany('contributor', 3),
        },
        hasFiles: {
            files: FactoryGuy.hasMany('file-provider', 3, 'hasFiles'),
        },
        hasRegistrations: {
            registrations: FactoryGuy.hasMany('registration', 1),
        },
        hasLogs: {
            logs: FactoryGuy.hasMany('log', 5),
        },
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(async () => {
      let serializer = FactoryGuy.store.serializerFor('profile');
      serializer.attrs = {
        created_at: {
          serialize: false
        }
      };

      let date = new Date();
      let profile = make('profile');
      profile.set('created_at', date);

      mockUpdate(profile)
      .match({created_at: null}) // serializer removes date
      .returns({attrs: {created_at: date}});

      await profile.save();

      assert.ok(profile.get('created_at').toString() === date.toString());
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();

      let mock = mockCreate('profile').match({description: 'correct description'});

      FactoryGuy.store.createRecord('profile', {description: 'wrong description'}).save()
                .catch(() => {
                  assert.ok(true);
                  // our mock was NOT called
                  assert.equal(mock.timesCalled, 0);
                  done();
                });
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();

      let json = buildList('user', 1);
      mockQuery('user', {name: 'Bob'}).returns({json});
      FactoryGuy.store.query('user', {name: 'Bob'}).then(function(users) {
        assert.equal(users.get('length'), 1);
        // makes the user after getting query response
        assert.equal(FactoryGuy.store.peekAll('user').get('content').length, 1);
        done();
      });
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();

      let json = buildList('user', 1);
      mockQuery('user', {name: 'Bob'}).returns({json});
      FactoryGuy.store.query('user', {name: 'Bob'}).then(function(users) {
        assert.equal(users.get('length'), 1);
        // makes the user after getting query response
        assert.equal(FactoryGuy.store.peekAll('user').get('content').length, 1);
        done();
      });
    });
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();

      let json = buildList('user', 1);
      mockQuery('user', {name: 'Bob'}).returns({json});
      FactoryGuy.store.query('user', {name: 'Bob'}).then(function(users) {
        assert.equal(users.get('length'), 1);
        // makes the user after getting query response
        assert.equal(FactoryGuy.store.peekAll('user').get('content').length, 1);
        done();
      });
    });
  });