Add simple tests for settings.html

This commit is contained in:
Yuya Ochiai
2015-12-27 16:11:44 +09:00
parent 9b0b782d20
commit 3d8d39562f
2 changed files with 52 additions and 2 deletions

View File

@@ -50,9 +50,9 @@ var SettingsPage = React.createClass({
</Row>
<Row>
<Col md={ 12 }>
<Button onClick={ this.handleCancel }>Cancel</Button>
<Button id="btnCancel" onClick={ this.handleCancel }>Cancel</Button>
{ ' ' }
<Button bsStyle="primary" onClick={ this.handleSave }>Save</Button>
<Button id="btnSave" bsStyle="primary" onClick={ this.handleSave }>Save</Button>
</Col>
</Row>
</Grid>

View File

@@ -168,4 +168,54 @@ describe('electron-mattermost', function() {
});
});
});
describe('settings.html', function() {
const config = {
version: 1,
teams: [{
name: 'example_1',
url: mattermost_url
}, {
name: 'example_2',
url: mattermost_url
}]
};
before(function() {
fs.writeFileSync(config_file_path, JSON.stringify(config));
});
it('should show index.thml when Cancel button is clicked', function(done) {
client
.init()
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
.waitForExist('#btnCancel')
.click('#btnCancel')
.pause(1000)
.getUrl().then(function(url) {
var url_split = url.split('/');
url_split[url_split.length - 1].should.equal('index.html');
})
.end().then(function() {
done();
});
});
it('should show index.thml when Save button is clicked', function(done) {
client
.init()
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
.waitForExist('#btnSave')
.click('#btnSave')
.pause(1000)
.getUrl().then(function(url) {
var url_split = url.split('/');
url_split[url_split.length - 1].should.equal('index.html');
})
.end().then(function() {
done();
});
});
});
});