Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Add more test cases & update filenames #17

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
31 changes: 31 additions & 0 deletions __tests__/pendingTestChallenges/getElementsByClassName.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
31 changes: 31 additions & 0 deletions __tests__/pendingTestChallenges/getElementsByTagName.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
31 changes: 31 additions & 0 deletions __tests__/pendingTestChallenges/selectAllAttribute.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
31 changes: 31 additions & 0 deletions __tests__/pendingTestChallenges/selectAllPseudoClass.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
1 change: 0 additions & 1 deletion __tests__/testCases/appendElement.answerkey.js

This file was deleted.

1 change: 0 additions & 1 deletion __tests__/testCases/appendElement.js

This file was deleted.

3 changes: 3 additions & 0 deletions __tests__/testCases/children.answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById('my-parent').children;

var child = ocument.getElementById('another-parent').children();
3 changes: 3 additions & 0 deletions __tests__/testCases/children.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('#my-parent').children();

var child = $('#another-parent').children();
1 change: 1 addition & 0 deletions __tests__/testCases/getElementsByClassName.answerkey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.getElementsByClassName('my-class');
1 change: 1 addition & 0 deletions __tests__/testCases/getElementsByClassName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('.my-class');
1 change: 1 addition & 0 deletions __tests__/testCases/getElementsByTagName.answerkey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.getElementsByTagName('div');
1 change: 1 addition & 0 deletions __tests__/testCases/getElementsByTagName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('div');
2 changes: 2 additions & 0 deletions __tests__/testCases/selectAll.answerkey.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
document.querySelectorAll(".box");

var divs = document.querySelectorAll('div');

document.querySelectorAll('[data-foo-bar="someval"]');
2 changes: 2 additions & 0 deletions __tests__/testCases/selectAll.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$(".box");

var divs = $('div');

$('[data-foo-bar="someval"]');
1 change: 1 addition & 0 deletions __tests__/testCases/selectAllAttribute.answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.querySelectorAll('[data-foo-bar="someval"]');
1 change: 1 addition & 0 deletions __tests__/testCases/selectAllAttribute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('[data-foo-bar="someval"]');
1 change: 1 addition & 0 deletions __tests__/testCases/selectAllPseudoClass.answerkey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.querySelectorAll('#myForm:invalid');
1 change: 1 addition & 0 deletions __tests__/testCases/selectAllPseudoClass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('#myForm:invalid');
5 changes: 0 additions & 5 deletions lib/equivalentsLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
*/

module.exports = [
{
name: 'appendElement',
jquery: /$^/,
vanilla: '',
},
{
name: 'cloneElement',
jquery: /$^/,
Expand Down