diff --git a/__tests__/testChallenges/challengeDocumentReady.test.js b/__tests__/finishedTestChallenges/documentReady.test.js similarity index 100% rename from __tests__/testChallenges/challengeDocumentReady.test.js rename to __tests__/finishedTestChallenges/documentReady.test.js diff --git a/__tests__/testChallenges/challengeGetElementById.test.js b/__tests__/finishedTestChallenges/getElementById.test.js similarity index 100% rename from __tests__/testChallenges/challengeGetElementById.test.js rename to __tests__/finishedTestChallenges/getElementById.test.js diff --git a/__tests__/main.test.js b/__tests__/main.test.js index a2854c2..d8bbe53 100644 --- a/__tests__/main.test.js +++ b/__tests__/main.test.js @@ -6,7 +6,7 @@ const { vanilla } = require('../lib/vanilla'); const loadFileToBuffer = require('../lib/loadFileToBuffer'); describe("Test command 'vanilla'", () => { - const testNames = ['documentReady']; + const testNames = ['documentReady', 'getElementById']; testNames.forEach((testName) => { test(`Vanillaize '${testName}'`, async () => { diff --git a/__tests__/testChallenges/challengeAppendElement.test.js b/__tests__/pendingTestChallenges/children.test.js similarity index 89% rename from __tests__/testChallenges/challengeAppendElement.test.js rename to __tests__/pendingTestChallenges/children.test.js index 0179238..ff0ef62 100644 --- a/__tests__/testChallenges/challengeAppendElement.test.js +++ b/__tests__/pendingTestChallenges/children.test.js @@ -1,12 +1,12 @@ /** - * Test function vanilla on case 'appendElement' + * Test function vanilla on case 'children' */ const { vanilla } = require('../../lib/vanilla'); const loadFileToBuffer = require('../../lib/loadFileToBuffer'); describe("Test command 'vanilla' on test challenges", () => { - const testName = 'appendElement'; + const testName = 'children'; test(`Vanillaize '${testName}'`, async () => { // Input diff --git a/__tests__/testChallenges/challengeCloneElement.test.js b/__tests__/pendingTestChallenges/cloneElement.test.js similarity index 100% rename from __tests__/testChallenges/challengeCloneElement.test.js rename to __tests__/pendingTestChallenges/cloneElement.test.js diff --git a/__tests__/testChallenges/challengeCreateElement.test.js b/__tests__/pendingTestChallenges/createElement.test.js similarity index 100% rename from __tests__/testChallenges/challengeCreateElement.test.js rename to __tests__/pendingTestChallenges/createElement.test.js diff --git a/__tests__/pendingTestChallenges/getElementsByClassName.test.js b/__tests__/pendingTestChallenges/getElementsByClassName.test.js new file mode 100644 index 0000000..d8da942 --- /dev/null +++ b/__tests__/pendingTestChallenges/getElementsByClassName.test.js @@ -0,0 +1,31 @@ +/** + * Test function vanilla on case 'getElementsByClassName' + */ + +const { vanilla } = require('../../lib/vanilla'); +const loadFileToBuffer = require('../../lib/loadFileToBuffer'); + +describe("Test command 'vanilla' on test challenges", () => { + const testName = 'getElementsByClassName'; + + test(`Vanillaize '${testName}'`, async () => { + // Input + const argv = { + _: ['vanilla', `./__tests__/testCases/${testName}.js`], + C: true, + 'no-cache': true, + noCache: true, + $0: 'vaniquery', + }; + + // Output + const output = await vanilla(argv); + + // Answer key + const answerKeyFile = `./__tests__/testCases/${testName}.answerkey.js`; + const answerKey = await loadFileToBuffer(answerKeyFile); + + // Expect + expect(output).toEqual(answerKey); + }); +}); diff --git a/__tests__/pendingTestChallenges/getElementsByTagName.test.js b/__tests__/pendingTestChallenges/getElementsByTagName.test.js new file mode 100644 index 0000000..f4164da --- /dev/null +++ b/__tests__/pendingTestChallenges/getElementsByTagName.test.js @@ -0,0 +1,31 @@ +/** + * Test function vanilla on case 'getElementsByTagName' + */ + +const { vanilla } = require('../../lib/vanilla'); +const loadFileToBuffer = require('../../lib/loadFileToBuffer'); + +describe("Test command 'vanilla' on test challenges", () => { + const testName = 'getElementsByTagName'; + + test(`Vanillaize '${testName}'`, async () => { + // Input + const argv = { + _: ['vanilla', `./__tests__/testCases/${testName}.js`], + C: true, + 'no-cache': true, + noCache: true, + $0: 'vaniquery', + }; + + // Output + const output = await vanilla(argv); + + // Answer key + const answerKeyFile = `./__tests__/testCases/${testName}.answerkey.js`; + const answerKey = await loadFileToBuffer(answerKeyFile); + + // Expect + expect(output).toEqual(answerKey); + }); +}); diff --git a/__tests__/testChallenges/challengeParent.test.js b/__tests__/pendingTestChallenges/parent.test.js similarity index 100% rename from __tests__/testChallenges/challengeParent.test.js rename to __tests__/pendingTestChallenges/parent.test.js diff --git a/__tests__/testChallenges/challengeSelectAll.test.js b/__tests__/pendingTestChallenges/selectAll.test.js similarity index 100% rename from __tests__/testChallenges/challengeSelectAll.test.js rename to __tests__/pendingTestChallenges/selectAll.test.js diff --git a/__tests__/pendingTestChallenges/selectAllAttribute.test.js b/__tests__/pendingTestChallenges/selectAllAttribute.test.js new file mode 100644 index 0000000..c976035 --- /dev/null +++ b/__tests__/pendingTestChallenges/selectAllAttribute.test.js @@ -0,0 +1,31 @@ +/** + * Test function vanilla on case 'selectAllAttribute' + */ + +const { vanilla } = require('../../lib/vanilla'); +const loadFileToBuffer = require('../../lib/loadFileToBuffer'); + +describe("Test command 'vanilla' on test challenges", () => { + const testName = 'selectAllAttribute'; + + test(`Vanillaize '${testName}'`, async () => { + // Input + const argv = { + _: ['vanilla', `./__tests__/testCases/${testName}.js`], + C: true, + 'no-cache': true, + noCache: true, + $0: 'vaniquery', + }; + + // Output + const output = await vanilla(argv); + + // Answer key + const answerKeyFile = `./__tests__/testCases/${testName}.answerkey.js`; + const answerKey = await loadFileToBuffer(answerKeyFile); + + // Expect + expect(output).toEqual(answerKey); + }); +}); diff --git a/__tests__/pendingTestChallenges/selectAllPseudoClass.test.js b/__tests__/pendingTestChallenges/selectAllPseudoClass.test.js new file mode 100644 index 0000000..22d60e3 --- /dev/null +++ b/__tests__/pendingTestChallenges/selectAllPseudoClass.test.js @@ -0,0 +1,31 @@ +/** + * Test function vanilla on case 'selectAllPseudoClass' + */ + +const { vanilla } = require('../../lib/vanilla'); +const loadFileToBuffer = require('../../lib/loadFileToBuffer'); + +describe("Test command 'vanilla' on test challenges", () => { + const testName = 'selectAllPseudoClass'; + + test(`Vanillaize '${testName}'`, async () => { + // Input + const argv = { + _: ['vanilla', `./__tests__/testCases/${testName}.js`], + C: true, + 'no-cache': true, + noCache: true, + $0: 'vaniquery', + }; + + // Output + const output = await vanilla(argv); + + // Answer key + const answerKeyFile = `./__tests__/testCases/${testName}.answerkey.js`; + const answerKey = await loadFileToBuffer(answerKeyFile); + + // Expect + expect(output).toEqual(answerKey); + }); +}); diff --git a/__tests__/testCases/appendElement.answerkey.js b/__tests__/testCases/appendElement.answerkey.js deleted file mode 100644 index 098724b..0000000 --- a/__tests__/testCases/appendElement.answerkey.js +++ /dev/null @@ -1 +0,0 @@ -document.body.appendChild(document.createElement('p')); diff --git a/__tests__/testCases/appendElement.js b/__tests__/testCases/appendElement.js deleted file mode 100644 index 8b6f8f9..0000000 --- a/__tests__/testCases/appendElement.js +++ /dev/null @@ -1 +0,0 @@ -$('body').append($('
')); diff --git a/__tests__/testCases/children.answer.js b/__tests__/testCases/children.answer.js new file mode 100644 index 0000000..5874f5c --- /dev/null +++ b/__tests__/testCases/children.answer.js @@ -0,0 +1,3 @@ +document.getElementById('my-parent').children; + +var child = ocument.getElementById('another-parent').children(); diff --git a/__tests__/testCases/children.js b/__tests__/testCases/children.js new file mode 100644 index 0000000..e1b9e2d --- /dev/null +++ b/__tests__/testCases/children.js @@ -0,0 +1,3 @@ +$('#my-parent').children(); + +var child = $('#another-parent').children(); diff --git a/__tests__/testCases/getElementsByClassName.answerkey.js b/__tests__/testCases/getElementsByClassName.answerkey.js new file mode 100644 index 0000000..84b028d --- /dev/null +++ b/__tests__/testCases/getElementsByClassName.answerkey.js @@ -0,0 +1 @@ +document.getElementsByClassName('my-class'); diff --git a/__tests__/testCases/getElementsByClassName.js b/__tests__/testCases/getElementsByClassName.js new file mode 100644 index 0000000..9e37d0e --- /dev/null +++ b/__tests__/testCases/getElementsByClassName.js @@ -0,0 +1 @@ +$('.my-class'); diff --git a/__tests__/testCases/getElementsByTagName.answerkey.js b/__tests__/testCases/getElementsByTagName.answerkey.js new file mode 100644 index 0000000..4d81c16 --- /dev/null +++ b/__tests__/testCases/getElementsByTagName.answerkey.js @@ -0,0 +1 @@ +document.getElementsByTagName('div'); diff --git a/__tests__/testCases/getElementsByTagName.js b/__tests__/testCases/getElementsByTagName.js new file mode 100644 index 0000000..e5ad510 --- /dev/null +++ b/__tests__/testCases/getElementsByTagName.js @@ -0,0 +1 @@ +$('div'); diff --git a/__tests__/testCases/selectAll.answerkey.js b/__tests__/testCases/selectAll.answerkey.js index 1c9ee30..0c7b9a9 100644 --- a/__tests__/testCases/selectAll.answerkey.js +++ b/__tests__/testCases/selectAll.answerkey.js @@ -1,3 +1,5 @@ document.querySelectorAll(".box"); var divs = document.querySelectorAll('div'); + +document.querySelectorAll('[data-foo-bar="someval"]'); diff --git a/__tests__/testCases/selectAll.js b/__tests__/testCases/selectAll.js index 9600b61..20baf72 100644 --- a/__tests__/testCases/selectAll.js +++ b/__tests__/testCases/selectAll.js @@ -1,3 +1,5 @@ $(".box"); var divs = $('div'); + +$('[data-foo-bar="someval"]'); diff --git a/__tests__/testCases/selectAllAttribute.answer.js b/__tests__/testCases/selectAllAttribute.answer.js new file mode 100644 index 0000000..71a185c --- /dev/null +++ b/__tests__/testCases/selectAllAttribute.answer.js @@ -0,0 +1 @@ +document.querySelectorAll('[data-foo-bar="someval"]'); diff --git a/__tests__/testCases/selectAllAttribute.js b/__tests__/testCases/selectAllAttribute.js new file mode 100644 index 0000000..f55e868 --- /dev/null +++ b/__tests__/testCases/selectAllAttribute.js @@ -0,0 +1 @@ +$('[data-foo-bar="someval"]'); diff --git a/__tests__/testCases/selectAllPseudoClass.answerkey.js b/__tests__/testCases/selectAllPseudoClass.answerkey.js new file mode 100644 index 0000000..575e2ae --- /dev/null +++ b/__tests__/testCases/selectAllPseudoClass.answerkey.js @@ -0,0 +1 @@ +document.querySelectorAll('#myForm:invalid'); diff --git a/__tests__/testCases/selectAllPseudoClass.js b/__tests__/testCases/selectAllPseudoClass.js new file mode 100644 index 0000000..5d3d5f2 --- /dev/null +++ b/__tests__/testCases/selectAllPseudoClass.js @@ -0,0 +1 @@ +$('#myForm:invalid'); diff --git a/lib/equivalentsLib.js b/lib/equivalentsLib.js index b8639f6..e49af16 100644 --- a/lib/equivalentsLib.js +++ b/lib/equivalentsLib.js @@ -3,11 +3,6 @@ */ module.exports = [ - { - name: 'appendElement', - jquery: /$^/, - vanilla: '', - }, { name: 'cloneElement', jquery: /$^/,