|
1 | | -test('custom blocks', () => { |
| 1 | +const { |
| 2 | + bundle |
| 3 | +} = require('./utils') |
2 | 4 |
|
| 5 | +test('add custom blocks to the webpack output', done => { |
| 6 | + bundle({ |
| 7 | + entry: 'custom-language.vue', |
| 8 | + module: { |
| 9 | + rules: [ |
| 10 | + { test: /\.js/, loader: 'babel-loader' } |
| 11 | + ] |
| 12 | + } |
| 13 | + }, code => { |
| 14 | + // should also be transpiled |
| 15 | + expect(code).toContain(` |
| 16 | +describe('example', function () { |
| 17 | + it('basic', function (done) { |
| 18 | + done(); |
| 19 | + }); |
| 20 | +}); |
| 21 | + `.trim()) |
| 22 | + done() |
| 23 | + }) |
| 24 | +}) |
| 25 | + |
| 26 | +test('custom blocks should work with src imports', done => { |
| 27 | + bundle({ |
| 28 | + entry: 'custom-import.vue', |
| 29 | + module: { |
| 30 | + rules: [ |
| 31 | + { test: /\.js/, loader: 'babel-loader' } |
| 32 | + ] |
| 33 | + } |
| 34 | + }, (code) => { |
| 35 | + expect(code).toContain(` |
| 36 | +describe('example', function () { |
| 37 | + it('basic', function (done) { |
| 38 | + done(); |
| 39 | + }); |
| 40 | +}); |
| 41 | + `.trim()) |
| 42 | + done() |
| 43 | + }) |
| 44 | +}) |
| 45 | + |
| 46 | +// TODO |
| 47 | +// test('passes Component to custom block loaders', done => { |
| 48 | +// mockBundleAndRun({ |
| 49 | +// entry: 'custom-language.vue', |
| 50 | +// module: { |
| 51 | +// rules: [ |
| 52 | +// { |
| 53 | +// resourceQuery: /blockType=documentation/, |
| 54 | +// loader: require.resolve('./mock-loaders/docs') |
| 55 | +// } |
| 56 | +// ] |
| 57 | +// } |
| 58 | +// }, ({ module }) => { |
| 59 | +// expect(module.__docs).toContain('This is example documentation for a component.') |
| 60 | +// done() |
| 61 | +// }) |
| 62 | +// }) |
| 63 | + |
| 64 | +test('custom blocks can be ignored', done => { |
| 65 | + bundle({ |
| 66 | + entry: 'custom-language.vue' |
| 67 | + }, code => { |
| 68 | + expect(code).not.toContain(`describe('example'`) |
| 69 | + done() |
| 70 | + }) |
3 | 71 | }) |
0 commit comments