Exemplo n.º 1
0
    def test_WATCH_ko(self):
        c="""class Component:
  def WATCH_var(self):
    pass"""
        with self.assertRaises(vbuild.VBuildException): # vbuild.VBuildException: name='var_to_watch' is not specified in WATCH_var
            vbuild.mkPythonVueComponent("toto","<div></div>",c)

        c="""class Component:
  def WATCH_var(self,oldVal,newVal,name):
    pass"""
        with self.assertRaises(vbuild.VBuildException): # vbuild.VBuildException: name='var_to_watch' is not specified in WATCH_var
            vbuild.mkPythonVueComponent("toto","<div></div>",c)
Exemplo n.º 2
0
 def test_1(self):
     c="class Component: pass"
     js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
     self.assertTrue("_pyfunc_op_instantiate" in js)
     self.assertTrue("Vue.component('toto',{" in js)
     self.assertTrue('name: "toto",' in js)
     self.assertTrue("template: '<div></div>'," in js)
Exemplo n.º 3
0
   def test_WATCH(self):
       c="""class Component:
 def WATCH_var(self,oldVal,newVal,name="$store.state.yo"):
   pass"""
       js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
       self.assertTrue("_pyfunc_op_instantiate" in js)
       self.assertTrue("Vue.component(" in js)
       self.assertTrue('"$store.state.yo": C.prototype.WATCH_var,' in js)
Exemplo n.º 4
0
   def test_COMPUTED(self):
       c="""class Component:
 def COMPUTED_var(self):
   pass"""
       js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
       self.assertTrue("_pyfunc_op_instantiate" in js)
       self.assertTrue("Vue.component(" in js)
       self.assertTrue('var: C.prototype.COMPUTED_var,' in js)
Exemplo n.º 5
0
   def test_MOUNTED(self):
       c="""class Component:
 def MOUNTED(self):
   pass"""
       js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
       self.assertTrue("_pyfunc_op_instantiate" in js)
       self.assertTrue("Vue.component(" in js)
       self.assertTrue('mounted: C.prototype.MOUNTED,' in js)
Exemplo n.º 6
0
def test_CREATED():
    c = """class Component:
    def CREATED(self):
        pass"""
    js = vbuild.mkPythonVueComponent("toto", "<div></div>", c)
    assert "_pyfunc_op_instantiate" in js
    assert "Vue.component(" in js
    assert "created: C.prototype.CREATED," in js
Exemplo n.º 7
0
    def test_METHODS(self):
        c="""class Component:
  def method1(self,nb):
    self["$parent"].nb=nb;
"""
        js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
        self.assertTrue("_pyfunc_op_instantiate" in js)
        self.assertTrue("Vue.component(" in js)
        self.assertTrue("method1: C.prototype.method1," in js)
        self.assertTrue('this["$parent"].nb = nb;' in js)
Exemplo n.º 8
0
    def test_INIT_PROPS(self):
        c="""class Component:
  def __init__(self,prop1="?",prop2="?"):
    self.val1=42
    self.val2=True
    self.val3="hello"
"""
        js=vbuild.mkPythonVueComponent("toto","<div></div>",c)
        self.assertTrue("_pyfunc_op_instantiate" in js)
        self.assertTrue("Vue.component(" in js)
        self.assertTrue("props: ['prop1', 'prop2']," in js)
        self.assertTrue("for(var i in ll) props.push( this.$props" in js)
        jsinit="""C.prototype.__init__ = function (prop1, prop2) {
    prop1 = (prop1 === undefined) ? "?": prop1;
    prop2 = (prop2 === undefined) ? "?": prop2;
    this.val1 = 42;
    this.val2 = true;
    this.val3 = "hello";
    return null;
};"""
        self.assertTrue(jsinit in js)