Skip to content

Commit

Permalink
Added tests for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
evangelion1204 committed Nov 13, 2016
1 parent 8b659bb commit a170ee6
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/filter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,65 @@ describe("Filters", function () {
expect(MultiIni.filters).not.to.be.undefined;
expect(MultiIni.filters).not.to.be.null;
});

describe("lowercase", function () {
it("is available", function () {
expect(MultiIni.filters.lowercase).to.be.defined;
});

it("string should be lowercase", function () {
expect(MultiIni.filters.lowercase('Test')).to.equal('test');
});

it("anything else then string will be returned unmodified", function () {
expect(MultiIni.filters.lowercase(false)).to.equal(false);
});
});

describe("uppercase", function () {
it("is available", function () {
expect(MultiIni.filters.uppercase).to.be.defined;
});

it("string should be uppercase", function () {
expect(MultiIni.filters.uppercase('Test')).to.equal('TEST');
});

it("anything else then string will be returned unmodified", function () {
expect(MultiIni.filters.uppercase(false)).to.equal(false);
});
});

describe("trim", function () {
it("is available", function () {
expect(MultiIni.filters.trim).to.be.defined;
});

it("string should be trimmed", function () {
expect(MultiIni.filters.trim(' Test ')).to.equal('Test');
});

it("anything else then string will be returned unmodified", function () {
expect(MultiIni.filters.trim(false)).to.equal(false);
});
});

describe("constants", function () {
it("is available", function () {
expect(MultiIni.filters.constants).to.be.defined;
});

it("string should have replaced constants", function () {
const options = {constants: {CONSTANT: 'replaced'}};

expect(MultiIni.filters.constants('"Test " CONSTANT', options)).to.equal('"Test replaced"');
expect(MultiIni.filters.constants('"Test " CONSTANT " Test"', options)).to.equal('"Test replaced Test"');
expect(MultiIni.filters.constants('CONSTANT " Test"', options)).to.equal('"replaced Test"');
});

it("anything else then string will be returned unmodified", function () {
expect(MultiIni.filters.constants(false)).to.equal(false);
});
});

});

0 comments on commit a170ee6

Please sign in to comment.