Example #1
0
module('Unit | Service | hot-keys', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    const service = this.owner.lookup('service:hot-keys');
    assert.ok(service);
  });

  test('it operates as intended', function(assert) {
    const service = this.owner.lookup('service:hot-keys');
    const theFloorIsLava = () => {
      assert.ok(true, 'The registered function was successfully called');
    };
    const theChairsArePeople = () => {
      assert.ok(false, 'This function should not run after being unregistered');
    };

    assert.expect(2);
    assert.ok(service);
    service.registerKeyMapping(Keyboard.ArrowUp, theFloorIsLava);
    service.applyKeyMapping(Keyboard.ArrowUp);

    service.registerKeyMapping(Keyboard.Enter, theChairsArePeople);
    service.unregisterKeyMapping(Keyboard.Enter);
    service.applyKeyMapping(Keyboard.Enter);
  });
});
module('Unit | Service | rollbar', function(hooks) {
  setupTest(hooks);
  setupSinonTest(hooks);

  test('it exists', function(assert) {
    assert.expect(0);

    let service = this.owner.lookup('service:rollbar');
    let mock = this.sinon.mock(get(service, 'instance'));
    let person = {name: 'Joe', email: '*****@*****.**'};

    mock.expects('log');
    mock.expects('debug');
    mock.expects('info');
    mock.expects('warn');
    mock.expects('warning');
    mock.expects('error');
    mock.expects('critical');
    mock.expects('configure').withArgs({payload: {person}});

    service.log('log');
    service.debug('debug');
    service.info('info');
    service.warn('warn');
    service.warning('warning');
    service.error('error');
    service.critical('critical');
    service.setPerson(person);

    mock.verify();
  });
});
Example #3
0
module('integration/injection factoryFor enabled', function(hooks) {
  setupTest(hooks);
  let store;
  let Model;

  hooks.beforeEach(function() {
    let { owner } = this;
    Model = {
      isModel: true,
    };
    owner.register('model:super-villain', Model);
    store = owner.lookup('service:store');
  });

  test('modelFactoryFor', function(assert) {
    let { owner } = this;
    const trueFactory = owner.factoryFor('model:super-villain');
    const modelFactory = store._modelFactoryFor('super-villain');

    assert.strictEqual(modelFactory, trueFactory, 'expected the factory itself to be returned');
  });

  test('modelFor', function(assert) {
    const modelClass = store.modelFor('super-villain');

    assert.strictEqual(modelClass, Model, 'expected the factory itself to be returned');

    assert.equal(
      modelClass.modelName,
      'super-villain',
      'expected the factory itself to be returned'
    );
  });
});
Example #4
0
module('Unit | Helper | to-items', function(hooks) {
  setupTest(hooks);

  test('it works', function(assert) {
    let groups = {
      odd: [1, 3, 5],
      even: [2, 4]
    };

    assert.deepEqual(
      toItems([groups], { keyName: 'name', valueName: 'items' }),
      [{ name: 'odd', items: [1, 3, 5] }, { name: 'even', items: [2, 4] }],
      'custom keyName and valueName'
    );

    assert.deepEqual(
      toItems([groups], { valueName: 'items' }),
      [{ key: 'odd', items: [1, 3, 5] }, { key: 'even', items: [2, 4] }],
      'default keyName'
    );

    assert.deepEqual(
      toItems([groups], {}),
      [{ key: 'odd', value: [1, 3, 5] }, { key: 'even', value: [2, 4] }],
      'default keyName and valueName'
    );
  });
});
module('Unit | Helpers | Helper URL Functions', function(hooks) {
  setupTest(hooks);

  test('that normalizeURL works correctly', function(assert) {
    assert.equal(normalizeURL('ws://localhost:8000'), 'ws://localhost:8000/');
    assert.equal(normalizeURL('ws://localhost:8000/'), 'ws://localhost:8000/');
    assert.equal(normalizeURL('ws://example.com'), 'ws://example.com/');
    assert.equal(normalizeURL('ws://example.com/foo'), 'ws://example.com/foo');
    assert.equal(normalizeURL('ws://example.com/foo/'), 'ws://example.com/foo/');
  });

  test('that normalizeURL works correctly if url contains query params', function(assert) {
    assert.equal(normalizeURL('ws://example.com/?param=value'), 'ws://example.com/?param=value');
    assert.equal(normalizeURL('ws://example.com?param=value'), 'ws://example.com/?param=value');
    assert.equal(normalizeURL('ws://example.com:8000/?param=value'), 'ws://example.com:8000/?param=value');
    assert.equal(normalizeURL('ws://example.com:8000?param=value'), 'ws://example.com:8000/?param=value');
    assert.equal(normalizeURL('ws://example.com:8000/foo?param=value'), 'ws://example.com:8000/foo?param=value');
    assert.equal(normalizeURL('ws://example.com:8000/foo/?param=value'), 'ws://example.com:8000/foo/?param=value');
  });

  test('that cleanURL works correctly', function(assert) {
    assert.equal(cleanURL('ws://example.com'), 'ws://examplecom');
    assert.equal(cleanURL('ws://example.com?param=foo.bar'), 'ws://examplecom?param=foobar');
  });
});
Example #6
0
module('Integration | Adapter | acl | response', function(hooks) {
  setupTest(hooks);
  const dc = 'dc-1';
  const id = 'token-name';
  test('handleResponse returns the correct data for list endpoint', function(assert) {
    const adapter = this.owner.lookup('adapter:acl');
    const request = {
      url: `/v1/acl/list?dc=${dc}`,
    };
    return get(request.url).then(function(payload) {
      const expected = payload.map(item =>
        Object.assign({}, item, {
          Datacenter: dc,
          uid: `["${dc}","${item.ID}"]`,
        })
      );
      const actual = adapter.handleResponse(200, {}, payload, request);
      assert.deepEqual(actual, expected);
    });
  });
  test('handleResponse returns the correct data for item endpoint', function(assert) {
    const adapter = this.owner.lookup('adapter:acl');
    const request = {
      url: `/v1/acl/info/${id}?dc=${dc}`,
    };
    return get(request.url).then(function(payload) {
      const expected = Object.assign({}, payload[0], {
        Datacenter: dc,
        uid: `["${dc}","${id}"]`,
      });
      const actual = adapter.handleResponse(200, {}, payload, request);
      assert.deepEqual(actual, expected);
    });
  });
});
Example #7
0
module('Unit | Component | error display', function(hooks) {
  setupTest(hooks);

  test('properties have default values', function(assert) {
    assert.expect(1);

    const expected = {
      errors:     null,
      showDetails: true
    };

    const Factory = this.owner.factoryFor('component:error-display');
    const component = Factory.create();

    const actual = {
      errors:     component.get('errors'),
      showDetails: component.get('showDetails'),
    };

    assert.deepEqual(actual, expected, 'default values are correct');
  });

  test('`toggleDetails` action changes `showDetails` property', function(assert) {
    assert.expect(1);

    const Factory = this.owner.factoryFor('component:error-display');
    const component = Factory.create();

    component.send('toggleDetails');

    assert.equal(component.get('showDetails'), false);
  });
});
Example #8
0
module('integration/injection eager injections', function(hooks) {
  setupTest(hooks);
  let store;
  let Apple = Service.extend();

  hooks.beforeEach(function() {
    let { owner } = this;

    owner.register('model:foo', Model.extend());
    owner.register('service:apple', Apple);
    owner.inject('model:foo', 'apple', 'service:apple');

    store = this.owner.lookup('service:store');
  });

  test('did inject', async function(assert) {
    let foo = store.createRecord('foo');
    let apple = foo.get('apple');
    let appleService = this.owner.lookup('service:apple');

    assert.ok(apple, `'model:foo' instance should have an 'apple' property`);
    assert.ok(apple === appleService, `'model:foo.apple' should be the apple service`);
    assert.ok(apple instanceof Apple, `'model:foo'.apple should be an instance of 'service:apple'`);
  });
});
module('Unit | Helper | lcm', function(hooks) {
  setupTest(hooks);

  module('Two integers', function() {
    test('computing lcm for a larger and smaller integer', function(assert) {
      assert.equal(lcm([100, 48]), 1200);
      assert.equal(lcm([48, 100]), 1200);
      assert.equal(lcm([12, 18]), 36);
      assert.equal(lcm([100, 0]), 0);
    });
    test('computing lcm for the absolute value of two integers ', function(assert) {
      assert.equal(lcm([-100, 48]), 1200);
      assert.equal(lcm([100, -48]), 1200);
      assert.equal(lcm([-12, 18]), 36);
      assert.equal(lcm([0, -48]), 0);
    });
  });
  module('Edge-case inputs', function() {
    test('returning 0 by default', function(assert) {
      const result = lcm([]);

      assert.equal(result, 0);
    });
    test('reflecting back single-integer inputs', function(assert) {
      const result = lcm([48]);

      assert.equal(result, 0);
    });
    test('handling numeric strings', function(assert) {
      const result = lcm(['2', '4']);

      assert.equal(result, 4);
    });
  });
});
module('FixtureBuilderFactory', function(hooks) {
  setupTest(hooks);
  inlineSetup(hooks, '-json-api');

  hooks.beforeEach(function() {
    store = this.owner.lookup('service:store');
    factory = new FixtureBuilderFactory(store);
  });

  test("returns the correct fixtureBuilder for serializer type of modelName", function(assert) {
    let tests = [
      // serializer type   expected FixtureBuilder
      [DS.RESTSerializer, RESTFixtureBuilder],
      [DS.JSONSerializer, JSONFixtureBuilder],
      [ActiveModelSerializer, ActiveModelFixtureBuilder],
      [DRFSerializer, DRFFixtureBuilder],
      [DS.JSONAPISerializer, JSONAPIFixtureBuilder],
      [null, JSONAPIFixtureBuilder]
    ];

    let serializer;
    store.serializerFor = () => serializer;
    let modelName = 'application';

    for (let test of tests) {
      let [serializerType, expectedFixtureBuilder] = test;
      serializer = serializerType && (new serializerType);
      let fixtureBuilder = factory.fixtureBuilder(modelName);
      assert.ok(fixtureBuilder instanceof expectedFixtureBuilder, `${serializerType} returns ${expectedFixtureBuilder.name}`);
    }
  });
});
Example #11
0
module('Unit | Route | blog/categories/index', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:blog/categories/index');
    assert.ok(route);
  });
});
Example #12
0
module('Unit | Route | datasets/dataset/compliance', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:datasets/dataset/compliance');
    assert.ok(route);
  });
});
Example #13
0
module('Unit | Route | archive/index', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:archive/index');
    assert.ok(route);
  });
});
Example #14
0
module('Unit | Route | create-warranty', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:create-warranty');
    assert.ok(route);
  });
});
module('Unit | Route | account/employees/messages', function (hooks) {
  setupTest(hooks);

  test('it exists', function (assert) {
    let route = this.owner.lookup('route:account/employees/messages');
    assert.ok(route);
  });
});
Example #16
0
module("Unit | Route | /obcinas/obcina/index", function(hooks) {
  setupTest(hooks);

  test("it exists", function(assert) {
    let route = this.owner.lookup("route:obcinas/obcina/index");
    assert.ok(route);
  });
});
module('Unit | Route | ui-forms/booking-form', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:ui-forms/booking-form');
    assert.ok(route);
  });
});
Example #18
0
module('Unit | Route | create/options datetime', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:create/options-datetime');
    assert.ok(route);
  });
});
Example #19
0
module('<%= friendlyTestDescription %>', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:<%= moduleName %>');
    assert.ok(route);
  });
});
Example #20
0
module('Unit | Route | klubs/klub/podaj mnenje', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:klubs/klub/podaj-mnenje');
    assert.ok(route);
  });
});
Example #21
0
module('Unit | Route | Programs ', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    var route = this.owner.lookup('route:programs');
    assert.ok(route);
  });
});
Example #22
0
module('Unit | Route | work/netflix', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:work/netflix');
    assert.ok(route);
  });
});
module('Unit | Route | our-product', function (hooks) {
  setupTest(hooks);

  test('it exists', function (assert) {
    let route = this.owner.lookup('route:our-product');
    assert.ok(route);
  });
});
Example #24
0
module('Unit | Service | clipboard', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let service = this.owner.lookup('service:clipboard');
    assert.ok(service);
  });
});
Example #25
0
module('Unit | Component | x foo', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let component = this.owner.factoryFor('component:x-foo').create();
    assert.ok(component);
  });
});
Example #26
0
module('Unit | Route | customers', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:customers');
    assert.ok(route);
  });
});
module('Unit | Route | submarine-cable', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:submarine-cable');
    assert.ok(route);
  });
});
Example #28
0
module('Unit | Route | poll/evaluation', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:poll/evaluation');
    assert.ok(route);
  });
});
module('Unit | Route | course visualize objectives', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:course-visualize-objectives');
    assert.ok(route);
  });
});
module('Unit | Route | authenticated/my-treads', function(hooks) {
  setupTest(hooks);

  test('it exists', function(assert) {
    let route = this.owner.lookup('route:authenticated/my-treads');
    assert.ok(route);
  });
});