Last active
May 31, 2018 16:08
-
-
Save lennyburdette/050ca882b3eb03da56916bce42da6649 to your computer and use it in GitHub Desktop.
Ember Addon Build Test Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-env node */ | |
| // This is for TEST_APPLICATION_FIXTURE in the next file | |
| module.exports = function() { | |
| return { | |
| application: { | |
| app: { | |
| styles: { | |
| 'app.css': '' | |
| }, | |
| 'index.html': '' | |
| }, | |
| config: { | |
| 'environment.js': "module.exports = function() { return { modulePrefix: 'application' } };" | |
| }, | |
| 'ember-cli-build.js': 'module.exports = {};', | |
| 'package.json': JSON.stringify({ | |
| name: 'application', | |
| devDependencies: { | |
| 'ember-cli': '*', | |
| 'ember-cli-babel': '*', | |
| 'ember-cli-htmlbars': '*', | |
| 'ember-engines': '*', | |
| 'ember-source': '*', | |
| 'loader.js': '*' | |
| }, | |
| 'ember-addon': { | |
| paths: ['../my-addon-name'] | |
| } | |
| }), | |
| tmp: {} | |
| } | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-env node, mocha */ | |
| 'use strict'; | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const co = require('co'); | |
| const expect = require('chai').expect; | |
| const helper = require('broccoli-test-helper'); | |
| const createBuilder = helper.createBuilder; | |
| const createTempDir = helper.createTempDir; | |
| const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | |
| const _resetTreeCache = require('ember-cli/lib/models/addon')._resetTreeCache; | |
| const ADDON_ROOT = path.resolve(__dirname, '..', '..'); | |
| describe('engines', function () { | |
| this.timeout(10000); | |
| let cwd; | |
| beforeEach(function () { | |
| cwd = process.cwd(); | |
| }); | |
| afterEach(function () { | |
| process.chdir(cwd); | |
| _resetTreeCache(); | |
| }); | |
| it( | |
| 'builds things correctly', | |
| co.wrap(function* () { | |
| const input = yield createTempDir(); | |
| /* | |
| Expected file system layout: | |
| ${tmp-dir}/ <- process.cwd, used as the ember-cli project.root | |
| application/ <- fixture files for a minimal application | |
| my-addon-name/ <- symlink; installed in application via package.json ember-addon.paths | |
| node_modules/ <- symlink | |
| */ | |
| input.write(TEST_APPLICATION_FIXTURE); | |
| fs.symlinkSync( | |
| path.join(ADDON_ROOT, 'node_modules'), | |
| path.join(input.path(), 'node_modules') | |
| ); | |
| fs.symlinkSync( | |
| ADDON_ROOT, | |
| path.join(input.path(), 'my-addon-name') | |
| ); | |
| process.chdir(input.path()); | |
| const emberApp = new EmberApp(); | |
| const output = createBuilder(emberApp.toTree()); | |
| try { | |
| yield output.build(); | |
| const files = output.read(); | |
| expect(files.assets['tailwind.css']).to.contain('example css'); | |
| } finally { | |
| yield output.dispose(); | |
| yield input.dispose(); | |
| } | |
| }) | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment