UNPKG

1.8 kBJavaScriptView Raw
1/* jshint expr: true */
2/* global describe: false, it: false, before: false */
3'use strict';
4require('should');
5var Stringify = require('../index');
6
7describe('the "getExtensions" function', function () {
8 function assertNonEmptyArrayInReturnedExtensions () {
9 it('should have returned a non-empty array', function () {
10 this.returned_extensions.should.be.an.Array;
11 this.returned_extensions.should.not.be.empty;
12 });
13 }
14
15 function assertCorrectExtensionsReturned () {
16 it('should have returned the correct extensions', function () {
17 this.returned_extensions.should.eql(this.correct_test_extensions);
18 });
19 }
20
21 describe('when passed no options argument', function () {
22 before(function () {
23 this.correct_test_extensions = Stringify.TRANSFORM_OPTIONS.includeExtensions;
24 this.returned_extensions = Stringify.getExtensions();
25 });
26
27 assertNonEmptyArrayInReturnedExtensions();
28 assertCorrectExtensionsReturned();
29 });
30
31 describe('when passed an array of file-extensions as an options argument', function () {
32 before(function () {
33 this.correct_test_extensions = ['.cookie', '.cupcake', '.halibut'];
34 this.returned_extensions = Stringify.getExtensions(this.correct_test_extensions);
35 });
36
37 assertNonEmptyArrayInReturnedExtensions();
38 assertCorrectExtensionsReturned();
39 });
40
41 describe('when passed an object with an "extensions" array property as an options argument', function () {
42 before(function () {
43 this.correct_test_extensions = ['.trains', '.are', '.fun'];
44
45 var test_object = { extensions: this.correct_test_extensions };
46
47 this.returned_extensions = Stringify.getExtensions(test_object);
48 });
49
50 assertNonEmptyArrayInReturnedExtensions();
51 assertCorrectExtensionsReturned();
52 });
53});