3
votes

I'm trying to add unit testing into my project, focused on improoving basic Odoo 9 POS module. My issue is about getting Odoo instanse inside test. I've created test for testing and getting undefined value for everything, except web.Registry. Here is my code sample:

    odoo.define_section('Model', ['<my_module>.models', 'web.Registry', '<my_module>.lens_selection_widget', '<my_module>.test_passer', 'point_of_sale.chrome'], function(test, mock) {
    test('Check Orderline', function(assert, Model, Reg, LSW, TP, Main, POSC) {
        assert.ok(mock, 'mock');
        assert.ok(Model, 'Model');
        assert.ok(Reg, 'Reg');
        assert.ok(LSW, 'LSW');
        assert.ok(TP, 'TP');
        assert.ok(POSC, 'POSC');
    })
});

Even test_passer, with definition like

odoo.define('test_passer', function (require) {
"use strict";

    return true
});

returns undefined.

Need some help, ready for any question.

1
Can you please paste the template you use to inject this javascript ? - George Daramouskas
@GeorgeDaramouskas ATM I can't, but thank you for the question, because it's possible, that I hasn't added the main files. I'll try and write the result here - Ivan Piskunov
@GeorgeDaramouskas each I've just needed to define files in the template. Thank you for your help - Ivan Piskunov

1 Answers

1
votes

I've just needed to add POS and my own files to the template to make it work. Thanks to @GeorgeDaramouskas for the idea

    <!-- POS Files -->
    <script type="text/javascript" src="/point_of_sale/static/lib/fastclick.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/lib/waitfont.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/db.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/models.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/widget_base.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/keyboard.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/chrome.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/devices.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/gui.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/popups.js"></script>
    <script type="text/javascript" src="/point_of_sale/static/src/js/screens.js"></script>
    <!-- Your files -->
    ....
    <!-- Your tests Here -->
    .....