|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const path = require('path'); |
| 4 | +const tap = require('tap'); |
| 5 | +const rewire = require("rewire"); |
| 6 | + |
| 7 | +const exportData = rewire('../core/lib/exportData'); |
| 8 | +const util = require('./util/test_utils.js'); |
| 9 | + |
| 10 | +const testPatternsPath = path.resolve(__dirname, 'files', '_patterns'); |
| 11 | + |
| 12 | +const fsMock = { |
| 13 | + outputFileSync: function (path, content) { /* INTENTIONAL NOOP */}, |
| 14 | +}; |
| 15 | + |
| 16 | +//set our mocks in place of usual require() |
| 17 | +exportData.__set__({ |
| 18 | + 'fs': fsMock, |
| 19 | +}); |
| 20 | + |
| 21 | +const patternlab = util.fakePatternLab(testPatternsPath); |
| 22 | +const result = exportData(patternlab); |
| 23 | + |
| 24 | +tap.test('exportData exports config', function (test) { |
| 25 | + test.equals(result.indexOf('config') > -1, true); |
| 26 | + test.equals(result.indexOf('paths') > -1, true); |
| 27 | + test.equals(result.indexOf('theme') > -1, true); |
| 28 | + test.end(); |
| 29 | +}); |
| 30 | + |
| 31 | +tap.test('exportData exports ishControls', function (test) { |
| 32 | + test.equals(result.indexOf('ishControlsHide') > -1, true); |
| 33 | + test.end(); |
| 34 | +}); |
| 35 | + |
| 36 | +tap.test('exportData exports navItems', function (test) { |
| 37 | + test.equals(result.indexOf('patternTypes') > -1, true); |
| 38 | + test.end(); |
| 39 | +}); |
| 40 | + |
| 41 | +tap.test('exportData exports patternPaths', function (test) { |
| 42 | + test.equals(result.indexOf('patternPaths') > -1, true); |
| 43 | + test.end(); |
| 44 | +}); |
| 45 | + |
| 46 | +tap.test('exportData exports viewAllPaths', function (test) { |
| 47 | + test.equals(result.indexOf('viewAllPaths') > -1, true); |
| 48 | + test.end(); |
| 49 | +}); |
| 50 | + |
| 51 | +tap.test('exportData exports plugins', function (test) { |
| 52 | + test.equals(result.indexOf('plugins') > -1, true); |
| 53 | + test.end(); |
| 54 | +}); |
| 55 | + |
| 56 | +tap.test('exportData exports defaultShowPatternInfo', function (test) { |
| 57 | + test.equals(result.indexOf('defaultShowPatternInfo') > -1, true); |
| 58 | + test.equals(result.indexOf('"defaultShowPatternInfo":false') > -1, true); |
| 59 | + test.end(); |
| 60 | +}); |
| 61 | + |
| 62 | +tap.test('exportData exports defaultPattern', function (test) { |
| 63 | + test.equals(result.indexOf('defaultPattern') > -1, true); |
| 64 | + test.equals(result.indexOf('"defaultPattern":"all"') > -1, true); |
| 65 | + test.end(); |
| 66 | +}); |
0 commit comments