Skip to content

Commit

Permalink
added 2 tests for issue 11ty#389, order logically,
Browse files Browse the repository at this point in the history
 - test no .eleventyignore, .gitignore exists but empty
 - test .eleventyignore, .gitignore exists but empty.
 - reorder tests.
  • Loading branch information
danielstaleiny committed Feb 16, 2019
1 parent dfebc60 commit f40cf8d
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 23 deletions.
83 changes: 61 additions & 22 deletions test/EleventyFilesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,45 @@ test("Get ignores (no .eleventyignore no .gitignore)", t => {
]);
});

test("Get ignores (no .eleventyignore)", t => {
test("Get ignores (no .eleventyignore .gitignore exists but empty)", t => {
let evf = new EleventyFiles(
"test/stubs/ignore2",
"test/stubs/ignore2/_site",
[]
);
evf.init();

evf._setLocalPathRoot("./test/stubs/ignorelocalroot");

t.deepEqual(evf.getIgnores(), [
"!./test/stubs/ignore2/thisshouldnotexist12345",
"!./node_modules/**",
"!./test/stubs/ignorelocalroot/node_modules/**",
"!./test/stubs/ignore2/node_modules/**",
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore2/_site/**"
]);
});

test("Get ignores (no .eleventyignore)", t => {
let evf = new EleventyFiles(
"test/stubs/ignore3",
"test/stubs/ignore3/_site",
[]
);
evf.init();
evf._setLocalPathRoot("./test/stubs/ignorelocalroot");

t.deepEqual(evf.getIgnores(), [
"!./test/stubs/ignore3/thisshouldnotexist12345",
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore3/_site/**"
]);
});

test("Get ignores (no .eleventyignore, using setUseGitIgnore(false))", t => {
let evf = new EleventyFiles(
"test/stubs/ignore2",
"test/stubs/ignore2/_site",
"test/stubs/ignore3",
"test/stubs/ignore3/_site",
[]
);
evf.init();
Expand All @@ -210,14 +229,14 @@ test("Get ignores (no .eleventyignore, using setUseGitIgnore(false))", t => {

t.deepEqual(evf.getIgnores(), [
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore2/_site/**"
"!./test/stubs/ignore3/_site/**"
]);
});

test("Get ignores (no .gitignore)", t => {
let evf = new EleventyFiles(
"test/stubs/ignore3",
"test/stubs/ignore3/_site",
"test/stubs/ignore4",
"test/stubs/ignore4/_site",
[]
);
evf.init();
Expand All @@ -226,36 +245,36 @@ test("Get ignores (no .gitignore)", t => {
t.deepEqual(evf.getIgnores(), [
"!./node_modules/**",
"!./test/stubs/ignorelocalroot/node_modules/**",
"!./test/stubs/ignore3/node_modules/**",
"!./test/stubs/ignore4/node_modules/**",
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore3/ignoredFolder/**",
"!./test/stubs/ignore3/ignoredFolder/ignored.md",
"!./test/stubs/ignore3/_site/**"
"!./test/stubs/ignore4/ignoredFolder/**",
"!./test/stubs/ignore4/ignoredFolder/ignored.md",
"!./test/stubs/ignore4/_site/**"
]);
});

test("Get ignores (both .eleventyignore and .gitignore)", t => {
let evf = new EleventyFiles(
"test/stubs/ignore4",
"test/stubs/ignore4/_site",
"test/stubs/ignore5",
"test/stubs/ignore5/_site",
[]
);
evf.init();
evf._setLocalPathRoot("./test/stubs/ignorelocalroot");

t.deepEqual(evf.getIgnores(), [
"!./test/stubs/ignore4/thisshouldnotexist12345",
"!./test/stubs/ignore5/thisshouldnotexist12345",
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore4/ignoredFolder/**",
"!./test/stubs/ignore4/ignoredFolder/ignored.md",
"!./test/stubs/ignore4/_site/**"
"!./test/stubs/ignore5/ignoredFolder/**",
"!./test/stubs/ignore5/ignoredFolder/ignored.md",
"!./test/stubs/ignore5/_site/**"
]);
});

test("Get ignores (both .eleventyignore and .gitignore, using setUseGitIgnore(false))", t => {
let evf = new EleventyFiles(
"test/stubs/ignore4",
"test/stubs/ignore4/_site",
"test/stubs/ignore5",
"test/stubs/ignore5/_site",
[]
);
evf.init();
Expand All @@ -267,9 +286,29 @@ test("Get ignores (both .eleventyignore and .gitignore, using setUseGitIgnore(fa

t.deepEqual(evf.getIgnores(), [
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore4/ignoredFolder/**",
"!./test/stubs/ignore4/ignoredFolder/ignored.md",
"!./test/stubs/ignore4/_site/**"
"!./test/stubs/ignore5/ignoredFolder/**",
"!./test/stubs/ignore5/ignoredFolder/ignored.md",
"!./test/stubs/ignore5/_site/**"
]);
});

test("Get ignores (both .eleventyignore and .gitignore, but .gitignore is empty)", t => {
let evf = new EleventyFiles(
"test/stubs/ignore6",
"test/stubs/ignore6/_site",
[]
);
evf.init();
evf._setLocalPathRoot("./test/stubs/ignorelocalroot");

t.deepEqual(evf.getIgnores(), [
"!./node_modules/**",
"!./test/stubs/ignorelocalroot/node_modules/**",
"!./test/stubs/ignore6/node_modules/**",
"!./test/stubs/ignorelocalroot/test.md",
"!./test/stubs/ignore6/ignoredFolder/**",
"!./test/stubs/ignore6/ignoredFolder/ignored.md",
"!./test/stubs/ignore6/_site/**"
]);
});
/* End .eleventyignore and .gitignore combos */
Expand Down
1 change: 0 additions & 1 deletion test/stubs/ignore2/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
thisshouldnotexist12345
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions test/stubs/ignore5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
thisshouldnotexist12345
1 change: 1 addition & 0 deletions test/stubs/ignore5/ignoredFolder/ignored.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This should be ignored
3 changes: 3 additions & 0 deletions test/stubs/ignore6/.eleventyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignoredFolder
./ignoredFolder/ignored.md
# This is a comment
Empty file added test/stubs/ignore6/.gitignore
Empty file.
1 change: 1 addition & 0 deletions test/stubs/ignore6/ignoredFolder/ignored.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This should be ignored

0 comments on commit f40cf8d

Please sign in to comment.