test: update parser tests and snapshots
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
0f3f27287d
commit
6e091a7cdb
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"files": Array [
|
"files": Object {
|
||||||
Object {
|
"indexjs": Object {
|
||||||
"contents": "function testFunction(arg) {
|
"contents": "function testFunction(arg) {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
@ -19,6 +19,6 @@ testFunction('hello');
|
|||||||
"tail": "console.info('after the test');
|
"tail": "console.info('after the test');
|
||||||
",
|
",
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -3,12 +3,21 @@
|
|||||||
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"solutions": Array [
|
"solutions": Array [
|
||||||
"function testFunction(arg) {
|
Object {
|
||||||
|
"indexjs": Object {
|
||||||
|
"contents": "function testFunction(arg) {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
testFunction('hello');
|
testFunction('hello');
|
||||||
",
|
",
|
||||||
|
"ext": "js",
|
||||||
|
"head": "",
|
||||||
|
"key": "indexjs",
|
||||||
|
"name": "index",
|
||||||
|
"tail": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -3,6 +3,7 @@ const isArray = require('lodash/isArray');
|
|||||||
|
|
||||||
const mockAST = require('./fixtures/challenge-html-ast.json');
|
const mockAST = require('./fixtures/challenge-html-ast.json');
|
||||||
const { challengeSeedToData } = require('./challengeSeed-to-data');
|
const { challengeSeedToData } = require('./challengeSeed-to-data');
|
||||||
|
const { isObject } = require('lodash');
|
||||||
|
|
||||||
describe('challengeSeed-to-data plugin', () => {
|
describe('challengeSeed-to-data plugin', () => {
|
||||||
const plugin = challengeSeedToData();
|
const plugin = challengeSeedToData();
|
||||||
@ -21,9 +22,9 @@ describe('challengeSeed-to-data plugin', () => {
|
|||||||
expect('files' in file.data).toBe(true);
|
expect('files' in file.data).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ensures that the `files` property is an array', () => {
|
it('ensures that the `files` property is an object', () => {
|
||||||
plugin(mockAST, file);
|
plugin(mockAST, file);
|
||||||
expect(Array.isArray(file.data.files)).toBe(true);
|
expect(isObject(file.data.files)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds test objects to the files array following a schema', () => {
|
it('adds test objects to the files array following a schema', () => {
|
||||||
@ -32,7 +33,7 @@ describe('challengeSeed-to-data plugin', () => {
|
|||||||
const {
|
const {
|
||||||
data: { files }
|
data: { files }
|
||||||
} = file;
|
} = file;
|
||||||
const testObject = files[0];
|
const testObject = files.indexjs;
|
||||||
expect(Object.keys(testObject).length).toEqual(7);
|
expect(Object.keys(testObject).length).toEqual(7);
|
||||||
expect(testObject).toHaveProperty('key');
|
expect(testObject).toHaveProperty('key');
|
||||||
expect(typeof testObject['key']).toBe('string');
|
expect(typeof testObject['key']).toBe('string');
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* global describe it expect beforeEach */
|
/* global describe it expect beforeEach */
|
||||||
const mockAST = require('./fixtures/challenge-html-ast.json');
|
const mockAST = require('./fixtures/challenge-html-ast.json');
|
||||||
const solutionToData = require('./solution-to-data');
|
const solutionToData = require('./solution-to-data');
|
||||||
|
const { isObject } = require('lodash');
|
||||||
|
|
||||||
describe('challengeSeed-to-data plugin', () => {
|
describe('challengeSeed-to-data plugin', () => {
|
||||||
const plugin = solutionToData();
|
const plugin = solutionToData();
|
||||||
@ -24,10 +25,10 @@ describe('challengeSeed-to-data plugin', () => {
|
|||||||
expect(Array.isArray(file.data.solutions)).toBe(true);
|
expect(Array.isArray(file.data.solutions)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('each entry in the `solutions` array is a string', () => {
|
it('each entry in the `solutions` array is an object', () => {
|
||||||
plugin(mockAST, file);
|
plugin(mockAST, file);
|
||||||
|
|
||||||
expect(file.data.solutions.every(el => typeof el === 'string')).toBe(true);
|
expect(file.data.solutions.every(el => isObject(el))).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have an output to match the snapshot', () => {
|
it('should have an output to match the snapshot', () => {
|
||||||
|
Reference in New Issue
Block a user