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