[js/ts] colorizer tests

This commit is contained in:
Martin Aeschlimann
2016-04-11 16:01:56 +02:00
parent e475fdebcc
commit a5ae040dba
6 changed files with 12619 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var gulp = require('gulp');
var tsb = require('gulp-tsb');
var util = require('./lib/util');
var watcher = require('./lib/watch');
var assign = require('object-assign');
var compilation = tsb.create(assign({ verbose: true }, require('./tsconfig.json').compilerOptions));
gulp.task('compile', function() {
return gulp.src('**/*.ts', { base: '.' })
.pipe(compilation())
.pipe(gulp.dest(''));
});
gulp.task('watch', function() {
var src = gulp.src('**/*.ts', { base: '.' });
return watcher('**/*.ts', { base: '.' })
.pipe(util.incremental(compilation, src))
.pipe(gulp.dest(''));
});
gulp.task('default', ['compile']);
function cloneArray(arr) {
_.foo();
var r = [];
for (var i = 0, len = arr.length; i < len; i++) {
r[i] = doClone(arr[i]);
}
return r;
}

View File

@@ -0,0 +1,35 @@
var ToggleText = React.createClass({
getInitialState: function () {
return {
showDefault: true
}
},
toggle: function (e) {
// Prevent following the link.
e.preventDefault();
// Invert the chosen default.
// This will trigger an intelligent re-render of the component.
this.setState({ showDefault: !this.state.showDefault })
},
render: function () {
// Default to the default message.
var message = this.props.default;
// If toggled, show the alternate message.
if (!this.state.showDefault) {
message = this.props.alt;
}
return (
<div>
<h1>Hello {message}!</h1>
<a href="" onClick={this.toggle}>Toggle</a>
</div>
);
}
});
React.render(<ToggleText default="World" alt="Mars" />, document.body);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff