Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 12 19:26
    cherifGsoul review_requested #5443
  • Dec 12 18:34
    cherifGsoul synchronize #5443
  • Dec 12 18:34

    cherifGsoul on document-inserted-removed-can6

    Update after review (compare)

  • Dec 12 17:44

    cherifGsoul on theme-3.0.0-pre.5

    (compare)

  • Dec 12 17:44

    cherifGsoul on master

    Update bit-doc-html-canjs (#544… (compare)

  • Dec 12 17:44
    cherifGsoul closed #5445
  • Dec 12 17:01
    cherifGsoul opened #5445
  • Dec 12 17:01

    cherifGsoul on theme-3.0.0-pre.5

    Update bit-doc-html-canjs Upda… (compare)

  • Dec 12 16:40

    cherifGsoul on update-api-page

    (compare)

  • Dec 12 16:39

    cherifGsoul on master

    Update API page (#5432) * Upda… (compare)

  • Dec 12 16:39
    cherifGsoul closed #5432
  • Dec 12 16:39
    cherifGsoul closed #5304
  • Dec 12 01:04
    greenkeeper[bot] commented #5392
  • Dec 12 01:04

    greenkeeper[bot] on core-js-3.5.0

    chore(package): update core-js … (compare)

  • Dec 11 18:34
    greenkeeper[bot] labeled #5444
  • Dec 11 18:34
    greenkeeper[bot] opened #5444
  • Dec 11 18:34

    greenkeeper[bot] on can-observable-mixin-1.0.7

    fix(package): update can-observ… (compare)

  • Dec 11 18:30

    cherifGsoul on update-infrastructure-page

    (compare)

  • Dec 11 18:30

    cherifGsoul on master

    Update infrastructure page with… (compare)

  • Dec 11 18:30
    cherifGsoul closed #5441
Luis Merino
@Rendez
Any advice you can give me to make testing easier?
Of course I could compose my own templates for each test so that I leave out other child components, but that would defeat the purpose because it would not be very maintenable and prone to errors (templates may differ from tests at some point)
Gerard Finnerty
@halcyonandon
I used a lot of components within components. What problem are you having with testing them specifically? Every component would have a corresponding test suite... If you're writing modules, you're loading all subcomponents from the parent anyways. If your test is on the parent, there's no reason to test the functionality of the child components, even if they're included... components should be self-contained, so anything a child receives from a parent should be passed as arguments in the child's tag anyways...

describe('Some component', function( ) {

var $component;

beforeEach(function( done ) {
  System.import('shared/services/account/fixture').then(function( ) {
    Promise.all([
      System.import('can/util/can'),
      System.import('shared/components/forms/someComponent/someComponent'),
      System.import('can/view/stache')
    ]).then(function (values){
      var can  = values[0];

      var template = can.stache('<some-component/>');
      $('body').append(template());
      $component = $('some-component');

      done();
    });
  });
});

it('should have a scope', function() {
  expect($component.scope()).toBeDefined();
});

afterEach(function() {
  $component.remove();
});

});

That's a basic test setup of a component that checks for the scope, that's what I use in my yeoman generator for the component.test.js when generating a new component
I don't use funcunit though
Luis Merino
@Rendez
Yeah, I understand what you're saying and I've written my tests accordingly, the problem is that the template in this case is <some-component> with ALL the other subcomponents inside, it's like the master HTML template. So when I append it to the fixture container a lot of unwanted initialization happens in all these subcomponents. I could just write a custom template for the test, but then my test's template and the real template I use for the app could diff at some point.
This is more of a philosophcal debate rather, I know how I can sort this out logically, but I wanted to know more about your take on this
@halcyonandon
Theoretically I have a few options:
  • Remove from the view subcomponent tags before I append them to the body (still dirty, still problematic if init: function is present in any subcomponent).
  • Stub component's prototype (if that's easy to do)
  • Use component's 'inserted' event to add another subcomponent (instead of using a template directly), which would allow me to stub the view's function avoiding this (given I precompile my templates in a JST object)
  • ...
Luis Merino
@Rendez
I guess I'm writing templates in tests for these cases, that contain only the component I want to test, I don't see which other "elegant" way is there to accomplish it
Vojtech Prikryl
@Aldredcz
Hello guys, anyone got experience with ES6 module syntax + StealJS + Babel? Or it works with traceur only?
Matthew Phillips
@matthewp
@Aldredcz StealJS 0.6.0 (current version) only works with Traceur
However 0.7.0 is coming out in a couple of days with Babel support
You can try it out by using 0.7.0-pre.5
in your config
System.config({ transpiler: "babel" })
^^ @Aldredcz
Vojtech Prikryl
@Aldredcz
btw. StealJs doesn't support gulp?
Vojtech Prikryl
@Aldredcz
@matthewp
Marshall Thompson
@marshallswain
@Aldredcz It's Gulp, so you can just use code. Here's an example gulpfile.js. Just change the path names to fit what you want.
var gulp = require('gulp'),
  compilerGulp = require('can-compile/gulp.js'),
  stealTools = require('steal-tools');

// Steal Build / Watch the App
gulp.task('steal-build', function() {
  stealTools.build({
    main: 'main',
    bundlesPath: '../assets',
    config: 'public/main/stealconfig.js'
  });
});
gulp.watch('public/main/**/*.*', ['steal-build']);

// Build / Watch CanJS TEMPLATES
var options = {
  src: ['public/**/*.stache'],
  out: 'public/assets/main.stache.js',
  version: '2.1.3'
};
compilerGulp.task('main-views', options, gulp);
compilerGulp.watch('main-views', options, gulp);


// The default task (called when you run `gulp` from cli)
gulp.task('default', [
  'steal-build',
  'main-views',
  'main-views-watch',
]);
Vojtech Prikryl
@Aldredcz
@matthewp thanks
wrong highlight, i meant thanks @marshallswain
Marshall Thompson
@marshallswain
You're welcome. The watch mode works quite well this way, but it will be built into Steal in the not-too-distant future.
*from what I've read.
Matthew Phillips
@matthewp
Yep, next is full source maps
Watch mode will be after that
And we're going to have even better gulp support in the future as well
@marshallswain not using Steal for views?
Matthew Phillips
@matthewp
Maybe you're using Can 2.1 @marshallswain ?
Vojtech Prikryl
@Aldredcz
Hello, I have a Component with helper being live-bound to scope attributes, and event catching same attributes and modifying them (before this modification, the scope state is in invalid state)... but the helper got resolved before the event,.. can I somehow prioritize the event callback, so the helper work with valid state?
Matthew Phillips
@matthewp
hm, not sure i understand what you mean
Vojtech Prikryl
@Aldredcz
inputType: function (subRule, options) {
                subRule = (typeof subRule === 'function') ? subRule() : subRule;

                var disabled = !subRule.attr('operator') || !subRule.attr('subject'),
                    multiple = disabled ? false : this.operatorsHash[subRule.attr('operator')].usage === 'STRING_LIST',
                    type;

                if (!this.predefinedValuesHash[subRule.attr('subject')] && multiple) {
                    type = 'tags';
                }
                else if (this.predefinedValuesHash[subRule.attr('subject')]) {
                    type = 'select';
                }
                else {
                    type = 'input';
                }

                return options.fn(options.scope.add({subRule: subRule, type: type, multiple: multiple, disabled: disabled}));
            }
{{#inputType .}}
                        {{#equals type 'input'}}
                            <input type="text" class="form-control" can-value="{subRule.value}" {{#if disabled}}disabled{{/if}}>
                        {{/equals}}
                        {{#equals type 'tags'}}
                            <div>
                                <input type="hidden" class="form-control" {{data 'input'}} {{initTags}}>
                            </div>
                        {{/equals}}
                        {{#equals type 'select'}}
                            <div>
                                <input type="hidden" class="form-control" {{data 'input'}} {{initSelect}}>
                            </div>
                            {{type}}, {{#if multiple}}multiple{{else}}single{{/if}}
                        {{/equals}}
                    {{/inputType}}
then I have events listening to changes in subRule.operator and subRule.subject, according to them, it modifies other attributes of subRule. And according to that, initTags and initSelect is rendered,.. but those helpers are called before event callbacks
Vojtech Prikryl
@Aldredcz
already solved it ... had operator and subject bound by can-value on <select>, so changed it to can-change and handled all the changes in can.batch, so I'm always in valid state... but once I would need to react to changes from other controller and not from view,.. dunno how I would solve it..
Marshall Thompson
@marshallswain
@matthewp Yes, still using 2.1.4, so can-compile’ing the views for a few more days.
Vojtech Prikryl
@Aldredcz

Was just diggin in lib files, this is in view/scanner.js:

// Escapes characters starting with `\`.
        clean = function (content) {
            return content
                .split('\\')
                .join("\\\\")
                .split("\n")
                .join("\\n")
                .split('"')
                .join('\\"')
                .split("\t")
                .join("\\t");
        },

You sure that's the best way how to escape chars in terms of performance?

Matthew Phillips
@matthewp
where is that?
oh, view/scanner
probably not the best way
i wonder how often this function gets called
but you're right
PRs welcome :)
Justin Meyer
@justinbmeyer
@Aldredcz you should really switch to stache
@Aldredcz you can check ev.batchNum
var lastBatchNum
bind("EVENT", function(ev){
  if(ev.batchNum === undefined || ev.batchNum !== lastBatchNum) { 
    lastBatchNum = ev.batchNum

    DO STUFF
 }
Vojtech Prikryl
@Aldredcz
@justinbmeyer Yea, slowly migrating whole app from ejs to stache,..
about batchNum - I know it and use it a lot, but this is not the case,.. I was asking if i can control somehow order of events 'helper live bound update' and 'event live bound update' in Component
Justin Love
@JustinLove
An inner component changes the state of the server. What is a good way to tell the parent components to refresh their data?
Matthew Phillips
@matthewp
@JustinLove There's currently some work to be done to make this better