Esempio n. 1
0
QUnit.test('Deleting a stat does not change playback location', function () {

    var gotoCalled = false;
    var frag = stache('<game-details {game-id}="gameId" {session}="session" />')({
        gameId: this.vm.attr('gameId'),
        session: new Session({
            isAdmin: true
        })
    });

    $('#qunit-fixture').html(frag);

    QUnit.stop();

    var vm = $('game-details').viewModel();

    vm.gotoTimeMinus5 = function () {
        gotoCalled = true;
    };

    vm.bind('game', function(ev, game) {
        QUnit.start();

        F('.stat-point .destroy-btn')
            .exists('Destroy button exists')
            .click()
            .then(function () {
                notOk(gotoCalled, 'Seek was not called');
            });
    });
});
Esempio n. 2
0
QUnit.test('A stat can be deleted by an admin', function () {

    var session = new Session({
        isAdmin: false
    });

    var frag = stache('<game-details {game-id}="gameId" {session}="session" />')({
        gameId: this.vm.attr('gameId'),
        session: session
    });

    $('#qunit-fixture').html(frag);

    F('.stat-point .destroy-btn')
        .size(0, 'There is no destroy button')
        .then(function () {
            session.attr('isAdmin', true);
            ok(true, 'The user is given admin privileges');
        })
        .size(6, 'Destroy buttons are inserted')
        .click()
        .size(5, 'Clicking the destroy button removed a stat');
});
Esempio n. 3
0
import stache from 'can/view/stache/';
import 'sam/learner/';
const learner = stache('<sam-learner transcript="{recognition.transcript}"></sam-learner>');

const actions = {
  learn(el, result, state) {
    state.attr('listening', false);
    el.html(learner(state));
  },

  weather(el, result) {
    let index = result.pos.indexOf('IN');
    let location = null;

    if(index !== -1 && result.tags[index + 1]) {
      location = result.tags[index + 1];
    }

    const loadWeather = (location, woeid) => {
      $.simpleWeather({
        location: location,
        woeid: woeid,
        unit: 'c',
        success: function(weather) {
          let html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'&deg;'+weather.units.temp+'</h2>';
          html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
          html += '<li class="currently">'+weather.currently+'</li>';
          html += '<li>'+weather.alt.temp+'&deg;C</li></ul>';

          el.html(html);
        },
Esempio n. 4
0
var can = require("can");
var stache = require("can/view/stache/");
var renderer = require("worker-render/worker");

var template = stache("<a href='javascript://' can-click='toggle'>Click to toggle</a>" +
	"{{#state}}<div can-click='log'>we have state</div>{{/state}}");

var State = can.Map.extend({
	state: false,
	toggle: function(viewModel, el, event){
		this.attr("state", !this.attr("state"));
	},
	log: function(){
		console.log("this is bound");
	}
});

var state = new State();

renderer.ready(function(){
	var frag = template(state);
	document.body.appendChild(frag);
});