|
@@ -119,4 +119,121 @@ describe('App.config', function () {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ describe('#fileConfigsIntoTextarea', function () {
|
|
|
|
+ var filename = 'capacity-scheduler.xml';
|
|
|
|
+ var configs = [
|
|
|
|
+ {
|
|
|
|
+ name: 'config1',
|
|
|
|
+ value: 'value1',
|
|
|
|
+ defaultValue: 'value1',
|
|
|
|
+ filename: 'capacity-scheduler.xml'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'config2',
|
|
|
|
+ value: 'value2',
|
|
|
|
+ defaultValue: 'value2',
|
|
|
|
+ filename: 'capacity-scheduler.xml'
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+ it('two configs into textarea', function () {
|
|
|
|
+ var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
|
|
|
|
+ expect(result.length).to.equal(1);
|
|
|
|
+ expect(result[0].value).to.equal('config1=value1\nconfig2=value2\n');
|
|
|
|
+ expect(result[0].defaultValue).to.equal('config1=value1\nconfig2=value2\n');
|
|
|
|
+ });
|
|
|
|
+ it('three config into textarea', function () {
|
|
|
|
+ configs.push({
|
|
|
|
+ name: 'config3',
|
|
|
|
+ value: 'value3',
|
|
|
|
+ defaultValue: 'value3',
|
|
|
|
+ filename: 'capacity-scheduler.xml'
|
|
|
|
+ });
|
|
|
|
+ var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
|
|
|
|
+ expect(result.length).to.equal(1);
|
|
|
|
+ expect(result[0].value).to.equal('config1=value1\nconfig2=value2\nconfig3=value3\n');
|
|
|
|
+ expect(result[0].defaultValue).to.equal('config1=value1\nconfig2=value2\nconfig3=value3\n');
|
|
|
|
+ });
|
|
|
|
+ it('one of three configs has different filename', function () {
|
|
|
|
+ configs[1].filename = 'another filename';
|
|
|
|
+ var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
|
|
|
|
+ //result contains two configs: one with different filename and one textarea config
|
|
|
|
+ expect(result.length).to.equal(2);
|
|
|
|
+ expect(result[1].value).to.equal('config1=value1\nconfig3=value3\n');
|
|
|
|
+ expect(result[1].defaultValue).to.equal('config1=value1\nconfig3=value3\n');
|
|
|
|
+ });
|
|
|
|
+ it('none configs into empty textarea', function () {
|
|
|
|
+ filename = 'capacity-scheduler.xml';
|
|
|
|
+ configs.clear();
|
|
|
|
+ var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
|
|
|
|
+ expect(result.length).to.equal(1);
|
|
|
|
+ expect(result[0].value).to.equal('');
|
|
|
|
+ expect(result[0].defaultValue).to.equal('');
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ describe('#textareaIntoFileConfigs', function () {
|
|
|
|
+ var filename = 'capacity-scheduler.xml';
|
|
|
|
+ var testData = [
|
|
|
|
+ {
|
|
|
|
+ configs: [Em.Object.create({
|
|
|
|
+ "name": "capacity-scheduler",
|
|
|
|
+ "value": "config1=value1",
|
|
|
|
+ "filename": "capacity-scheduler.xml"
|
|
|
|
+ })]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ configs: [Em.Object.create({
|
|
|
|
+ "name": "capacity-scheduler",
|
|
|
|
+ "value": "config1=value1\nconfig2=value2\n",
|
|
|
|
+ "filename": "capacity-scheduler.xml"
|
|
|
|
+ })]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ configs: [Em.Object.create({
|
|
|
|
+ "name": "capacity-scheduler",
|
|
|
|
+ "value": "config1=value1,config2=value2\n",
|
|
|
|
+ "filename": "capacity-scheduler.xml"
|
|
|
|
+ })]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ configs: [Em.Object.create({
|
|
|
|
+ "name": "capacity-scheduler",
|
|
|
|
+ "value": "config1=value1 config2=value2\n",
|
|
|
|
+ "filename": "capacity-scheduler.xml"
|
|
|
|
+ })]
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ it('config1=value1 to one config', function () {
|
|
|
|
+ var result = App.config.textareaIntoFileConfigs.call(App.config, testData[0].configs, filename);
|
|
|
|
+ expect(result.length).to.equal(1);
|
|
|
|
+ expect(result[0].value).to.equal('value1');
|
|
|
|
+ expect(result[0].name).to.equal('config1');
|
|
|
|
+ });
|
|
|
|
+ it('config1=value1\\nconfig2=value2\\n to two configs', function () {
|
|
|
|
+ var result = App.config.textareaIntoFileConfigs.call(App.config, testData[1].configs, filename);
|
|
|
|
+ expect(result.length).to.equal(2);
|
|
|
|
+ expect(result[0].value).to.equal('value1');
|
|
|
|
+ expect(result[0].name).to.equal('config1');
|
|
|
|
+ expect(result[1].value).to.equal('value2');
|
|
|
|
+ expect(result[1].name).to.equal('config2');
|
|
|
|
+ });
|
|
|
|
+ it('config1=value1,config2=value2 to two configs', function () {
|
|
|
|
+ var result = App.config.textareaIntoFileConfigs.call(App.config, testData[2].configs, filename);
|
|
|
|
+ expect(result.length).to.equal(2);
|
|
|
|
+ expect(result[0].value).to.equal('value1');
|
|
|
|
+ expect(result[0].name).to.equal('config1');
|
|
|
|
+ expect(result[1].value).to.equal('value2');
|
|
|
|
+ expect(result[1].name).to.equal('config2');
|
|
|
|
+ });
|
|
|
|
+ it('config1=value1 config2=value2 to two configs', function () {
|
|
|
|
+ var result = App.config.textareaIntoFileConfigs.call(App.config, testData[3].configs, filename);
|
|
|
|
+ expect(result.length).to.equal(2);
|
|
|
|
+ expect(result[0].value).to.equal('value1');
|
|
|
|
+ expect(result[0].name).to.equal('config1');
|
|
|
|
+ expect(result[1].value).to.equal('value2');
|
|
|
|
+ expect(result[1].name).to.equal('config2');
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|