Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Add test scripts for all types of input (file, pre-defined, string)
Browse files Browse the repository at this point in the history
  • Loading branch information
snugfox committed Dec 7, 2015
1 parent 33df3a7 commit 59feeb2
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
48 changes: 48 additions & 0 deletions test/formats.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
});
48 changes: 48 additions & 0 deletions test/themes.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
});

0 comments on commit 59feeb2

Please sign in to comment.