diff --git a/test/examples.js b/test/examples.js index 4410830..9a53249 100644 --- a/test/examples.js +++ b/test/examples.js @@ -37,7 +37,9 @@ describe('Examples', function() { var example = path.basename(e, path.extname(e)); // Determine name of the exmaple var tempDir = path.join(__dirname, 'temp'); - fs.mkdirSync(tempDir); + try { + fs.mkdirSync(tempDir); + } catch (err) {} // Test wres render with YAML and JSON formats of each example it(example + ' (yaml file) renders without error', function() { diff --git a/test/formats.js b/test/formats.js new file mode 100644 index 0000000..fd8b344 --- /dev/null +++ b/test/formats.js @@ -0,0 +1,48 @@ +/** + * Copyright 2015 Cm_Star. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); +var wres = require('..'); + +describe('Formats', function() { + fs.readdirSync(path.resolve(__dirname, '../formats')).forEach(function (e) { + + // Load each format + var formatFile = path.resolve(__dirname, '../formats/' + e); + var format = path.basename(e, path.extname(e)); // Determine name of the exmaple + var template = path.resolve(__dirname, '../examples/template.yml'); + + // Test file, pre-defined and string types of formats + it(format + ' (file) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, formatFile, null, null); + }); + }); + it(format + ' (pre-defined) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, format, null, null); + }); + }); + it(format + ' (string) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, fs.readFileSync(formatFile, 'utf8'), null, null); + }); + }); + }); +}); diff --git a/test/themes.js b/test/themes.js new file mode 100644 index 0000000..4be2e30 --- /dev/null +++ b/test/themes.js @@ -0,0 +1,48 @@ +/** + * Copyright 2015 Cm_Star. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var assert = require('assert'); +var wres = require('..'); + +describe('Themes', function() { + fs.readdirSync(path.resolve(__dirname, '../themes')).forEach(function (e) { + + // Load each format + var themeFile = path.resolve(__dirname, '../themes/' + e); + var theme = path.basename(e, path.extname(e)); // Determine name of the exmaple + var template = path.resolve(__dirname, '../examples/template.yml'); + + // Test file, pre-defined and string types of formats + it(theme + ' (file) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, null, themeFile, null); + }); + }); + it(theme + ' (pre-defined) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, null, theme, null); + }); + }); + it(theme + ' (string) renders without error', function() { + assert.doesNotThrow(function() { + wres.render(template, null, fs.readFileSync(themeFile, 'utf8'), null); + }); + }); + }); +});