UNPKG

1.75 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var cordovaConfig = require("./cordova-config");
4describe('parseConfig function', function () {
5 it('should return {} when the config does not contain a widget', function () {
6 var result = cordovaConfig.parseConfig({});
7 expect(result).toEqual({});
8 });
9 it('should return a CordovaProject without id or version if config.$ does not exist', function () {
10 var result = cordovaConfig.parseConfig({
11 widget: {
12 name: ['thename'],
13 }
14 });
15 expect(result).toEqual({
16 name: 'thename',
17 });
18 });
19 it('should return a CordovaProject on success', function () {
20 var result = cordovaConfig.parseConfig({
21 widget: {
22 name: ['thename'],
23 $: {
24 id: 'theid',
25 version: 'theversion'
26 }
27 }
28 });
29 expect(result).toEqual({
30 name: 'thename',
31 id: 'theid',
32 version: 'theversion'
33 });
34 });
35});
36/*
37describe('buildCordovaConfig', () => {
38 it('should read the config.xml file', (done) => {
39 let fs: any = jest.genMockFromModule('fs');
40 fs.readFile = jest.fn().mockReturnValue('blah');
41 jest.mock('xml2js', function() {
42 return {
43 Parser: function() {
44 return {
45 parseString: function (data, cb) {
46 cb(null, 'parseConfigData');
47 }
48 };
49 }
50 };
51 });
52
53 function daCallback() {
54 expect(fs.readfile).toHaveBeenCalledWith('config.xml');
55 done();
56 }
57
58 cordovaConfig.buildCordovaConfig(daCallback, daCallback);
59 });
60});
61*/