<commit_before>import chai from 'chai';
import fs from 'fs';
import { GCodeToolpath } from '../lib/';
import _ from 'lodash';

const expect = chai.expect;
const should = chai.should();

describe('G-code Toolpath', (done) => {
    describe('Pass a null value as the first argument', (done) => {
        let gcodeToolpath = new GCodeToolpath();
        it('should call interpretText\'s callback.', (done) => {
            gcodeToolpath.interpretText(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
        it('should call interpretFile\'s callback.', (done) => {
            gcodeToolpath.interpretFile(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
        it('should call interpretStream\'s callback.', (done) => {
            gcodeToolpath.interpretStream(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
    });

    describe('Event callbacks', (done) => {
        let gcodeToolpath = new GCodeToolpath();
        gcodeToolpath
            .on('data', (data) => {
                expect(data).to.be.an('object');
            })
            .on('end', (results) => {
                expect(results).to.be.an('array');
            });

        it('should call event callbacks.', (done) => {
            gcodeToolpath.interpretFile('test/fixtures/circle.nc', (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
    });

    describe('Arc Curve: G02/G03', (done) => {

        it('Simple Radius', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/arc-r.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

        it('Helical Thread Milling', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/helical-thread-milling.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

        it('One inch circle', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/one-inch-circle.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

    });

    describe('Dwell: G4', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/dwell.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Motion: G0/G1/G2/G3/G38.2/G38.3/G38.4/G38.5/G80', (done) => {
        it('should generate tool paths for an empty object.', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G0',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/motion.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });
    });

    describe('Plane: G17/G18/G19', (done) => {

        it('should not generate tool paths with wrong plane mode.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {
                    plane: 'xx' // The plane is invalid
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-no-plane.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });

        it('should generate correct tool paths in the XY-plane (G17)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-xy-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

        it('should generate correct tool paths in the ZX-plane (G18)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G2',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G3',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-zx-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

        it('should generate correct tool paths in the YZ-plane (G19)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-yz-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

    });

    describe('Units: G20/G21', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/units.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Coordinate: G54/G55/G56/G57/G58/G59', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/coordinate.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Feed Rate: G93/G94', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/feedrate.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

});
<commit_msg>Rename interpretText to interpretString<commit_after>import chai from 'chai';
import fs from 'fs';
import { GCodeToolpath } from '../lib/';
import _ from 'lodash';

const expect = chai.expect;
const should = chai.should();

describe('G-code Toolpath', (done) => {
    describe('Pass a null value as the first argument', (done) => {
        let gcodeToolpath = new GCodeToolpath();
        it('should call interpretString\'s callback.', (done) => {
            gcodeToolpath.interpretString(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
        it('should call interpretFile\'s callback.', (done) => {
            gcodeToolpath.interpretFile(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
        it('should call interpretStream\'s callback.', (done) => {
            gcodeToolpath.interpretStream(null, (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
    });

    describe('Event callbacks', (done) => {
        let gcodeToolpath = new GCodeToolpath();
        gcodeToolpath
            .on('data', (data) => {
                expect(data).to.be.an('object');
            })
            .on('end', (results) => {
                expect(results).to.be.an('array');
            });

        it('should call event callbacks.', (done) => {
            gcodeToolpath.interpretFile('test/fixtures/circle.nc', (err, results) => {
                expect(err).to.be.okay;
                done();
            });
        });
    });

    describe('Arc Curve: G02/G03', (done) => {

        it('Simple Radius', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/arc-r.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

        it('Helical Thread Milling', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/helical-thread-milling.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

        it('One inch circle', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });

            gcodeToolpath.interpretFile('test/fixtures/one-inch-circle.nc', (err, results) => {
                // TODO: Add test case
                done();
            });
        });

    });

    describe('Dwell: G4', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/dwell.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Motion: G0/G1/G2/G3/G38.2/G38.3/G38.4/G38.5/G80', (done) => {
        it('should generate tool paths for an empty object.', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G0',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/motion.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });
    });

    describe('Plane: G17/G18/G19', (done) => {

        it('should not generate tool paths with wrong plane mode.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {
                    plane: 'xx' // The plane is invalid
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-no-plane.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });

        it('should generate correct tool paths in the XY-plane (G17)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-xy-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

        it('should generate correct tool paths in the ZX-plane (G18)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G2',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G3',
                    v1: { x: 20, y: 0, z: 0 },
                    v2: { x: 0, y: 20, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-zx-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

        it('should generate correct tool paths in the YZ-plane (G19)', (done) => {
            const expectedToolpaths = [
                {
                    motion: 'G1',
                    v1: { x: 0, y: 0, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G2',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                },
                {
                    motion: 'G1',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 0, y: 0, z: 20 }
                },
                {
                    motion: 'G3',
                    v1: { x: 0, y: 20, z: 0 },
                    v2: { x: 20, y: 0, z: 0 },
                    v0: { x: 0, y: 0, z: 0 }
                }
            ];
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                modalState: {},
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/arc-yz-plane.nc', (err, results) => {
                expect(toolpaths).to.deep.equal(expectedToolpaths);
                done();
            });
        });

    });

    describe('Units: G20/G21', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/units.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Coordinate: G54/G55/G56/G57/G58/G59', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/coordinate.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

    describe('Feed Rate: G93/G94', (done) => {
        it('should not generate tool paths.', (done) => {
            let toolpaths = [];
            let gcodeToolpath = new GCodeToolpath({
                addLine: (modalState, v1, v2) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2
                    });
                },
                addArcCurve: (modalState, v1, v2, v0) => {
                    toolpaths.push({
                        motion: modalState.motion,
                        v1: v1,
                        v2: v2,
                        v0: v0
                    });
                }
            });
            gcodeToolpath.interpretFile('test/fixtures/feedrate.nc', (err, results) => {
                expect(toolpaths).to.be.empty;
                done();
            });
        });
    });

});
<|endoftext|>


<commit_before>function test(name, path) {
    describe(name, function() {
        require(path);
    })
}

describe('#dl-module', function(done) {
    this.timeout(2 * 60000);

    // Auth
    // test('@auth/account-manager', './auth/account-manager-test');
    // test('@auth/role-manager', './auth/role-manager-test');
    //Master
    // test('@master/uom-manager', './master/uom-manager-test');
    // test('@master/supplier-manager', './master/supplier-manager-test');
    // test('@master/buyer-manager', './master/buyer-manager-test');
    // test('@master/product-manager', './master/product-manager-test');
    // test('@master/division-manager', './master/division-manager-test');
     //test('@master/unit-manager', './master/unit-manager-test');
    // test('@master/category-manager', './master/category-manager-test');
    // test('@master/currency-manager', './master/currency-manager-test');
    // test('@master/vat-manager', './master/vat-manager-test');
    // test('@master/budget-manager', './master/budget-manager-test');
    // test('@master/machine-manager', './master/machine-manager-test');
   // test('@master/thread-specification-manager', './master/thread-specification-manager-test');
   //  test('@master/uster-classification-manager', './master/uster-classification-manager-test');
    // test('@master/lot-machine-manager', './master/lot-machine-manager-test');

    // //Purchasing
    // test('@purchasing/purchase-order-manager', './purchasing/purchase-order-manager-test');
    // test('@purchasing/purchase-order-external-manager', './purchasing/purchase-order-external-manager-test');
    // test('@purchasing/delivery-order-manager', './purchasing/delivery-order-manager-test');
    // test('@purchasing/unit-receipt-note', './purchasing/unit-receipt-note-manager-test');
    // test('@purchasing/purchase-request-manager', './purchasing/purchase-request-manager-test');
    // test('@purchasing/unit-payment-price-correction-note', './purchasing/unit-payment-price-correction-note-manager-test');
    // test('@purchasing/unit-payment-order', './purchasing/unit-payment-order-test');

    // test('@purchasing/purchase-request/create', './purchasing/purchase-request/create');
    // test('@purchasing/purchase-request/post', './purchasing/purchase-request/post');
    // test('@purchasing/purchase-order/create', './purchasing/purchase-order/create');
    // test('@purchasing/purchase-order/update', './purchasing/purchase-order/update');

    //Production

    // test('@production/winding-quality-sampling-manager', './production/spinning/winding/winding-quality-sampling-manager-test');
    test('@production/winding-production-output-manager', './production/spinning/winding/winding-production-output-manager-test');

})
<commit_msg>adding test yarn conversion<commit_after>function test(name, path) {
    describe(name, function() {
        require(path);
    })
}

describe('#dl-module', function(done) {
    this.timeout(2 * 60000);

    // Auth
    // test('@auth/account-manager', './auth/account-manager-test');
    // test('@auth/role-manager', './auth/role-manager-test');
    //Master
    // test('@master/uom-manager', './master/uom-manager-test');
    // test('@master/supplier-manager', './master/supplier-manager-test');
    // test('@master/buyer-manager', './master/buyer-manager-test');
    // test('@master/product-manager', './master/product-manager-test');
    // test('@master/division-manager', './master/division-manager-test');
     //test('@master/unit-manager', './master/unit-manager-test');
    // test('@master/category-manager', './master/category-manager-test');
    // test('@master/currency-manager', './master/currency-manager-test');
    // test('@master/vat-manager', './master/vat-manager-test');
    // test('@master/budget-manager', './master/budget-manager-test');
    // test('@master/machine-manager', './master/machine-manager-test');
   // test('@master/thread-specification-manager', './master/thread-specification-manager-test');
   //  test('@master/uster-classification-manager', './master/uster-classification-manager-test');
     test('@master/lot-machine-manager', './master/lot-machine-manager-test');
    //test('@master/yarn-equivalent-conversion-manager', './master/yarn-equivalent-conversion-manager-test');

    // //Purchasing
    // test('@purchasing/purchase-order-manager', './purchasing/purchase-order-manager-test');
    // test('@purchasing/purchase-order-external-manager', './purchasing/purchase-order-external-manager-test');
    // test('@purchasing/delivery-order-manager', './purchasing/delivery-order-manager-test');
    // test('@purchasing/unit-receipt-note', './purchasing/unit-receipt-note-manager-test');
    // test('@purchasing/purchase-request-manager', './purchasing/purchase-request-manager-test');
    // test('@purchasing/unit-payment-price-correction-note', './purchasing/unit-payment-price-correction-note-manager-test');
    // test('@purchasing/unit-payment-order', './purchasing/unit-payment-order-test');

    // test('@purchasing/purchase-request/create', './purchasing/purchase-request/create');
    // test('@purchasing/purchase-request/post', './purchasing/purchase-request/post');
    // test('@purchasing/purchase-order/create', './purchasing/purchase-order/create');
    // test('@purchasing/purchase-order/update', './purchasing/purchase-order/update');

    //Production

    // test('@production/winding-quality-sampling-manager', './production/spinning/winding/winding-quality-sampling-manager-test');
    //test('@production/winding-production-output-manager', './production/spinning/winding/winding-production-output-manager-test');

})
<|endoftext|>


<commit_before>'use strict'

const os = require('os')
const path = require('path')
const assert = require('chai').assert
const uuid = require('uuid/v4')
const index = require('./../src/index')

const fsify = require('fsify')({
	cwd: os.tmpdir()
})

describe('index()', function() {

	it('should return an error when called without a filePath', async function() {

		return index().then((result) => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.strictEqual(err.message, `'filePath' must be a string`)

		})

	})

	it('should return an error when called with invalid options', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`
			}
		])

		return index(structure[0].name, '').then((result) => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.strictEqual(err.message, `'opts' must be undefined, null or an object`)

		})

	})

	it('should return an error when called with a fictive filePath', async function() {

		return index(`${ uuid() }.njk`).then((result) => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.isNotNull(err)
			assert.isDefined(err)

		})

	})

	it('should return an error when called with invalid Nunjucks', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ + }}'
			}
		])

		return index(structure[0].name).then((result) => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.isNotNull(err)
			assert.isDefined(err)

		})

	})

	it('should load Nunjucks and transform it to HTML', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ environment }}'
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, 'dev')

	})

	it('should load Nunjucks from a relative path and transform it to HTML', async function() {

		const folderName = uuid()
		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.DIRECTORY,
				name: folderName,
				contents: [
					{
						type: fsify.FILE,
						name: fileName,
						contents: 'value'
					}
				]
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% include './${ folderName }/${ fileName }' %}`
			}
		])

		const file = path.relative(process.cwd(), structure[1].name)
		const result = await index(file)

		assert.strictEqual(result, structure[0].contents[0].contents)

	})

	it('should load Nunjucks and transform it to HTML with custom global data', async function() {

		const data = { key: 'value' }

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ key }}'
			}
		])

		const result = await index(structure[0].name, { data })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with external custom global data', async function() {

		const data = { key: 'value' }

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.json`,
				contents: JSON.stringify(data)
			}
		])

		const result = await index(structure[0].name, { data: structure[1].name })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom inject tag but without global data', async function() {

		const data = { key: 'value' }
		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: fileName,
				contents: '{{ key }}{{ environment }}'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% inject '${ fileName }', ${ JSON.stringify(data) } %}`
			}
		])

		const result = await index(structure[1].name, { src: path.dirname(structure[1].name) })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom inject tag called without data', async function() {

		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: fileName,
				contents: 'value'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% inject '${ fileName }' %}`
			}
		])

		const result = await index(structure[1].name, { src: path.dirname(structure[1].name) })

		assert.strictEqual(result, structure[0].contents)

	})

	it('should load Nunjucks and transform it to HTML with custom shy filter', async function() {

		const target = 'Long head|lines are awe|some'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{{ '${ target }' | shy }}`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, 'Long headlines are awesome')

	})

	it('should load Nunjucks and transform it to HTML with custom shy filter on an undefined variable', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{{ target | shy }}`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, '')

	})

	it('should load Nunjucks and transform it to optimized HTML when optimization enabled', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ environment }}'
			}
		])

		const result = await index(structure[0].name, { optimize: true })

		assert.strictEqual(result, 'prod')

	})

	it('should load Nunjucks and transform it to HTML with a custom prepend', async function() {

		const prepend = 'value'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: ''
			}
		])

		const result = await index(structure[0].name, { prepend })

		assert.strictEqual(result, prepend)

	})

	it('should load Nunjucks and transform it to HTML with a custom append', async function() {

		const append = 'value'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: ''
			}
		])

		const result = await index(structure[0].name, { append })

		assert.strictEqual(result, append)

	})

	it('should load Nunjucks and transform it to HTML with custom data from a JS data file', async function() {

		const data = { key: 'value' }
		const fileName = uuid()

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ fileName }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ fileName }.data.js`,
				contents: `module.exports = ${ JSON.stringify(data) }`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom data from a JSON data file', async function() {

		const data = { key: 'value' }
		const fileName = uuid()

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ fileName }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ fileName }.data.json`,
				contents: JSON.stringify(data)
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, data.key)

	})

	describe('.in()', function() {

		it('should be a function', function() {

			assert.isFunction(index.in)

		})

		it('should return a default extension', function() {

			assert.strictEqual(index.in(), '.njk')

		})

		it('should return a default extension when called with invalid options', function() {

			assert.strictEqual(index.in(''), '.njk')

		})

		it('should return a custom extension when called with options', function() {

			assert.strictEqual(index.in({ in: '.xml' }), '.xml')

		})

	})

	describe('.out()', function() {

		it('should be a function', function() {

			assert.isFunction(index.in)

		})

		it('should return a default extension', function() {

			assert.strictEqual(index.out(), '.html')

		})

		it('should return a default extension when called with invalid options', function() {

			assert.strictEqual(index.out(''), '.html')

		})

		it('should return a custom extension when called with options', function() {

			assert.strictEqual(index.out({ out: '.xml' }), '.xml')

		})

	})

	describe('.cache', function() {

		it('should be an array', function() {

			assert.isArray(index.cache)

		})

	})

})<commit_msg>Removed unused parameter<commit_after>'use strict'

const os = require('os')
const path = require('path')
const assert = require('chai').assert
const uuid = require('uuid/v4')
const index = require('./../src/index')

const fsify = require('fsify')({
	cwd: os.tmpdir()
})

describe('index()', function() {

	it('should return an error when called without a filePath', async function() {

		return index().then(() => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.strictEqual(err.message, `'filePath' must be a string`)

		})

	})

	it('should return an error when called with invalid options', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`
			}
		])

		return index(structure[0].name, '').then(() => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.strictEqual(err.message, `'opts' must be undefined, null or an object`)

		})

	})

	it('should return an error when called with a fictive filePath', async function() {

		return index(`${ uuid() }.njk`).then(() => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.isNotNull(err)
			assert.isDefined(err)

		})

	})

	it('should return an error when called with invalid Nunjucks', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ + }}'
			}
		])

		return index(structure[0].name).then(() => {

			throw new Error('Returned without error')

		}, (err) => {

			assert.isNotNull(err)
			assert.isDefined(err)

		})

	})

	it('should load Nunjucks and transform it to HTML', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ environment }}'
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, 'dev')

	})

	it('should load Nunjucks from a relative path and transform it to HTML', async function() {

		const folderName = uuid()
		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.DIRECTORY,
				name: folderName,
				contents: [
					{
						type: fsify.FILE,
						name: fileName,
						contents: 'value'
					}
				]
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% include './${ folderName }/${ fileName }' %}`
			}
		])

		const file = path.relative(process.cwd(), structure[1].name)
		const result = await index(file)

		assert.strictEqual(result, structure[0].contents[0].contents)

	})

	it('should load Nunjucks and transform it to HTML with custom global data', async function() {

		const data = { key: 'value' }

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ key }}'
			}
		])

		const result = await index(structure[0].name, { data })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with external custom global data', async function() {

		const data = { key: 'value' }

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.json`,
				contents: JSON.stringify(data)
			}
		])

		const result = await index(structure[0].name, { data: structure[1].name })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom inject tag but without global data', async function() {

		const data = { key: 'value' }
		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: fileName,
				contents: '{{ key }}{{ environment }}'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% inject '${ fileName }', ${ JSON.stringify(data) } %}`
			}
		])

		const result = await index(structure[1].name, { src: path.dirname(structure[1].name) })

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom inject tag called without data', async function() {

		const fileName = `${ uuid() }.njk`

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: fileName,
				contents: 'value'
			},
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{% inject '${ fileName }' %}`
			}
		])

		const result = await index(structure[1].name, { src: path.dirname(structure[1].name) })

		assert.strictEqual(result, structure[0].contents)

	})

	it('should load Nunjucks and transform it to HTML with custom shy filter', async function() {

		const target = 'Long head|lines are awe|some'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{{ '${ target }' | shy }}`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, 'Long headlines are awesome')

	})

	it('should load Nunjucks and transform it to HTML with custom shy filter on an undefined variable', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: `{{ target | shy }}`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, '')

	})

	it('should load Nunjucks and transform it to optimized HTML when optimization enabled', async function() {

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: '{{ environment }}'
			}
		])

		const result = await index(structure[0].name, { optimize: true })

		assert.strictEqual(result, 'prod')

	})

	it('should load Nunjucks and transform it to HTML with a custom prepend', async function() {

		const prepend = 'value'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: ''
			}
		])

		const result = await index(structure[0].name, { prepend })

		assert.strictEqual(result, prepend)

	})

	it('should load Nunjucks and transform it to HTML with a custom append', async function() {

		const append = 'value'

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ uuid() }.njk`,
				contents: ''
			}
		])

		const result = await index(structure[0].name, { append })

		assert.strictEqual(result, append)

	})

	it('should load Nunjucks and transform it to HTML with custom data from a JS data file', async function() {

		const data = { key: 'value' }
		const fileName = uuid()

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ fileName }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ fileName }.data.js`,
				contents: `module.exports = ${ JSON.stringify(data) }`
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, data.key)

	})

	it('should load Nunjucks and transform it to HTML with custom data from a JSON data file', async function() {

		const data = { key: 'value' }
		const fileName = uuid()

		const structure = await fsify([
			{
				type: fsify.FILE,
				name: `${ fileName }.njk`,
				contents: '{{ key }}'
			},
			{
				type: fsify.FILE,
				name: `${ fileName }.data.json`,
				contents: JSON.stringify(data)
			}
		])

		const result = await index(structure[0].name)

		assert.strictEqual(result, data.key)

	})

	describe('.in()', function() {

		it('should be a function', function() {

			assert.isFunction(index.in)

		})

		it('should return a default extension', function() {

			assert.strictEqual(index.in(), '.njk')

		})

		it('should return a default extension when called with invalid options', function() {

			assert.strictEqual(index.in(''), '.njk')

		})

		it('should return a custom extension when called with options', function() {

			assert.strictEqual(index.in({ in: '.xml' }), '.xml')

		})

	})

	describe('.out()', function() {

		it('should be a function', function() {

			assert.isFunction(index.in)

		})

		it('should return a default extension', function() {

			assert.strictEqual(index.out(), '.html')

		})

		it('should return a default extension when called with invalid options', function() {

			assert.strictEqual(index.out(''), '.html')

		})

		it('should return a custom extension when called with options', function() {

			assert.strictEqual(index.out({ out: '.xml' }), '.xml')

		})

	})

	describe('.cache', function() {

		it('should be an array', function() {

			assert.isArray(index.cache)

		})

	})

})<|endoftext|>


<commit_before>const assert = require('assert');

const mehdown = require('../lib');

describe('email', function() {
    it('email address', function(done) {
        mehdown.render('email me at whatever@somewhere.com if you are not a meanie.', function(err, html) {
            assert.equal(html, '
email me at whatever@somewhere.com if you are not a meanie.
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/35
    it('email addresses with periods should be linked correctly', function(done) {
        mehdown.render('firstname.lastname@example.com', function(err, html) {
            assert.equal(html, '
firstname.lastname@example.com
');
            done();
        });
    });
});

describe('links', function() {
    it('http://example.com', function(done) {
        mehdown.render('http://example.com', function(err, html) {
            assert.equal(html, '
http://example.com
');
            done();
        });
    });

    it('[example.com](http://example.com)', function(done) {
        mehdown.render('[example.com](http://example.com)', function(err, html) {
            assert.equal(html, '
example.com
');
            done();
        });
    });

    it('[see example.com here](http://example.com)', function(done) {
        mehdown.render('[see example.com here](http://example.com)', function(err, html) {
            assert.equal(html, '
see example.com here
');
            done();
        });
    });

    it('[see http://example.com here](http://example.com)', function(done) {
        mehdown.render('[see http://example.com here](http://example.com)', function(err, html) {
            assert.equal(html, '
see http://example.com here
');
            done();
        });
    });

    it('[leavemealone.com](http://leavemealone.com) but linkme.com', function(done) {
        mehdown.render('[leavemealone.com](http://leavemealone.com) but linkme.com', function(err, html) {
            assert.equal(html, '
leavemealone.com but linkme.com
');
            done();
        });
    });

    it('[example.com](http://example.com "go to example.com")', function(done) {
        mehdown.render('[example.com](http://example.com "go to example.com")', function(err, html) {
            assert.equal(html, '
example.com
');
            done();
        });
    });

    it('simple domain', function(done) {
        mehdown.render('stuff google.com more stuff', function(err, html) {
            assert.equal(html, '
stuff google.com more stuff
');
            done();
        });
    });

    it('domain with path', function(done) {
        mehdown.render('mediocre.com/forum/topics/american-parties', function(err, html) {
            assert.equal(html, '
mediocre.com/forum/topics/american-parties
');
            done();
        });
    });

    it('domain with query string', function(done) {
        mehdown.render('google.com/search?q=domain', function(err, html) {
            assert.equal(html, '
google.com/search?q=domain
');
            done();
        });
    });

    it('.horse is a TLD', function(done) {
        mehdown.render('https://drone.horse', function(err, html) {
            assert.equal(html, '
https://drone.horse
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/6
    it('URLs with underscores should not lose the underscores', function(done) {
        mehdown.render('https://example.com/_/status/416050320272551936', function(err, html) {
            assert.equal(html, '
https://example.com/_/status/416050320272551936
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/29
    it('should not link two, four, or five consecutive periods', function(done) {
        mehdown.render('Awww....I always wanted my own baby elephant.', function(err, html) {
            assert.equal(html, '
Awww…I always wanted my own baby elephant.
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/30
    it('should link URLs with @ characters', function(done) {
        mehdown.render('https://meh.com/@mediocrebot', function(err, html) {
            assert.equal(html, '
https://meh.com/@mediocrebot
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/39
    it('URLs that happen to have Emoji shortnames should be linked correctly', function(done) {
        mehdown.render('http://www.ebay.com/itm/GOgroove-BlueSYNC-OR3-Portable-Wireless-Bluetooth-Speaker-Splatter-Edition-/351328294837?var=&hash=item51cccc57b5:m:mLzVeDaMfRlxsCqFiutY-aw', function(err, html) {
            assert.equal(html, '
http://www.ebay.com/itm/GOgroove-BlueSYNC-OR3-Portable-Wireless-Bluetooth-Speaker-Splatter-Edition-/351328294837?var=&hash=item51cccc57b5:m:mLzVeDaMfRlxsCqFiutY-aw
');
            done();
        });
    });
});

describe('newlines', function() {
    it('\\n', function(done) {
        mehdown.render('a\nb\nc\n', function(err, html) {
            assert.equal(html, '
a
\nb
\nc
');
            done();
        });
    });

    it('\\r\\n', function(done) {
        mehdown.render('a\r\nb\r\nc\r\n', function(err, html) {
            assert.equal(html, '
a
\nb
\nc
');
            done();
        });
    });

    it('
', function(done) {
        mehdown.render('- a\n- b\n- c', function(err, html) {
            assert.equal(html, '
\n
a
\n
b
\n
c
\n
');
            done();
        });
    });

    it('
', function(done) {
        mehdown.render('> Alone.\n>\n> Yes, that\'s the key word, the most awful word in the English tonque. Murder doesn\'t hold a candle to it, and hell is only a poor synonym.\n> - Stephen King', function(err, html) {
            assert.equal(html, '
\n
Alone.
\n
Yes, that’s the key word, the most awful word in the English tonque. Murder doesn’t hold a candle to it, and hell is only a poor synonym.
\n
\n
Stephen King
\n
\n
');
            done();
        });
    });
});

describe('strikethrough', function() {
    it('~~', function(done) {
        mehdown.render('~~strikethrough~~', function(err, html) {
            assert.equal(html, '
<s>strikethrough</s>
');
            done();
        });
    });
});

describe.skip('headers', function() {
    it('adds ids for anchors', function() {
        var text = mehdown.parse('
What is meh
');
        assert.equal(text, '
What is meh
');
    });

    it('appends suffix to id', function() {
        var text = mehdown.parse('
What is meh
', { suffix: '012fed' });
        assert.equal(text, '
What is meh
');
    });

    it('handle header text with non alpha-numeric characters', function() {
        var text = mehdown.parse('
What.is!meh?
', { suffix: '0.1!2?f..e!!d??' });
        assert.equal(text, '
What.is!meh?
');
    });

    it('handle header text with multiple spaces', function() {
        var text = mehdown.parse('
What. is ! meh     ?
', { suffix: '0. 1! 2?f. . e! !d? ?' });
        assert.equal(text, '
What. is ! meh     ?
');
    });

    it('handle suffix with non alpha-numeric characters', function() {
        var text = mehdown.parse('
a- -b?c
', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
        assert.equal(text, '
a- -b?c
');
    });

    it('collapse multiple hyphens', function() {
        var text = mehdown.parse('
-- - What - - is --- -   - meh - - -
', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
        assert.equal(text, '
-- - What - - is --- -   - meh - - -
');
    });

    it('handle header with other tags inside', function() {
        var text = mehdown.parse('
bold
');
        assert.equal(text, '
bold
');
    });
});

describe.skip('YouTube URLs', function() {
    it('http://www.youtube.com/watch?v=kU9MuM4lP18', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?v=kU9MuM4lP18
');
        assert.equal(text, '

');
    });

    it('http://www.youtube.com/watch?v=kU9MuM4lP18 http://www.youtube.com/watch?v=eGDBR2L5kzI', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?v=kU9MuM4lP18
http://www.youtube.com/watch?v=eGDBR2L5kzI
');
        assert.equal(text, '

');
    });

    it('http://www.youtube.com/watch?feature=player_embedded&v=zIEIvi2MuEk', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?feature=player_embedded&v=zIEIvi2MuEk
');
        assert.equal(text, '

');
    });

    it('`&` instead of `&` in URL', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?feature=player_embedded&v=zIEIvi2MuEk
');
        assert.equal(text, '

');
    });

    it('http://www.youtube.com/watch?v=kU9MuM4lP18&start=10', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?v=kU9MuM4lP18&start=10
');
        assert.equal(text, '

');
    });

    it('http://www.youtube.com/watch?v=kU9MuM4lP18&start=10', function() {
        var text = mehdown.parse('
http://www.youtube.com/watch?v=kU9MuM4lP18&start=10
');
        assert.equal(text, '

');
    });
});
<commit_msg>another blockquote newline test<commit_after>const assert = require('assert');

const mehdown = require('../lib');

describe('email', function() {
    it('email address', function(done) {
        mehdown.render('email me at whatever@somewhere.com if you are not a meanie.', function(err, html) {
            assert.equal(html, '
email me at whatever@somewhere.com if you are not a meanie.
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/35
    it('email addresses with periods should be linked correctly', function(done) {
        mehdown.render('firstname.lastname@example.com', function(err, html) {
            assert.equal(html, '
firstname.lastname@example.com
');
            done();
        });
    });
});

describe('links', function() {
    it('http://example.com', function(done) {
        mehdown.render('http://example.com', function(err, html) {
            assert.equal(html, '
http://example.com
');
            done();
        });
    });

    it('[example.com](http://example.com)', function(done) {
        mehdown.render('[example.com](http://example.com)', function(err, html) {
            assert.equal(html, '
example.com
');
            done();
        });
    });

    it('[see example.com here](http://example.com)', function(done) {
        mehdown.render('[see example.com here](http://example.com)', function(err, html) {
            assert.equal(html, '
see example.com here
');
            done();
        });
    });

    it('[see http://example.com here](http://example.com)', function(done) {
        mehdown.render('[see http://example.com here](http://example.com)', function(err, html) {
            assert.equal(html, '
see http://example.com here
');
            done();
        });
    });

    it('[leavemealone.com](http://leavemealone.com) but linkme.com', function(done) {
        mehdown.render('[leavemealone.com](http://leavemealone.com) but linkme.com', function(err, html) {
            assert.equal(html, '
leavemealone.com but linkme.com
');
            done();
        });
    });

    it('[example.com](http://example.com "go to example.com")', function(done) {
        mehdown.render('[example.com](http://example.com "go to example.com")', function(err, html) {
            assert.equal(html, '
example.com
');
            done();
        });
    });

    it('simple domain', function(done) {
        mehdown.render('stuff google.com more stuff', function(err, html) {
            assert.equal(html, '
stuff google.com more stuff
');
            done();
        });
    });

    it('domain with path', function(done) {
        mehdown.render('mediocre.com/forum/topics/american-parties', function(err, html) {
            assert.equal(html, '
mediocre.com/forum/topics/american-parties
');
            done();
        });
    });

    it('domain with query string', function(done) {
        mehdown.render('google.com/search?q=domain', function(err, html) {
            assert.equal(html, '
google.com/search?q=domain
');
            done();
        });
    });

    it('.horse is a TLD', function(done) {
        mehdown.render('https://drone.horse', function(err, html) {
            assert.equal(html, '
https://drone.horse
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/6
    it('URLs with underscores should not lose the underscores', function(done) {
        mehdown.render('https://example.com/_/status/416050320272551936', function(err, html) {
            assert.equal(html, '
https://example.com/_/status/416050320272551936
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/29
    it('should not link two, four, or five consecutive periods', function(done) {
        mehdown.render('Awww....I always wanted my own baby elephant.', function(err, html) {
            assert.equal(html, '
Awww…I always wanted my own baby elephant.
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/30
    it('should link URLs with @ characters', function(done) {
        mehdown.render('https://meh.com/@mediocrebot', function(err, html) {
            assert.equal(html, '
https://meh.com/@mediocrebot
');
            done();
        });
    });

    // https://github.com/mediocre/mehdown/issues/39
    it('URLs that happen to have Emoji shortnames should be linked correctly', function(done) {
        mehdown.render('http://www.ebay.com/itm/GOgroove-BlueSYNC-OR3-Portable-Wireless-Bluetooth-Speaker-Splatter-Edition-/351328294837?var=&hash=item51cccc57b5:m:mLzVeDaMfRlxsCqFiutY-aw', function(err, html) {
            assert.equal(html, '
http://www.ebay.com/itm/GOgroove-BlueSYNC-OR3-Portable-Wireless-Bluetooth-Speaker-Splatter-Edition-/351328294837?var=&hash=item51cccc57b5:m:mLzVeDaMfRlxsCqFiutY-aw
');
            done();
        });
    });
});

describe('newlines', function() {
    it('\\n', function(done) {
        mehdown.render('a\nb\nc\n', function(err, html) {
            assert.equal(html, '
a
\nb
\nc
');
            done();
        });
    });

    it('\\r\\n', function(done) {
        mehdown.render('a\r\nb\r\nc\r\n', function(err, html) {
            assert.equal(html, '
a
\nb
\nc
');
            done();
        });
    });

    it('
', function(done) {
        mehdown.render('- a\n- b\n- c', function(err, html) {
            assert.equal(html, '
\n
a
\n
b
\n
c
\n
');
            done();
        });
    });

    it('
', function(done) {
        mehdown.render('> Alone.\n>\n> Yes, that\'s the key word, the most awful word in the English tonque. Murder doesn\'t hold a candle to it, and hell is only a poor synonym.\n> - Stephen King', function(err, html) {
            assert.equal(html, '
\n
Alone.
\n
Yes, that’s the key word, the most awful word in the English tonque. Murder doesn’t hold a candle to it, and hell is only a poor synonym.
\n
\n
Stephen King
\n
\n
');
            done();
        });
    });

    it('
', function(done) {
        mehdown.render('> \'cause i broke my flippin\' hand yesterday playing racquetball, that\'s\n> why, and if any of you capitalization thought police give me any\n> flames about it, or if i get one lousy letter telling me how YOU were\n> able to hit the shift key with your nose, i\'m gonna get you, YOU\n> TURKEYS!!!\n> I\'M GONNA WRITE YOUR MOTHERS!!!\n> I\'M GONNA PUNCH OUT YOUR SISTERS!!!!\n> I\'M GONNA GET YOU IF IT TAKES ME FOREVER!!!', function(err, html) {
            assert.equal(html, '
\n
‘cause i broke my flippin’ hand yesterday playing racquetball, that’s
\nwhy, and if any of you capitalization thought police give me any
\nflames about it, or if i get one lousy letter telling me how YOU were
\nable to hit the shift key with your nose, i’m gonna get you, YOU
\nTURKEYS!!!
\nI’M GONNA WRITE YOUR MOTHERS!!!
\nI’M GONNA PUNCH OUT YOUR SISTERS!!!
\nI’M GONNA GET YOU IF IT TAKES ME FOREVER!!!
\n
');
            done();
        });
    });
});

describe('strikethrough', function() {
    it('~~', function(done) {
        mehdown.render('~~strikethrough~~', function(err, html) {
            assert.equal(html, '
<s>strikethrough</s>
');
            done();
        });
    });
});

describe.skip('headers', function() {
    it('adds ids for anchors', function() {
        var text = mehdown.parse('
What is meh
');
        assert.equal(text, '
What is meh
');
    });

    it('appends suffix to id', function() {
        var text = mehdown.parse('
What is meh
', { suffix: '012fed' });
        assert.equal(text, '
What is meh
');
    });

    it('handle header text with non alpha-numeric characters', function() {
        var text = mehdown.parse('
What.is!meh?
', { suffix: '0.1!2?f..e!!d??' });
        assert.equal(text, '
What.is!meh?
');
    });

    it('handle header text with multiple spaces', function() {
        var text = mehdown.parse('
What. is ! meh     ?
', { suffix: '0. 1! 2?f. . e! !d? ?' });
        assert.equal(text, '
What. is ! meh     ?
');
    });

    it('handle suffix with non alpha-numeric characters', function() {
        var text = mehdown.parse('
a- -b?c
', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
        assert.equal(text, '
a- -b?c
');
    });

    it('collapse multiple hyphens', function() {
        var text = mehdown.parse('
-- - What - - is --- -   - meh - - -
', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
        assert.equal(text, '
-- - What - - is --- -   - meh - - -
');
    });

    it('handle header with other tags inside', function() {
        var text = mehdown.parse('
bold
');
        assert.equal(text, '
bold
');
    });
});
<|endoftext|>


<commit_before>/* eslint-env mocha */
'use strict';

const sinon = require('sinon');
const assert = require('assert');
const mock = require('mock-require');

const pkg = require('../package.json');
const namespace = 'test:namespace';

// Mock the debug module
const mockDebugFunction = sinon.spy();
const mockDebugModule = sinon.stub().returns(mockDebugFunction);
mockDebugModule.onCall(0, (...args) => console.log(...args));
mock('debug', mockDebugModule);

const debug = require('../lib')(namespace);
const debug_noprefix = require('../lib')(namespace, {prefix: false});

describe('Debug Module', () => {

    it('was initialized properly', () => {

        var spyCalls = mockDebugModule.getCalls();

        spyCalls.forEach(call => {
            console.log(call.args);
        });

        sinon.assert.calledTwice(mockDebugModule);
    });

    it('is called with correct namespace', () => {
        debug('testing123');
        sinon.assert.calledWith(mockDebugModule, `${pkg.name}:${namespace}`);
    });

    it('is called with correct namespace (prefix off)', () => {
        debug_noprefix('testing123');
        sinon.assert.calledWith(mockDebugModule, `${namespace}`);
    });

    it('is called with correct params (basic)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug('testing');
        sinon.assert.calledWith(mockDebugFunction, 'testing');
    });

    it('calls functions correctly (single function)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing');
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 'testing');

    });

    it('calls functions correctly (multiple arguments)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(1, 2, 3, 4, () => 5);
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 1, 2, 3, 4, 5);
    });

    it('passes correct arguments through (multiple data types)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing', {}, []);
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 'testing', {}, []);

    });

    it('doesn\'t do anything at all when debug is turned off', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = false;

        debug(() => 'testing', {}, []);
        sinon.assert.notCalled(mockDebugFunction);
    });

    it('is called twice correctly', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing', {}, []);
        debug(() => 'testing', {}, []);
        sinon.assert.calledTwice(mockDebugFunction);
    });

    it('returned undefined', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        const result = debug(() => 'testing', {}, []);
        sinon.assert.calledOnce(mockDebugFunction);
        assert(result === undefined);
    });

});
<commit_msg>remove debug code for travis<commit_after>/* eslint-env mocha */
'use strict';

const sinon = require('sinon');
const assert = require('assert');
const mock = require('mock-require');

const pkg = require('../package.json');
const namespace = 'test:namespace';

// Mock the debug module
const mockDebugFunction = sinon.spy();
const mockDebugModule = sinon.stub().returns(mockDebugFunction);
mock('debug', mockDebugModule);

const debug = require('../lib')(namespace);
const debug_noprefix = require('../lib')(namespace, {prefix: false});

describe('Debug Module', () => {

    it('was initialized properly', () => {
        sinon.assert.calledTwice(mockDebugModule);
    });

    it('is called with correct namespace', () => {
        debug('testing123');
        sinon.assert.calledWith(mockDebugModule, `${pkg.name}:${namespace}`);
    });

    it('is called with correct namespace (prefix off)', () => {
        debug_noprefix('testing123');
        sinon.assert.calledWith(mockDebugModule, `${namespace}`);
    });

    it('is called with correct params (basic)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug('testing');
        sinon.assert.calledWith(mockDebugFunction, 'testing');
    });

    it('calls functions correctly (single function)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing');
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 'testing');

    });

    it('calls functions correctly (multiple arguments)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(1, 2, 3, 4, () => 5);
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 1, 2, 3, 4, 5);
    });

    it('passes correct arguments through (multiple data types)', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing', {}, []);
        sinon.assert.calledOnce(mockDebugFunction);
        sinon.assert.calledWith(mockDebugFunction, 'testing', {}, []);

    });

    it('doesn\'t do anything at all when debug is turned off', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = false;

        debug(() => 'testing', {}, []);
        sinon.assert.notCalled(mockDebugFunction);
    });

    it('is called twice correctly', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        debug(() => 'testing', {}, []);
        debug(() => 'testing', {}, []);
        sinon.assert.calledTwice(mockDebugFunction);
    });

    it('returned undefined', () => {
        mockDebugFunction.reset();
        mockDebugFunction.enabled = true;

        const result = debug(() => 'testing', {}, []);
        sinon.assert.calledOnce(mockDebugFunction);
        assert(result === undefined);
    });

});
<|endoftext|>


<commit_before>// Dependencies
const parseUrl = require("../lib")
    , tester = require("tester")
    ;

const INPUTS = [
    [
        "http://ionicabizau.net/blog"
      , {
            protocols: [ "http" ]
          , protocol: "http"
          , port: null
          , resource: "ionicabizau.net"
          , user: ""
          , pathname: "/blog"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "//ionicabizau.net/foo.js"
      , {
            protocols: []
          , protocol: ""
          , port: null
          , resource: "ionicabizau.net"
          , user: ""
          , pathname: "/foo.js"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "http://domain.com/path/name?foo=bar&bar=42#some-hash"
      , {
            protocols: ["http"]
          , protocol: "http"
          , port: null
          , resource: "domain.com"
          , user: ""
          , pathname: "/path/name"
          , hash: "some-hash"
          , search: "foo=bar&bar=42"
        }
    ]
  , [
        "http://domain.com/path/name#some-hash?foo=bar&bar=42"
      , {
            protocols: ["http"]
          , protocol: "http"
          , port: null
          , resource: "domain.com"
          , user: ""
          , pathname: "/path/name"
          , hash: "some-hash?foo=bar&bar=42"
          , search: ""
        }
    ]
  , [
        "git+ssh://git@host.xz/path/name.git"
      , {
            protocols: ["git", "ssh"]
          , protocol: "git"
          , port: null
          , resource: "host.xz"
          , user: "git"
          , pathname: "/path/name.git"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "git@github.com:IonicaBizau/git-stats.git"
      , {
            protocols: []
          , protocol: "ssh"
          , port: null
          , resource: "github.com"
          , user: "git"
          , pathname: "/IonicaBizau/git-stats.git"
          , hash: ""
          , search: ""
        }
    ]
];

tester.describe("check urls", test => {
    INPUTS.forEach(function (c) {
        test.should("support " + c[0], () => {
            c[1].href = c[0];
            test.expect(parseUrl(c[0])).toEqual(c[1]);
        });
    });
});
<commit_msg>Adds tests for local files<commit_after>// Dependencies
const parseUrl = require("../lib")
    , tester = require("tester")
    ;

const INPUTS = [
    [
        "http://ionicabizau.net/blog"
      , {
            protocols: [ "http" ]
          , protocol: "http"
          , port: null
          , resource: "ionicabizau.net"
          , user: ""
          , pathname: "/blog"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "//ionicabizau.net/foo.js"
      , {
            protocols: []
          , protocol: ""
          , port: null
          , resource: "ionicabizau.net"
          , user: ""
          , pathname: "/foo.js"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "http://domain.com/path/name?foo=bar&bar=42#some-hash"
      , {
            protocols: ["http"]
          , protocol: "http"
          , port: null
          , resource: "domain.com"
          , user: ""
          , pathname: "/path/name"
          , hash: "some-hash"
          , search: "foo=bar&bar=42"
        }
    ]
  , [
        "http://domain.com/path/name#some-hash?foo=bar&bar=42"
      , {
            protocols: ["http"]
          , protocol: "http"
          , port: null
          , resource: "domain.com"
          , user: ""
          , pathname: "/path/name"
          , hash: "some-hash?foo=bar&bar=42"
          , search: ""
        }
    ]
  , [
        "git+ssh://git@host.xz/path/name.git"
      , {
            protocols: ["git", "ssh"]
          , protocol: "git"
          , port: null
          , resource: "host.xz"
          , user: "git"
          , pathname: "/path/name.git"
          , hash: ""
          , search: ""
        }
    ]
  , [
        "git@github.com:IonicaBizau/git-stats.git"
      , {
            protocols: []
          , protocol: "ssh"
          , port: null
          , resource: "github.com"
          , user: "git"
          , pathname: "/IonicaBizau/git-stats.git"
          , hash: ""
          , search: ""
        }
    ]
	, [
        "/path/to/file.png"
      , {
            protocols: []
          , protocol: "file"
          , port: null
          , resource: ""
          , user: ""
          , pathname: "/path/to/file.png"
          , hash: ""
          , search: ""
        }
    ]
	, [
        "./path/to/file.png"
      , {
            protocols: []
          , protocol: "file"
          , port: null
          , resource: ""
          , user: ""
          , pathname: "/path/to/file.png"
          , hash: ""
          , search: ""
        }
    ]
	, [
        "./.path/to/file.png"
      , {
            protocols: []
          , protocol: "file"
          , port: null
          , resource: ""
          , user: ""
          , pathname: "/.path/to/file.png"
          , hash: ""
          , search: ""
        }
    ]
	, [
        ".path/to/file.png"
      , {
            protocols: []
          , protocol: "file"
          , port: null
          , resource: ""
          , user: ""
          , pathname: ".path/to/file.png"
          , hash: ""
          , search: ""
        }
    ]
];

tester.describe("check urls", test => {
    INPUTS.forEach(function (c) {
        test.should("support " + c[0], () => {
            c[1].href = c[0];
            test.expect(parseUrl(c[0])).toEqual(c[1]);
        });
    });
});
<|endoftext|>


<commit_before>
var security_service = require("../index");

debugger;
var content = "1234567890"
console.log("Content: " + content)
// Token
var data = security_service.token("md5",content)
console.log("Token (MD5): " + data);

var data = security_service.token("sha1",content)
console.log("Token (SHA1): " + data);

var data = security_service.token("sha256",content)
console.log("Token (SHA256): " + data);

// Encrypt / Decrypt
var data = security_service.encrypt("aes256","key",content);
console.log("Encrypt (AES256): " + data);

var data = security_service.decrypt("aes256","key",data);
console.log("Decrypt (AES256): " + data);

var data = security_service.encrypt("HS512","key",content);
console.log("Encrypt (HS512): " + data);

var data = security_service.decrypt("HS512","key",data);
console.log("Decrypt (HS512): " + data);

var data = security_service.escapeHTML("&<>\"'/");
console.log("Escape html:&<>\"'/ with: " + data);

var data = security_service.escapeHTMLAttribute("\n\t\"");
console.log("Escape html attributes :&<>\"'/ with: " + data);

var data = security_service.encodeJavaScriptString("\n\t\"\u2028\u2029");
console.log("Encode javascript string: " + data);

var data = security_service.encodeCSSString("\n\t\"");
console.log("Encode CSS string: " + data);

security_service.consoleLog('hello world');

security_service.consoleLog('counter', 123);

security_service.consoleLog(1, "2", [ 3, 4 ], { 5: 6 }, function() { return 7; });

// testing validation:

var Validator = security_service.validator;
var v = new Validator();

  // Address, to be embedded on Person
  var addressSchema = {
    "id": "/SimpleAddress",
    "type": "object",
    "properties": {
      "lines": {
        "type": "array",
        "items": {"type": "string"}
      },
      "zip": {"type": "string"},
      "city": {"type": "string"},
      "country": {"type": "string", "required": true}
    }
  };

  // Person
  var schema = {
    "id": "/SimplePerson",
    "type": "object",
    "properties": {
      "name": {"type": "string"},
      "address": {"$ref": "/SimpleAddress"},
      "votes": {"type": "integer", "minimum": 1}
    }
  };

  var p = {
    "name": "Barack Obama",
    "address": {
      "lines": [ "1600 Pennsylvania Avenue Northwest" ],
      "zip": "DC 20500",
      "city": "Washington",
      "country": "USA"
    },
    "votes": "2"
  };

 security_service.consoleLog("****************************************************");
 security_service.consoleLog("****************************************************");
 security_service.consoleLog("**********************Testing validator*************");
 security_service.consoleLog("****************************************************");
 v.addSchema(addressSchema, '/SimpleAddress');
 security_service.consoleLog(v.validate(p, schema).valid);

/*security_service.log("****************************************************");
 security_service.log("****************************************************");
 security_service.log("**********************Testing forever***************");
 security_service.log("****************************************************");

 /*var child = new (security_service.forever.Monitor)('index.js', {
    max: 3,
    silent: true,
    args: []
  });

  child.on('exit', function () {
    console.log('your-filename.js has exited after 3 restarts');
  });

  child.start(); /* */
debugger;
security_service.winstonLog.add(security_service.winstonLog.transports.File, { filename: 'somefile.log' });
security_service.winstonLog.remove(security_service.winstonLog.transports.Console);

security_service.winstonLog.log('info', 'Hello distributed log files!');

<commit_msg>Update test/index.js<commit_after>
var secUtil = require("../index");

var content = "1234567890"
console.log("Content: " + content)
// Token
var data = secUtil.token("md5",content)
console.log("Token (MD5): " + data);

var data = secUtil.token("sha1",content)
console.log("Token (SHA1): " + data);

var data = secUtil.token("sha256",content)
console.log("Token (SHA256): " + data);

// Encrypt / Decrypt
var data = secUtil.encrypt("aes256","key",content);
console.log("Encrypt (AES256): " + data);

var data = secUtil.decrypt("aes256","key",data);
console.log("Decrypt (AES256): " + data);

var data = secUtil.encrypt("HS512","key",content);
console.log("Encrypt (HS512): " + data);

var data = secUtil.decrypt("HS512","key",data);
console.log("Decrypt (HS512): " + data);

var data = secUtil.escapeHTML("&<>\"'/");
console.log("Escape html:&<>\"'/ with: " + data);

var data = secUtil.escapeHTMLAttribute("\n\t\"");
console.log("Escape html attributes :&<>\"'/ with: " + data);

var data = secUtil.encodeJavaScriptString("\n\t\"\u2028\u2029");
console.log("Encode javascript string: " + data);

var data = secUtil.encodeCSSString("\n\t\"");
console.log("Encode CSS string: " + data);

secUtil.consoleLog('hello world');

secUtil.consoleLog('counter', 123);

secUtil.consoleLog(1, "2", [ 3, 4 ], { 5: 6 }, function() { return 7; });

// testing validation:

var Validator = secUtil.validator;
var v = new Validator();

  // Address, to be embedded on Person
  var addressSchema = {
    "id": "/SimpleAddress",
    "type": "object",
    "properties": {
      "lines": {
        "type": "array",
        "items": {"type": "string"}
      },
      "zip": {"type": "string"},
      "city": {"type": "string"},
      "country": {"type": "string", "required": true}
    }
  };

  // Person
  var schema = {
    "id": "/SimplePerson",
    "type": "object",
    "properties": {
      "name": {"type": "string"},
      "address": {"$ref": "/SimpleAddress"},
      "votes": {"type": "integer", "minimum": 1}
    }
  };

  var p = {
    "name": "Barack Obama",
    "address": {
      "lines": [ "1600 Pennsylvania Avenue Northwest" ],
      "zip": "DC 20500",
      "city": "Washington",
      "country": "USA"
    },
    "votes": "2"
  };

 secUtil.consoleLog("****************************************************");
 secUtil.consoleLog("****************************************************");
 secUtil.consoleLog("**********************Testing validator*************");
 secUtil.consoleLog("****************************************************");
 v.addSchema(addressSchema, '/SimpleAddress');
 secUtil.consoleLog(v.validate(p, schema).valid);

  secUtil.winstonLog.add(secUtil.winstonLog.transports.File, { filename: 'somefile.log' });
  secUtil.winstonLog.remove(secUtil.winstonLog.transports.Console);

  secUtil.winstonLog.log('info', 'Hello distributed log files!');

<|endoftext|>