UNPKG

2.81 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 "getTransformOptions" function', function () {
8 function assertObjectInReturnedExtensions () {
9 it('should have returned an object', function () {
10 this.returned_options.should.be.an.Object;
11 });
12 }
13
14 function assertCorrectOptionsReturned () {
15 it('should have returned the correct extensions', function () {
16 this.returned_options.should.eql(this.correct_test_options);
17 });
18 }
19
20 describe('when passed no options argument', function () {
21 before(function () {
22 this.correct_test_options = {};
23 this.returned_options = Stringify.getTransformOptions();
24 });
25
26 assertObjectInReturnedExtensions();
27 assertCorrectOptionsReturned();
28 });
29
30 describe('when passed an array of file-extensions as an options argument', function () {
31 before(function () {
32 var test_extensions = ['.cookie', '.cupcake', '.halibut'];
33
34 this.correct_test_options = { appliesTo: { includeExtensions: test_extensions } };
35 this.returned_options = Stringify.getTransformOptions(test_extensions);
36 });
37
38 assertObjectInReturnedExtensions();
39 assertCorrectOptionsReturned();
40 });
41
42 describe('when passed an object with an "extensions" array property as an options argument', function () {
43 before(function () {
44 var test_extensions = ['.trains', '.are', '.fun'];
45
46 this.correct_test_options = { appliesTo: { includeExtensions: test_extensions }, space: 'ship' };
47
48 var test_options = { extensions: test_extensions, space: 'ship' };
49
50 this.returned_options = Stringify.getTransformOptions(test_options);
51 });
52
53 assertObjectInReturnedExtensions();
54 assertCorrectOptionsReturned();
55 });
56
57 describe('when passed an object with an "extensions" Browserify array property as an options argument', function () {
58 before(function () {
59 var test_extensions = ['.trains', '.are', '.fun'];
60
61 this.correct_test_options = { appliesTo: { includeExtensions: test_extensions }, space: 'ship' };
62
63 var test_options = { extensions: { _: test_extensions }, space: 'ship' };
64
65 this.returned_options = Stringify.getTransformOptions(test_options);
66 });
67
68 assertObjectInReturnedExtensions();
69 assertCorrectOptionsReturned();
70 });
71
72 describe('when passed an object with an "appliesTo" object property as an options argument', function () {
73 before(function () {
74 this.correct_test_options = { appliesTo: { files: ['.ant', '.frog', '.panda'] }, fruit: 'bowl' };
75
76 this.returned_options = Stringify.getTransformOptions(this.correct_test_options);
77 });
78
79 assertObjectInReturnedExtensions();
80 assertCorrectOptionsReturned();
81 });
82});