-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpug_loader.coffee
34 lines (34 loc) · 1.04 KB
/
pug_loader.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
load_template = (template_name, callback)->
$.get
url: '/base/test/'+template_name+'.html',
dataType: 'text'
success: callback
parse_assert = (input)->
$.map input.split(':'), (i)->
[
$.map i.split(','), (s)->
parseFloat(s)
]
describe "Pug", ->
run_test_from_template = (template_name, callback)->
load_template template_name, (template)->
$context = $('<div style="position: fixed; top: 0; left: 0">'+template+'</div>')
$('body').append($context)
$('.referentiel', $context).each ->
referentiel = new Referentiel(this)
$('[data-assert]', this).each (assert)->
[global, local] = parse_assert $(this).data('assert')
result = referentiel.global_to_local(global)
expect(result).toEqual(local)
callback()
add_test = (template_name)->
it template_name, (done)->
run_test_from_template template_name, done
for template_name in [
'svg-1',
'svg-2',
'svg-3',
'position-basique',
'position-scoped',
]
add_test(template_name)