vendredi 22 décembre 2017

Reference Error for Sencha Test

I'm trying a simple unit test with Sencha Test but keep taking this error;

System error: ReferenceError: myDemoApp is not defined at Object.<anonymous> (/Users/frontend/la-nuri/Dev/Demo/MyDemoApp/test/DemoScenario/DemoSuite2.js:6:27) at Object.call (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kD6F4w) at Object.invoke (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kYpIW0) at Object.me.wrapperFn (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kF5VeV) at attemptAsync (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kYpMoI) at QueueRunner.run (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kF5XU5) at QueueRunner.execute (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kYpNZO) at Spec.queueRunnerFactory (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kD6Lco) at Spec.execute (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kXGFQt) at Object.fn (/Applications/Sencha/Test/2_1_2_1/Sencha http://ift.tt/2kFKoTs)

I've generate a sample app with sencha cmd through this guide with this command;

sencha generate app -ext MyApp /path/to/my-app

Here is my test suite and some other code snippets;

describe('Demo Suite 2', function() {

    describe('onConfirm() method', function() {

        it('should be a function', function() {
            expect(typeof myDemoApp.view.main.MainController.onConfirm).toEqual('function');
        });

        it('should return a string', function() {
            expect(typeof myDemoApp.view.main.MainController.onConfirm()).toEqual('string');
        });
    });  
});

This is sencha-made controller;

/**
 * This class is the controller for the main view for the application. It is specified as
 * the "controller" of the Main view class.
 */
Ext.define('myDemoApp.view.main.MainController', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.main',

    onItemSelected: function (sender, record) {
        Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
    },

    onConfirm: function (choice) {
        if (choice === 'yes') {
            console.log("this is a yess")
        }
    }
});

I want to check onConfirm method with that simple unit test suite. Why cannot reach to myDemoApp?

Aucun commentaire:

Enregistrer un commentaire