środa, 27 sierpnia 2014

Playing with ember-leaflet and circle marker

Here are results of playing with ember-leaflet and awesome-markers. This is how you can use ember-leaflet to mark area on a map:


You can also add another layer with custom markers(awesome-markers):



To install this with ember-cli you need to:

//bower install --save ember-cli-leaflet
//bower install --save ember-cli-ember-leaflet
//bower install --save fontawesome
//bower install --save Leaflet.awesome-markers
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var mergeTrees = require('broccoli-merge-trees');
var pickFiles = require('broccoli-static-compiler');
var fontTree = pickFiles('vendor/fontawesome/fonts', {
srcDir: '/',
files: ['fontawesome-webfont.eot','fontawesome-webfont.ttf','fontawesome-webfont.svg','fontawesome-webfont.woff'],
destDir: '/fonts'
});
var leafletMarkers = pickFiles('vendor/Leaflet.awesome-markers/dist/images', {
srcDir: '/',
files: ['*'],
destDir: '/assets/images'
});
var app = new EmberApp();
app.import('vendor/Leaflet.awesome-markers/dist/leaflet.awesome-markers.js', {
exports: {
'leaflet.awesome-markers': 'default'
}
});
app.import('vendor/Leaflet.awesome-markers/dist/leaflet.awesome-markers.css');
//app.import('vendor/leaflet-plugins/layer/tile/Google.js');
module.exports = mergeTrees([app.toTree(), fontTree, leafletMarkers]);
view raw Brocfile.js hosted with ❤ by GitHub

wtorek, 19 sierpnia 2014

Ember.js testing focusOut

Quick note how to test focusOut in integration tests in ember.
I was writing signup form using easyForm with client side validations. Note that validations return a promise so we have async call. The feature was about displaying error when I leave field.
First I wrote this and it worked on local machine. But then on CI I started getting errors after running this again it occurs that it fails sometimes.

test 'Signup form', ->
click('input[name="businessName"]')
fillIn('input[name="businessName"]', "Some name")
click('input[name="contactName"]')
andThen ->
ok(find("div.businessName span.help-block.error").is(':visible'), "Should see error message on previous field")
The solution was to invoke the blur even on element instead of going to another field.  Click helper is a async helper(http://emberjs.com/guides/testing/test-helpers/#toc_asynchronous-helpers) but it's probably waiting only for click event, not the corresponding ones.
Ember.Test.registerAsyncHelper 'leaveBusinessName',
(app, name, context) ->
triggerEvent('input[name="businessName"]', 'blur')
test 'Signup form', ->
click('input[name="businessName"]')
fillIn('input[name="businessName"]', "Some name")
leaveBusinessName()
andThen ->
ok(find("div.businessName span.help-block.error").is(':visible'), "Should see error message on previous field")