Skip to content

Instantly share code, notes, and snippets.

@ahmetemrekilinc
Last active April 1, 2019 18:47
Show Gist options
  • Save ahmetemrekilinc/e3990522af32525bbb28fe6f1b8d49f6 to your computer and use it in GitHub Desktop.
Save ahmetemrekilinc/e3990522af32525bbb28fe6f1b8d49f6 to your computer and use it in GitHub Desktop.
ember-pikaday-test-null
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
onSelection(val){
this.get('onSelection')(val);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
onSelection(val){
console.log('selection is changed: ' + val);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{my-component}}
<br>
<br>
{{pikaday-input onSelection=(action 'onSelection') }}
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import moment from 'moment';
moduleForComponent('my-component', 'TODO: put something here', {
integration: true
});
function updateDateValue(_this, val){
let datecomponent = _this.$('input');
datecomponent.click();
datecomponent.val(val);
datecomponent[0].dispatchEvent(new Event('change'));
}
test('it renders', function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
let actionListenerValue;
this.on('myaction', function(val) { actionListenerValue=val; });
// Template block usage:
this.render(hbs`{{my-component onSelection=(action 'myaction') }}`);
updateDateValue(this, '01.04.2016');
assert.equal(this.$('input').val(), '01.04.2016');
assert.equal(moment(actionListenerValue).format('DD.MM.YYYY'), '01.04.2016');
updateDateValue(this, '05.02.2016');
assert.equal(this.$('input').val(), '05.02.2016');
assert.equal(moment(actionListenerValue).format('DD.MM.YYYY'), '05.02.2016');
updateDateValue(this, null);
assert.notOk(this.$('input').val());
assert.notOk(actionListenerValue);
});
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-pikaday": "2.2.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment