How to use the ember-data-factory-guy.makeList function in ember-data-factory-guy

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 danielspaniel / ember-data-factory-guy / tests / unit / shared-factory-guy-behaviour.js View on Github external
test("handles hasMany relationships", function(assert) {
    let projects = makeList('project', 1),
        user     = makeNew('user', {projects});
    assert.deepEqual(user.get('projects').toArray(), projects.toArray(), 'hasMany projects');
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-factory-guy-behaviour.js View on Github external
test("handles traits and optional fixture arguments", function(assert) {
    let users = FactoryGuy.makeList('user', 2, 'with_hats', {name: 'Bob'});
    assert.equal(users[0].get('name'), 'Bob');
    assert.equal(users[0].get('hats.length') === 2, true);
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-factory-guy-behaviour.js View on Github external
test("with data and links for hasMany relationship", function(assert) {
    const properties   = makeList('property', 2),
          propertyLink = '/user/1/properties',
          user         = make('user', {properties, links: {properties: propertyLink}});

    assert.equal(user.hasMany('properties').link(), propertyLink, 'has link');
    assert.deepEqual(user.properties.toArray(), properties, 'has models');
  });
github danielspaniel / ember-data-factory-guy / tests / unit / shared-adapter-behaviour.js View on Github external
run(() => {
      let done = assert.async();
      let expectedAssertions = 2;

      function finalizeTest() {
        --expectedAssertions;
        if (expectedAssertions === 0) {
          done();
        }
      }

      let companies = makeList('company', 2);

      mockQuery('company', {name: 'Dude'}).returns({models: companies});
      mockQuery('company', {type: 'Small', name: 'Dude'}).returns({models: companies});

      let request1 = FactoryGuy.store.query('company', {name: 'Dude'});
      let request2 = FactoryGuy.store.query('company', {type: 'Small', name: 'Dude'});

      request1.then(function(returnedCompanies) {
        assert.equal(A(companies).mapBy('id') + '', A(returnedCompanies).mapBy('id') + '');
        finalizeTest();
      });

      request2.then(function(returnedCompanies) {
        assert.equal(A(companies).mapBy('id') + '', A(returnedCompanies).mapBy('id') + '');
        finalizeTest();
      });