Example #1
0
 run(function() {
   view.set('template', compile("{{#with first as |ring|}}{{ring}}-{{#with fifth as |ring|}}{{ring}}-{{#with ninth as |ring|}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}{{/with}}"));
   view.set('context', {
     first: 'Limbo',
     fifth: 'Wrath',
     ninth: 'Treachery'
   });
 });
Example #2
0
  setup: function() {
    Ember.lookup = lookup = { Ember: Ember };

    lookup.Foo = { bar: 'baz' };
    view = EmberView.create({
      template: compile("{{#with Foo.bar as qux}}{{qux}}{{/with}}")
    });
  },
Example #3
0
  run(function() {
    app = Application.create({
      rootElement: '#qunit-fixture'
    });

    app.Router.reopen({
      location: 'none'
    });

    app.register('template:application',
      compile("{{outlet}}")
    );

    Ember.TEMPLATES.index = compile(
      "<h1>Hi from index</h1>"
    );
  });
Example #4
0
test("should keep class in the order it appears in", function() {
  view = EmberView.create({
    template: compile('<span {{bind-attr class=":foo :baz"}}></span>'),
  });

  runAppend(view);

  equal(view.element.firstChild.className, 'foo baz', 'classes are in expected order');
});
Example #5
0
  test("path is output", function() {
    view = EmberView.create({
      context: {name: {firstName: 'erik'}},
      template: compile("ohai {{name.firstName}}")
    });
    appendView(view);

    equalInnerHTML(view.element, 'ohai erik', "path is output");
  });
Example #6
0
test("should output a data attribute with a guid", function() {
  view = EmberView.create({
    template: compile('<a href="#" {{action "edit"}}>edit</a>')
  });

  runAppend(view);

  ok(view.$('a').attr('data-ember-action').match(/\d+/), "A data-ember-action attribute with a guid was added");
});
Example #7
0
test("should render an instance of the specified view", function() {
  var OceanView = EmberView.extend({
    template: compile('zomg, nice view')
  });

  helper('oceanView', OceanView);

  view = EmberView.create({
    controller: EmberObject.create(),
    template: compile('{{oceanView tagName="strong"}}')
  });

  runAppend(view);

  var oceanViews = view.$().find("strong:contains('zomg, nice view')");

  equal(oceanViews.length, 1, "helper rendered an instance of the view");
});
Example #8
0
test("asserts if component is not found", function() {
  view = EmberView.create({
    container: container,
    template: compile("<foo-bar />")
  });

  expectAssertion(function() {
    appendView(view);
  }, 'You specified `foo-bar` in your template, but a component for `foo-bar` could not be found.');
});
Example #9
0
  expectAssertion(function () {

    view = EmberView.create({
      template: compile(template),
      container : container
    });

    runAppend(view);

  });
Example #10
0
test("quoted viewBox property is output", function() {
  var viewBoxString = '0 0 100 100';
  view = EmberView.create({
    context: {viewBoxString: viewBoxString},
    template: compile("<svg viewBox='{{viewBoxString}}'></svg>")
  });
  appendView(view);

  equalInnerHTML(view.element, '<svg viewBox="'+viewBoxString+'"></svg>', "attribute is output");
});
Example #11
0
test("href is set", function() {
  view = EmberView.create({
    context: {url: 'http://example.com'},
    template: compile("<a href={{url}}></a>")
  });
  appendView(view);

  equalInnerHTML(view.element, '<a href="http://example.com"></a>',
                 "attribute is output");
});
Example #12
0
  test("`if` helper with inline form: can omit the falsy argument and renders nothing when conditional is falsy", function() {
    view = EmberView.create({
      conditional: false,
      template: compile('{{if view.conditional "truthy"}}')
    });

    runAppend(view);

    equal(view.$().text(), '');
  });
Example #13
0
  test("`if` helper with inline form: raises when using less than two arguments", function() {
    view = EmberView.create({
      conditional: true,
      template: compile('{{if one}}')
    });

    expectAssertion(function() {
      runAppend(view);
    }, 'If helper in inline form expects between two and three arguments');
  });
Example #14
0
  setup: function() {
    controller = {};

    view = View.extend({
      controller: controller,
      template: compile('{{input type="text" disabled=true value="hello" placeholder="Enter some text" name="some-name" maxlength=30 size=30 tabindex=5}}')
    }).create();

    runAppend(view);
  },
Example #15
0
test("The `unless` helper does not error on undefined", function() {
  view = EmberView.create({
    undefinedValue: undefined,
    template: compile('{{#unless view.undefinedValue}}Yep{{/unless}}{{#unbound unless view.undefinedValue}}Yep{{/unbound}}')
  });

  runAppend(view);

  equal(view.$().text(), 'YepYep');
});
Example #16
0
test("should be able to be inserted in DOM when the router is not present", function() {
  var template = "{{#link-to 'index'}}Go to Index{{/link-to}}";
  view = EmberView.create({
    template: compile(template)
  });

  runAppend(view);

  equal(view.$().text(), 'Go to Index');
});
Example #17
0
  test("`if` helper with inline form: renders the third argument when conditional is falsy", function() {
    view = EmberView.create({
      conditional: false,
      template: compile('{{if view.conditional "truthy" "falsy"}}')
    });

    runAppend(view);

    equal(view.$().text(), 'falsy');
  });
Example #18
0
  setup: function() {
    controller = {};

    view = View.extend({
      controller: controller,
      template: compile('{{input}}')
    }).create();

    runAppend(view);
  },
Example #19
0
test("it should wrap context with object controller [DEPRECATED]", function() {
  var Controller = ObjectController.extend({
    controllerName: computed(function() {
      return "controller:"+this.get('model.name') + ' and ' + this.get('parentController.name');
    })
  });

  var person = EmberObject.create({name: 'Steve Holt'});
  var registry = new Registry();
  var container = registry.container();

  var parentController = EmberObject.create({
    container: container,
    name: 'Bob Loblaw'
  });

  view = EmberView.create({
    container: container,
    template: compile('{{#with view.person controller="person"}}{{controllerName}}{{/with}}'),
    person: person,
    controller: parentController
  });

  registry.register('controller:person', Controller);

  expectDeprecation(function(){
    runAppend(view);
  }, 'Using the context switching form of `{{with}}` is deprecated. Please use the keyword form (`{{with foo as bar}}`) instead. See http://emberjs.com/guides/deprecations/#toc_more-consistent-handlebars-scope for more details.');

  equal(view.$().text(), "controller:Steve Holt and Bob Loblaw");

  run(function() {
    view.rerender();
  });

  equal(view.$().text(), "controller:Steve Holt and Bob Loblaw");

  run(function() {
    parentController.set('name', 'Carl Weathers');
    view.rerender();
  });

  equal(view.$().text(), "controller:Steve Holt and Carl Weathers");

  run(function() {
    person.set('name', 'Gob');
    view.rerender();
  });

  equal(view.$().text(), "controller:Gob and Carl Weathers");

  strictEqual(view.get('_childViews')[0].get('controller.target'), parentController, "the target property of the child controllers are set correctly");

  runDestroy(view);
});
Example #20
0
  test("`if` helper with inline form: works when used in a sub expression", function() {
    view = EmberView.create({
      conditional: true,
      innerConditional: true,
      template: compile('{{if view.conditional (if view.innerConditional "truthy" )}}')
    });

    runAppend(view);

    equal(view.$().text(), 'truthy');
  });
Example #21
0
test("class attribute concats bound values", function() {
  view = EmberView.create({
    context: {size: 'large', color: 'blue'},
    template: compile("<div class='{{size}} {{color}} round'></div>")
  });
  appendView(view);

  ok(view.$('.large')[0], 'first class found');
  ok(view.$('.blue')[0], 'second class found');
  ok(view.$('.round')[0], 'third class found');
});
Example #22
0
test("does not escape title in non-block form when `unescaped` is true", function() {
  view = EmberView.create({
    title: "<b>blah</b>",

    template: compile("{{link-to view.title unescaped=true}}")
  });

  runAppend(view);

  equal(view.$('b').length, 1, '<b> was found');
});
Example #23
0
test("escapes title in non-block form", function() {
  view = EmberView.create({
    title: "<b>blah</b>",

    template: compile("{{link-to view.title}}")
  });

  runAppend(view);

  equal(view.$('b').length, 0, 'no <b> were found');
});
Example #24
0
test("The `unbound if` helper does not update when the value changes", function() {
  view = EmberView.create({
    conditional: false,
    template: compile('{{#unbound unless view.conditional}}Nope{{/unbound}}')
  });
  runAppend(view);
  equal(view.$().text(), 'Nope');
  run(function(){
    view.set('conditional', true);
  });
  equal(view.$().text(), 'Nope');
});
Example #25
0
test("The `if` helper updates when the value changes", function() {
  view = EmberView.create({
    conditional: true,
    template: compile('{{#if view.conditional}}Yep{{/if}}')
  });
  runAppend(view);
  equal(view.$().text(), 'Yep');
  run(function(){
    view.set('conditional', false);
  });
  equal(view.$().text(), '');
});
Example #26
0
test("The `if` helper does not print the contents for an object proxy without content", function() {
  view = EmberView.create({
    truthy: ObjectProxy.create({ content: {} }),
    falsy: ObjectProxy.create({ content: null }),

    template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}')
  });

  runAppend(view);

  equal(view.$().text(), 'Yep');
});
Example #27
0
test("class property can contain multiple classes", function() {
  view = EmberView.create({
    context: {classes: 'large blue'},
    template: compile("<div class={{classes}}></div>")
  });
  appendView(view);

  equalInnerHTML(view.element, '<div class="large blue"></div>',
                 "attribute is output");
  ok(view.$('.large')[0], 'first class found');
  ok(view.$('.blue')[0], 'second class found');
});
Example #28
0
test("The `if` helper tests for `isTruthy` if available", function() {
  view = EmberView.create({
    truthy: EmberObject.create({ isTruthy: true }),
    falsy: EmberObject.create({ isTruthy: false }),

    template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}')
  });

  runAppend(view);

  equal(view.$().text(), 'Yep');
});
Example #29
0
  setup: function() {
    controller = {
      someProperty: 'password'
    };

    view = View.extend({
      controller: controller,
      template: compile('{{input type=someProperty}}')
    }).create();

    runAppend(view);
  },
test("bound helpers should not be invoked with blocks", function() {
  registerRepeatHelper();
  view = EmberView.create({
    container: container,
    controller: {},
    template: compile("{{#x-repeat}}Sorry, Charlie{{/x-repeat}}")
  });

  expectAssertion(function() {
    runAppend(view);
  }, /makeBoundHelper generated helpers do not support use with blocks/i);
});