1
YUI().use('lp.testing.runner', 'test', 'console', 'node', 'lazr.picker',
2
'lp.answers.subscribers',
3
'event', 'node-event-simulate', 'dump', function(Y) {
5
var suite = new Y.Test.Suite("lp.answers.subscribers Tests");
6
var module = Y.lp.answers.subscribers;
9
suite.add(new Y.Test.Case({
10
name: 'QuestionSubscribersList constructor test',
13
this.root = Y.Node.create('<div />');
14
Y.one('body').appendChild(this.root);
17
tearDown: function() {
21
setUpLoader: function() {
22
this.root.appendChild(
23
Y.Node.create('<div />').addClass('container'));
24
var question = { web_link: '/base', self_link: '/question/1'};
25
return new module.createQuestionSubscribersLoader({
26
container_box: '.container',
28
subscribers_details_view: '/+portlet-subscribers-details'});
31
test_subscribers_list_instantiation: function() {
35
test_addSubscriber: function() {
36
// Check that the subscription list has been created with the expected
37
// subscription levels for questions. This can be done by adding a
38
// subscriber to one of the expected levels and checking the results.
39
var loader = this.setUpLoader(this.root);
40
var node = loader.subscribers_list.addSubscriber(
41
{ name: 'user' }, 'Direct');
43
// Node is constructed using _createSubscriberNode.
44
Y.Assert.isTrue(node.hasClass('subscriber'));
45
// And the ID is set inside addSubscriber() method.
46
Y.Assert.areEqual('subscriber-user', node.get('id'));
48
// And it nested in the subscribers-list of a 'Direct' section.
49
var list_node = node.ancestor('.subscribers-list');
50
Y.Assert.isNotNull(list_node);
51
var section_node = list_node.ancestor(
52
'.subscribers-section-direct');
53
Y.Assert.isNotNull(section_node);
57
Y.lp.testing.Runner.run(suite);