sightglass-overlay.spec.js
2.98 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
define(function(require) {
'use strict';
var $ = require('jquery');
window.jQuery = $;
var SightglassOverlay = require('sightglass-overlay');
require('rivets-backbone-adapter-brainfood');
var _ = require('underscore');
var Backbone = require('backbone');
var rivets = require('rivets');
//rivets.config.rootInterface = ':';
/* global console:false */
describe('SightglassOverlay', function() {
var rootScope, rootNode;
beforeEach(function() {
rootScope = new Backbone.Model({
sub: new Backbone.Model({
subKey: 'sub-key',
list: new Backbone.Collection([
{key: 'A'},
{key: 'B'},
{key: 'C'},
], {parse: true}),
}),
list: new Backbone.Collection([
{key: 'A'},
{key: 'B'},
{key: 'C'},
], {parse: true}),
constant: 'this-is-a-constant',
});
rootNode = $($.parseHTML('<div>{:constant}<div rv-bfeach-item=":list">key:{:item:key} constant:{:constant}<ul><li rv-bfeach-subitem=":sub:list">sub-key:{:subitem:key} constant:{:constant}<input rv-value=":inputValue" /></li></ul></div></div>'));
});
it('returns defined', function() {
expect(SightglassOverlay).toBeDefined();
});
describe('makeOverrideAdapters', function() {
var newAdapters, roData, rivetsView;
beforeEach(function() {
roData = {};
roData[':sub:list'] = new Backbone.Collection([
{key: 'sub1'},
{key: 'sub2'},
{key: 'sub3'},
], {parse: true});
roData[':list'] = new Backbone.Collection([
{key: '1'},
{key: '2'},
{key: '3'},
], {parse: true});
newAdapters = SightglassOverlay.makeOverrideAdapters(rivets.adapters, roData);
rivetsView = rivets.bind(rootNode, rootScope, {adapters: newAdapters});
});
xit('test', function() {
var subListHtml = '<ul><!-- rivets: bfeach-subitem --><li>sub-key:sub1 constant:this-is-a-constant<input rv-value=":inputValue"></li><li>sub-key:sub2 constant:this-is-a-constant<input rv-value=":inputValue"></li><li>sub-key:sub3 constant:this-is-a-constant<input rv-value=":inputValue"></li></ul>';
expect(rootNode.html()).toEqual(
'this-is-a-constant' +
'<!-- rivets: bfeach-item -->' +
'<div>key:1 constant:this-is-a-constant' + subListHtml + '</div>' +
'<div>key:2 constant:this-is-a-constant' + subListHtml + '</div>' +
'<div>key:3 constant:this-is-a-constant' + subListHtml + '</div>'
);
});
});
});
});