import { compile, compileOptions, defaultPlugins, registerPlugin, unregisterPlugin, } from '../../index'; import { moduleFor, AbstractTestCase, RenderingTestCase } from 'internal-test-helpers'; moduleFor( 'ember-template-compiler: default compile options', class extends AbstractTestCase { ['@test default options are a new copy'](assert) { assert.notEqual(compileOptions(), compileOptions()); } ['@test has default AST plugins'](assert) { assert.expect(defaultPlugins.length); let plugins = compileOptions().plugins.ast; for (let i = 0; i < defaultPlugins.length; i++) { let plugin = defaultPlugins[i]; assert.ok(plugins.indexOf(plugin) > -1, `includes ${plugin}`); } } } ); let customTransformCounter = 0; class CustomTransform { constructor(options) { customTransformCounter++; this.options = options; this.syntax = null; } transform(ast) { let walker = new this.syntax.Walker(); walker.visit(ast, node => { if (node.type !== 'ElementNode') { return; } for (var i = 0; i < node.attributes.length; i++) { let attribute = node.attributes[i]; if (attribute.name === 'data-test') { node.attributes.splice(i, 1); } } }); return ast; } } class CustomPluginsTests extends RenderingTestCase { afterEach() { customTransformCounter = 0; return super.afterEach(); } ['@test custom plugins can be used']() { this.render('
'); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: 'hahaha', 'data-blah': 'derp' }, content: '', }); } ['@test wrapped plugins are only invoked once per template'](assert) { this.render('