Initial ember.js declarations and tests

This commit is contained in:
Boris Yankov
2012-10-19 20:27:25 +03:00
parent ca547794ae
commit 83319ba26f
2 changed files with 111 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for Ember.js 1.0
// Project: http://emberjs.com/
// Definitions: https://github.com/borisyankov/DefinitelyTyped
module Em {
// $;
export function A(arr?: any[]): NativeArray;
export function addListener(obj: any, eventName: string, targetOrMethod: any, method: any): void;
export function alias(methodName: Descriptor): Alias;
export function assert(desc: string, test: bool): void;
export function beforeObserver(func: Function, propertyNames: string): Function;
export function bind(obj: any, to: string, from: string): Binding;
export function cacheFor(obj: any, key: string): void;
export interface Alias {
}
class Application {
static create(): Application;
MyView: View;
}
export interface ArrayController {
}
export interface Binding {
}
export interface Descriptor {
}
export interface NativeArray {
activate(): void;
}
export interface Object {
}
export class View {
}
}
+68
View File
@@ -0,0 +1,68 @@
/// <reference path="../Definitions/ember-1.0.d.ts" />
var App;
App = Em.Application.create();
App.MyView = Em.View.extend({
mouseDown: function() {
window.alert("hello world!");
});
class MyView extends Em.View {
mouseDown() {
window.alert("hello world!");
}
}
App.Person = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
fullName: function() {
return this.get('firstName') +
" " + this.get('lastName');
}.property('firstName', 'lastName')
});
App.peopleController = Em.ArrayController.create({
content: App.Person.findAll()
});
App.president = Ember.Object.create({
name: "Barack Obama"
});
App.country = Ember.Object.create({
presidentNameBinding: 'App.president.name'
});
App.country.get('presidentName');
App.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property()
});
App.president.get('fullName');
App.president = Ember.Object.create({
firstName: "Barack",
lastName: "Obama",
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
App.PaintSample = Ember.Object.extend({
color: 'red',
colour: Ember.alias('color'),
name: function () {
return "Zed";
},
moniker: Ember.alias("name")
});
var paintSample = App.PaintSample.create();
paintSample.get('colour');
paintSample.moniker();
Ember.assert('Must pass a valid object', obj);
Ember.assert('This code path should never be run');