|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const buildResolutionMap = require('..').buildResolutionMap; |
| 4 | +const createTempDir = require('broccoli-test-helper').createTempDir; |
| 5 | +const fs = require('fs'); |
| 6 | +const path = require('path'); |
| 7 | +const assert = require('assert'); |
| 8 | + |
| 9 | +describe('buildResolutionMap', function () { |
| 10 | + let configPath = path.join(__dirname, 'fixtures/config/environment.json'); |
| 11 | + let config = JSON.parse(fs.readFileSync(configPath)); |
| 12 | + let srcFixture; |
| 13 | + |
| 14 | + beforeEach(function () { |
| 15 | + return createTempDir().then(src => { |
| 16 | + srcFixture = src; |
| 17 | + |
| 18 | + srcFixture.write({ |
| 19 | + "src": { |
| 20 | + "ui": { |
| 21 | + "components": { |
| 22 | + "my-app": { |
| 23 | + "README.md": "## My-App Component\n", |
| 24 | + "component.ts": "", |
| 25 | + "page-banner": { |
| 26 | + "-utils": { |
| 27 | + "ignore-me.ts": "" |
| 28 | + }, |
| 29 | + "component.ts": "", |
| 30 | + "ignore-me.d.ts": "", |
| 31 | + "template.hbs": "", |
| 32 | + "titleize.ts": "" |
| 33 | + }, |
| 34 | + "template.hbs": "" |
| 35 | + }, |
| 36 | + "unresolvable.js": "console.log(1);", |
| 37 | + }, |
| 38 | + "index.html": "<html>\n <head></head>\n <body></body>\n</html>\n" |
| 39 | + }, |
| 40 | + "unresolvable.js": "console.log(1);", |
| 41 | + } |
| 42 | + }); |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + afterEach(function () { |
| 47 | + srcFixture.dispose(); |
| 48 | + }); |
| 49 | + |
| 50 | + it('never includes unresolvalbe types', function () { |
| 51 | + config.moduleConfiguration.types.unresolvable = { unresolvable: true }; |
| 52 | + config.moduleConfiguration.collections.main.types.push('unresolvable'); |
| 53 | + config.moduleConfiguration.collections.components.types.push('unresolvable'); |
| 54 | + |
| 55 | + let map = buildResolutionMap({ |
| 56 | + projectDir: srcFixture.path(), |
| 57 | + moduleConfig: config.moduleConfiguration, |
| 58 | + modulePrefix: config.modulePrefix |
| 59 | + }); |
| 60 | + |
| 61 | + assert.deepEqual(map, { |
| 62 | + 'component:/my-app/components/my-app': 'src/ui/components/my-app/component', |
| 63 | + 'component:/my-app/components/my-app/page-banner': 'src/ui/components/my-app/page-banner/component', |
| 64 | + 'template:/my-app/components/my-app/page-banner': 'src/ui/components/my-app/page-banner/template', |
| 65 | + 'component:/my-app/components/my-app/page-banner/titleize': 'src/ui/components/my-app/page-banner/titleize', |
| 66 | + 'template:/my-app/components/my-app': 'src/ui/components/my-app/template', |
| 67 | + }) |
| 68 | + }); |
| 69 | +}); |
0 commit comments