HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/assets/components/utils.test.js
var utils = require('./utils');

describe('Widget misc. functions', function () {
    describe('getIdFromUrl', function () {
        it('should return null when the URL does not contain an id', function () {
            var url1 = 'http://localhost/widgets/new';
            expect(utils.getIdFromUrl(url1)).toBe(null);
            var url2 = 'http://localhost/widgets/edit/';
            expect(utils.getIdFromUrl(url2)).toBe(null);
        });

        it('should return the corrent ID from the URL', function () {
            var url = 'http://localhost/widgets/edit/7';
            expect(utils.getIdFromUrl(url)).toBe(7);
        });
    });
});