-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Add a basic integration test for Glimmer""
This reverts commit d619a07. CI was failing because we forgot to push the upstream changes in Glimmer.
- Loading branch information
1 parent
d619a07
commit e07d3cf
Showing
17 changed files
with
142 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export class Renderer { | ||
constructor(domHelper, { destinedForDOM, env } = {}) { | ||
this._dom = domHelper; | ||
this._env = env; | ||
} | ||
|
||
appendTo(view, target) { | ||
let env = this._env; | ||
|
||
env.begin(); | ||
view.template.render({ view }, env, { appendTo: target }); | ||
env.commit(); | ||
} | ||
|
||
componentInitAttrs() { | ||
// TODO: Remove me | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/ember-glimmer/lib/ember-template-compiler/system/compile.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import template from './template'; | ||
import require, { has } from 'require'; | ||
|
||
let compileSpec; | ||
let Template; | ||
|
||
export default function compile(string, options) { | ||
if (!compileSpec && has('glimmer-compiler')) { | ||
compileSpec = require('glimmer-compiler').compileSpec; | ||
} | ||
|
||
if (!Template && has('glimmer-runtime')) { | ||
Template = require('glimmer-runtime').Template; | ||
} | ||
|
||
if (!compileSpec || !Template) { | ||
throw new Error('Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`.'); | ||
} | ||
|
||
let templateSpec = template(compileSpec(string, options)); | ||
return Template.fromSpec(templateSpec, options.env); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/ember-glimmer/lib/ember-template-compiler/system/template.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function template(templateSpec) { | ||
return JSON.parse(templateSpec); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { RenderingTest, moduleFor } from '../utils/test-case'; | ||
|
||
moduleFor('Content tests', class extends RenderingTest { | ||
|
||
['TEST: it can render static content']() { | ||
this.render('hello'); | ||
this.assertText('hello'); | ||
} | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { TestEnvironment as default } from 'glimmer-test-helpers'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { DOMHelper } from 'glimmer-runtime'; | ||
export { Renderer } from 'ember-glimmer/ember-metal-views'; | ||
export { default as compile } from 'ember-glimmer/ember-template-compiler/system/compile'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'glimmer'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import packageName from './package-name'; | ||
import Environment from './environment'; | ||
import { compile, DOMHelper, Renderer } from './helpers'; | ||
import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; | ||
import Component from 'ember-views/components/component'; | ||
import jQuery from 'ember-views/system/jquery'; | ||
|
||
const packageTag = `${packageName.toUpperCase()}: `; | ||
|
||
export function moduleFor(description, TestClass) { | ||
let context; | ||
|
||
QUnit.module(description, { | ||
setup() { | ||
context = new TestClass(); | ||
}, | ||
|
||
teardown() { | ||
context.teardown(); | ||
} | ||
}); | ||
|
||
Object.keys(TestClass.prototype).forEach(name => { | ||
if (name.indexOf('TEST: ') === 0) { | ||
QUnit.test(name.slice(5), assert => context[name](assert)); | ||
} else if (name.indexOf('SKIP: ') === 0) { | ||
QUnit.skip(name.slice(5), assert => context[name](assert)); | ||
} else if (name.indexOf(packageTag) === 0) { | ||
QUnit.test(name.slice(packageTag.length), assert => context[name](assert)); | ||
} | ||
}); | ||
} | ||
|
||
let assert = QUnit.assert; | ||
|
||
export class TestCase { | ||
teardown() {} | ||
} | ||
|
||
export class RenderingTest extends TestCase { | ||
constructor() { | ||
super(); | ||
let dom = new DOMHelper(document); | ||
let env = this.env = new Environment(dom); | ||
this.renderer = new Renderer(dom, { destinedForDOM: true, env }); | ||
this.component = null; | ||
} | ||
|
||
teardown() { | ||
if (this.component) { | ||
runDestroy(this.component); | ||
} | ||
} | ||
|
||
render(templateStr, context = {}) { | ||
let { env, renderer } = this; | ||
|
||
let attrs = Object.assign({}, context, { | ||
renderer, | ||
template: compile(templateStr, { env }) | ||
}); | ||
|
||
this.component = Component.create(attrs); | ||
|
||
runAppend(this.component); | ||
} | ||
|
||
rerender() { | ||
this.component.rerender(); | ||
} | ||
|
||
assertText(text) { | ||
assert.strictEqual(jQuery('#qunit-fixture').text(), text, `#qunit-fixture contents`); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
import Renderer from 'ember-metal-views/renderer'; | ||
export { Renderer }; | ||
export * from './htmlbars-renderer'; |
This file contains 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
This file contains 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