const path = require('path');
const { expect } = require('chai');
const utils = require('./utils');
const loader = require('../index');
const YAML = require('js-yaml');

describe('loader output', () => {

    it('default output should be an exported javascript object', () => {
        return utils.context('./yaml/plain.yml', { importRoot: true })
            .then(context => utils.load(context, loader))
            .then(({ result, deps }) => {
                expect(result).eql(`module.exports = ${JSON.stringify({
                    hello: 'world',
                    test: 'a',
                })};`);
            });
    });

    it('allow json output', () => {
        return utils.context('./yaml/plain.yml', { importRoot: true, output: 'json' })
            .then(context => utils.load(context, loader))
            .then(({ result, deps }) => {
                expect(result).eql(JSON.stringify({
                    hello: 'world',
                    test: 'a',
                }));
            });
    });

    it('allow yaml output', () => {
        return utils.context('./yaml/plain.yml', { importRoot: true, output: 'yaml' })
            .then(context => utils.load(context, loader))
            .then(({ result, deps }) => {
                expect(result).eql(YAML.safeDump({
                    hello: 'world',
                    test: 'a',
                }));
            });
    });
});

@@ -235,11 +235,8 @@
  be 
-an 
 expo
@@ -245,17 +245,9 @@
 ed j
-avascript
+s
  obj

test naming