'use strict';

var stemmer,
    content,
    visit,
    Retext,
    assert,
    retext,
    otherWords,
    otherStems;

/**
 * Module dependencies.
 */

stemmer = require('./');
Retext = require('retext');
visit = require('retext-visit');
content = require('retext-content');
assert = require('assert');

/**
 * Retext.
 */

retext = new Retext()
    .use(visit)
    .use(content)
    .use(stemmer);

/**
 * Constants.
 */

otherWords = ['An', 'easy', 'normal', 'paragraph'];
otherStems = ['an', 'easi', 'normal', 'paragraph'];

/**
 * Tests.
 */

describe('porterStemmer()', function () {
    it('should be a `function`', function () {
        assert(typeof stemmer === 'function');
    });

    it('should export an `attach` method', function () {
        assert(typeof stemmer.attach === 'function');
    });

    retext.parse('A simple, english, sentence', function (err, tree) {
        it('should not throw', function (done) {
            done(err);
        });

        it('should `stem` each `WordNode`', function () {
            tree.visit(tree.WORD_NODE, function (wordNode) {
                assert('stem' in wordNode.data);
            });
        });

        it('should set each stem to `null` when a WordNode (no longer?) ' +
            'has a value', function () {
                tree.visit(tree.WORD_NODE, function (wordNode) {
                    wordNode.removeContent();

                    assert(wordNode.data.stem === null);
                });
            }
        );

        it('should automatically re-stem `WordNode`s when their values ' +
            'change',
            function () {
                var index;

                index = -1;

                tree.visit(tree.WORD_NODE, function (wordNode) {
                    wordNode.replaceContent(otherWords[++index]);

                    assert(wordNode.data.stem === otherStems[index]);
                });
            }
        );
    });
});

@@ -8,16 +8,42 @@
 rict';%0A%0A
+/**%0A * Dependencies.%0A */%0A%0A
 var stem
@@ -97,86 +97,9 @@
 sert
-,%0A    retext,%0A    otherWords,%0A    otherStems;%0A%0A/**%0A * Module dependencies.%0A */
+;
 %0A%0Ast
@@ -268,16 +268,29 @@
 t.%0A */%0A%0A
+var retext;%0A%0A
 retext =
@@ -368,22 +368,54 @@
 %0A * 
-Constants.%0A */
+Fixtures.%0A */%0A%0Avar otherWords,%0A    otherStems;
 %0A%0Aot

Refactor test