UNPKG

nsmockup

Version:

Test your Suitescripts before deploying to NetSuite

59 lines (51 loc) 1.58 kB
'use strict'; var fs = require('fs'), path = require('path'), should = require('should'), parallel = require('mocha.parallel'), nsmockup = require('../../'); const fileDir = __dirname + '/../_input-files/files'; /** * Test Suites */ describe('<Unit Test - Netsuite XML API>', function () { before(done => { nsmockup.init(done); }); parallel('XML API - nlapiSelectValue:', () => { let xmlDoc; before(done => { let xmlPath = path.resolve(fileDir + '/help.xml'), xml = fs.readFileSync(xmlPath, 'utf8'); xmlDoc = nlapiStringToXML(xml); should(xmlDoc).be.ok(); return done(); }); it('select-value find by xpath', done => { let value = nlapiSelectValue(xmlDoc, '//table'); should(value).be.ok(); return done(); }); it('select-value missing node', done => { try { nlapiSelectValue(); return done('missing node'); } catch (e) { should(e).have.property('code', 'SSS_NODE_ARG_REQD'); return done(); } }); it('elect-value missing xpath', done => { try { nlapiSelectValue(xmlDoc); return done('missing xpath'); } catch (e) { should(e).have.property('code', 'SSS_XPATH_ARG_REQD'); return done(); } }); }); after(done => { nsmockup.destroy(done); }); });