Add tests for tabs

This commit is contained in:
Yuya Ochiai
2015-12-23 20:53:54 +09:00
parent 62b6e4c51b
commit 7fb2dc9cb6
2 changed files with 43 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ var MainPage = React.createClass({
} }
}, },
visibleStyle: function(visible) { visibleStyle: function(visible) {
var visibility = visible ? 'initial' : 'hidden'; var visibility = visible ? 'visible' : 'hidden';
return { return {
position: 'absolute', position: 'absolute',
top: 42, top: 42,
@@ -62,7 +62,7 @@ var MainPage = React.createClass({
{ thisObj.state.unreadCounts[index] } { thisObj.state.unreadCounts[index] }
</Badge>); </Badge>);
} }
return (<NavItem eventKey={ index }> return (<NavItem className="teamTabItem" id={ 'teamTabItem' + index } eventKey={ index }>
{ team.name } { team.name }
{ ' ' } { ' ' }
{ badge } { badge }

View File

@@ -100,7 +100,6 @@ describe('electron-mattermost', function() {
client client
.init() .init()
.getAttribute('.mattermostView', 'src').then(function(attribute) { .getAttribute('.mattermostView', 'src').then(function(attribute) {
console.log(attribute);
attribute.forEach(function(attr, index) { attribute.forEach(function(attr, index) {
attr.should.equal(config.teams[index].url); attr.should.equal(config.teams[index].url);
}); });
@@ -109,5 +108,46 @@ describe('electron-mattermost', function() {
done(); done();
}); });
}); });
it('should set name of tab from config file', function(done) {
var client = webdriverio.remote(options);
client
.init()
.getText('.teamTabItem').then(function(text) {
text.forEach(function(t, index) {
t.should.equal(config.teams[index].name);
});
})
.end().then(function() {
done();
});
});
it('should show only the selected team', function(done) {
this.timeout(5000);
var checkVisility = function(visibleIndex) {
return function(isVisible) {
isVisible.forEach(function(v, index) {
if (index === visibleIndex) {
v.should.equal(true);
}
else {
v.should.equal(false);
}
});
};
};
var client = webdriverio.remote(options);
client
.init()
.isVisible('.mattermostView').then(checkVisility(0))
.click('#teamTabItem1')
.isVisible('.mattermostView').then(checkVisility(1))
.click('#teamTabItem0')
.isVisible('.mattermostView').then(checkVisility(0))
.end().then(function() {
done();
});
});
}); });
}); });