Tom MacWright 11d9045a00 Native Flow, use Jest (#767)
* build: Use Flow syntax without comments.

We're switching to Flow annotations - not Flow comments. This
gives documentation.js the ability to self-document without
JSDoc types and improves our compatibility with tools like
prettier.

Fixes #729. Fixes #709
2017-05-08 20:46:21 -04:00

47 lines
1.2 KiB
JavaScript

var path = require('path'), shallow = require('../../../src/input/shallow');
test('shallow deps', async function() {
const deps = await shallow(
[path.resolve(path.join(__dirname, '../../fixture/es6.input.js'))],
{}
);
expect(deps.length).toBe(1);
expect(deps[0]).toBeTruthy();
});
test('shallow deps multi', async function() {
const deps = await shallow(
[
path.resolve(path.join(__dirname, '../../fixture/es6.input.js')),
path.resolve(path.join(__dirname, '../../fixture/simple.input.js'))
],
{}
);
expect(deps.length).toBe(2);
expect(deps[0]).toBeTruthy();
});
test('shallow deps directory', async function() {
const deps = await shallow(
[path.resolve(path.join(__dirname, '../../fixture/html'))],
{}
);
expect(deps.length).toBe(1);
expect(deps[0].file.match(/input.js/)).toBeTruthy();
});
test('throws on non-string or object input', function() {
return shallow([true], {}).catch(err => {
expect(err.message).toBe('Indexes should be either strings or objects');
});
});
test('shallow deps literal', async function() {
var obj = {
file: 'foo.js',
source: '//bar'
};
const deps = await shallow([obj], {});
expect(deps[0]).toBe(obj);
});