Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo/bar-baz', 'helper:foo/bar-baz', {
integration: true
});
// Replace this with your real tests.
test('it renders', function(assert) {
this.set('inputValue', '1234');
this.render(hbs`{{foo/bar-baz inputValue}}`);
assert.equal(this.$().text().trim(), '1234');
});
'contentList should not be filtered when searchFilter is cleared'
);
Ember.run(function() {
component.set('searchFilter', 'itm');
});
// When search is set to normal (not advanced), searching for 'itm' should
// give 0 results
assert.equal(
component.get('contentList.length'), 0,
'contentList should be filtered to no results for "itm"'
);
});
test('Advanced Search (multiple)', function(assert) {
assert.expect(2);
var component = this.subject({
multiple: true,
liveSearch: 'advanced',
content: contentArray,
selection: Ember.A(),
optionValuePath: 'content.id',
optionLabelPath: 'content.name'
});
assert.equal(
component.get('contentList.length'), contentArray.length,
'contentList should not be filtered initially'
);
// render the component
this.render(hbs`
{{ x-foo value=value action="result" }}
`);
this.render('{{ x-foo value=value action="result" }}');
this.render([
'{{ x-foo value=value action="result" }}'
]);
assert.equal(this.$('div>.value').text(), 'cat', 'The component shows the correct value');
this.$('button').click();
});
test('it renders', function(assert) {
assert.expect(1);
// creates the component instance
const subject = this.subject();
const subject2 = this.subject({
item: 42
});
const { inputFormat } = this.setProperties({
inputFormat: 'M/D/YY',
outputFormat: 'MMMM D, YYYY',
date: '5/3/10'
});
const { inputFormat: if2, outputFormat } = this.getProperties('inputFormat', 'outputFormat');
blur,
triggerEvent,
keyEvent,
scrollTo,
selectFiles,
waitFor,
waitUntil,
} from 'ember-native-dom-helpers';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await click('.foo', {});
assert.equal(find('.foo').id, 'foo');
await fillIn('.foo input', 'bar');
await blur('.foo input');
assert.equal(find('.foo').textContent.trim(), 'foo');
});
test('it renders again', function(assert) {
this.render(hbs`{{foo-bar}}`);
let selector = '.foo input';
assert.equal(findAll(selector).length, 1);
assert.equal(find(selector).value, 'foo');
assert.ok(find('.foo').classList.contains('selected'));
beforeEach() {
this.register('service:routing', routingStub);
this.inject.service('routing', { as: 'routing' });
this.register('service:l10n', L10n);
this.inject.service('l10n', { as: 'l10n' });
this.application = startApp();
l10nTestHelper(this);
},
afterEach() {
destroyApp(this.application);
}
});
if (testCase) {
test('it renders', testCase);
}
}
}
});
test('serverTokenEndpoint', assert => {
assert.equal(Configuration.serverTokenEndpoint, '/api/token-auth/', 'defaults to "/api/token-auth/"');
});
test('identificationField', assert => {
assert.equal(Configuration.identificationField, 'username', 'defaults to "username"');
});
test('tokenPropertyName', assert => {
assert.equal(Configuration.tokenPropertyName, 'token', 'defaults to "token"');
});
test('authorizationPrefix', assert => {
assert.equal(Configuration.authorizationPrefix, 'Bearer ', 'defaults to "Bearer "');
});
test('authorizationHeaderName', assert => {
assert.equal(Configuration.authorizationHeaderName, 'Authorization', 'defaults to "Authorization"');
});
test('serverTokenRefreshEndpoint', assert => {
assert.equal(Configuration.serverTokenRefreshEndpoint, '/api/token-refresh/', 'defaults to "/api/token-refresh/"');
});
test('refreshAccessTokens', assert => {
assert.equal(Configuration.refreshAccessTokens, true, 'defaults to true');
});
test('refreshLeeway', assert => {
assert.equal(cat.get('friend'), 'Friend 1');
});
test("with model that has primaryKey defined in serializer ( FactoryGuy sets id value )", function(assert) {
let cat = make('cat');
assert.equal(cat.get('id'), 1);
});
test("with model that has primaryKey defined in serializer ( user sets id value )", function(assert) {
let cat = make('cat', {catId: 'meow1'});
assert.equal(cat.get('id'), 'meow1');
});
test("with model that has primaryKey defined in serializer and is attribute ( value set in fixture )", function(assert) {
let dog = make('dog');
assert.equal(dog.get('id'), 'Dog1', 'primary key comes from dogNumber');
assert.equal(dog.get('dogNumber'), 'Dog1', 'attribute has the primary key value as well');
});
test("with fixture options", function(assert) {
let profile = make('profile', {description: 'dude'});
assert.ok(profile.get('description') === 'dude');
});
test("with attributes in traits", function(assert) {
let profile = make('profile', 'goofy_description');
assert.ok(profile.get('description') === 'goofy');
});
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import ANY_SELECTOR_AS_IMPORTED_CONST from './constants';
const JQEXTENSION_SELECTOR_AS_LOCAL_CONST = '.foo:first';
const NORMAL_SELECTOR = '.foo';
const NORMAL_PSEUDO_SELECTOR = '.foo:eq(0)';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});
test('it renders', function(assert) {
this.render(hbs`{{foo-bar}}`);
assert.ok(this.$('.foo:even').length);
assert.ok(this.$('.foo:odd').length);
assert.ok(this.$('.foo:contains(foo)').length);
assert.ok(this.$('.foo:has(p)').length);
assert.ok(this.$('.foo:animated').length);
assert.ok(this.$('.foo:checkbox').length);
assert.ok(this.$('.foo:file').length);
assert.ok(this.$('.foo:first').length);
assert.ok(this.$('.foo:gt(2)').length);
assert.ok(this.$('.foo:header').length);
assert.ok(this.$('.foo:hidden').length);
assert.ok(this.$('.foo:image').length);
assert.ok(this.$('.foo:input').length);
assert.ok(this.$('.foo:last').length);
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});
test('it renders', function(assert) {
this.render(hbs`{{foo-bar}}`);
this.$('.foo').click();
this.$('.baz a:eq(0)').click();
this.$('.foo .bar:eq(3)').click();
assert.ok(true);
});
trackEvent(...args) {
this.set('props', [...args]);
}
});
moduleFor('mixin:analytics', {
subject(){
this.register('service:metrics', service);
this.inject.service('metrics');
const analyticsObject = Ember.Controller.extend(AnalyticsMixin);
this.registry.register('test:subject', analyticsObject);
return getOwner(this).lookup('test:subject');
}
});
test("Google Analytics mixin", function(assert) {
const subject = this.subject();
assert.ok(AnalyticsMixin.detect(subject));
Ember.run(() => {
subject.send('click', 'test category', 'test label');
assert.ok(subject.get('metrics.props'));
subject.send('track', 'test category', 'test label');
assert.ok(subject.get('metrics.props'));
});
});