Иван Стрелков
describe('VideoView', () => {
it('is editable', () => {
expect(new VideoView().editable).toBe(true);
});
});
class VideoView extends GenericView {
editable = true;
// ...
}
Тестируются статические данные
module.exports = {
build() {
firstLib.clean('build')
.then(() => secondLib.compileJS('src', 'build'))
.then(() => thirdLib.optimizeCSS())
}
};
module.exports = {
build() {
firstLib.clean('build') // очистка
.then(() => secondLib.compileJS('src', 'build'))
.then(() => thirdLib.optimizeCSS())
}
};
module.exports = {
build() {
firstLib.clean('build')
.then(() => secondLib.compileJS('src', 'build')) // JS
.then(() => thirdLib.optimizeCSS())
}
};
module.exports = {
build() {
firstLib.clean('build')
.then(() => secondLib.compileJS('src', 'build'))
.then(() => thirdLib.optimizeCSS()) // CSS
}
};
describe('build step', () => {
beforeEach(() => {
// Подменяем библиотечные методы моками с resolved promises
buildSystem.build('/dir1');
});
it('builds, compiles and does something else', () => {
assert(firstLib.clean.calledWith('build'));
assert(secondLib.compileJS.calledWith('src', 'build'));
assert(thirdLib.optimizeCSS.called);
});
});
describe('build step', () => {
beforeEach(() => {
// Подменяем библиотечные методы моками с resolved promises
buildSystem.build('/dir1');
});
it('builds, compiles and does something else', () => {
assert(firstLib.clean.calledWith('build')); // очистка
assert(secondLib.compileJS.calledWith('src', 'build'));
assert(thirdLib.optimizeCSS.called);
});
});
describe('build step', () => {
beforeEach(() => {
// Подменяем библиотечные методы моками с resolved promises
buildSystem.build('/dir1');
});
it('builds, compiles and does something else', () => {
assert(firstLib.clean.calledWith('build'));
assert(secondLib.compileJS.calledWith('src', 'build')); // JS
assert(thirdLib.optimizeCSS.called);
});
});
describe('build step', () => {
beforeEach(() => {
// Подменяем библиотечные методы моками с resolved promises
buildSystem.build('/dir1');
});
it('builds, compiles and does something else', () => {
assert(firstLib.clean.calledWith('build'));
assert(secondLib.compileJS.calledWith('src', 'build'));
assert(thirdLib.optimizeCSS.called); // CSS
});
});
class HomePage extends React.Component {
render() {
return (
<div>
<Header userName={this.props.userName} />
<Content> {this.props.invitation} </Content>
<Footer showSocial />
</div>
)
}
}
describe('HomePage', () => {
beforeEach(() => { /* <HomePage userName="vasya" invitation="hello"/> */ });
it('renders header with userName', () => {
let header = TestUtils.findRenderedComponent(this.homePage, Header);
expect(header.props.userName).toBe('vasya');
});
it('renders footer', () => {
let footer = TestUtils.findRenderedComponent(this.homePage, Footer);
expect(footer.props.showSocial).toBe(true);
});
it('renders invitation', () => {
expect(this.container.innerHTML).toContain('hello');
});
});
describe('HomePage', () => {
beforeEach(() => { /* <HomePage userName="vasya" invitation="hello"/> */ });
it('renders header with userName', () => {
let header = TestUtils.findRenderedComponent(this.homePage, Header);
expect(header.props.userName).toBe('vasya');
});
it('renders footer', () => {
let footer = TestUtils.findRenderedComponent(this.homePage, Footer);
expect(footer.props.showSocial).toBe(true);
});
it('renders invitation', () => {
expect(this.container.innerHTML).toContain('hello');
});
});
describe('HomePage', () => {
beforeEach(() => { /* <HomePage userName="vasya" invitation="hello"/> */ });
it('renders header with userName', () => {
let header = TestUtils.findRenderedComponent(this.homePage, Header);
expect(header.props.userName).toBe('vasya');
});
it('renders footer', () => {
let footer = TestUtils.findRenderedComponent(this.homePage, Footer);
expect(footer.props.showSocial).toBe(true);
});
it('renders invitation', () => {
expect(this.container.innerHTML).toContain('hello');
});
});
describe('HomePage', () => {
beforeEach(() => { /* <HomePage userName="vasya" invitation="hello"/> */ });
it('renders header with userName', () => {
let header = TestUtils.findRenderedComponent(this.homePage, Header);
expect(header.props.userName).toBe('vasya');
});
it('renders footer', () => {
let footer = TestUtils.findRenderedComponent(this.homePage, Footer);
expect(footer.props.showSocial).toBe(true);
});
it('renders invitation', () => {
expect(this.container.innerHTML).toContain('hello');
});
});
class HomePage extends React.Component {
render() {
return (
<div>
<Header userName={this.props.userName} />
<Content children={this.props.invitation} />
<Footer showSocial />
</div>
)
}
}
test() {
form.toggleTube();
form.avitoBalloon().hide();
form.toggleAvito();
assert(form.avitoBalloon().visible === false);
}
toggleAvito() {
this.avito().action.toggle.call(this.avito());
basis.asap.process();
}
class SearchForm extends React.Component {
renderInput() {
return <input ref="query" onChange={this.handleChange}/>;
}
@Debounce(200) @autobind
handleChange() {
this.setState({ state: 'loading' });
fetchResults(this.refs.query.value).then(results => {
this.setState({ state: 'loaded', results });
});
}
// ...
}
class SearchForm extends React.Component { renderInput() { return <input ref="query" onChange={this.handleChange}/>; } @Debounce(200) @autobind handleChange() { this.setState({ state: 'loading' }); fetchResults(this.refs.query.value).then(results => { this.setState({ state: 'loaded', results }); }); } // ... }
class SearchForm extends React.Component { renderInput() { return <input ref="query" onChange={this.debouncedHandleChange}/>; } handleChange(value) { this.setState({ state: 'loading' }); fetchResults(value).then(results => { this.setState({ state: 'loaded', results }); }); } @Debounce(200) @autobind debouncedHandleChange() { this.handleChange(this.refs.query.value); } }