test: update parser tests and snapshots
parent
0f3f27287d
commit
6e091a7cdb
|
@ -2,8 +2,8 @@
|
|||
|
||||
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
||||
Object {
|
||||
"files": Array [
|
||||
Object {
|
||||
"files": Object {
|
||||
"indexjs": Object {
|
||||
"contents": "function testFunction(arg) {
|
||||
return arg;
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ testFunction('hello');
|
|||
"tail": "console.info('after the test');
|
||||
",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -3,12 +3,21 @@
|
|||
exports[`challengeSeed-to-data plugin should have an output to match the snapshot 1`] = `
|
||||
Object {
|
||||
"solutions": Array [
|
||||
"function testFunction(arg) {
|
||||
Object {
|
||||
"indexjs": Object {
|
||||
"contents": "function testFunction(arg) {
|
||||
return arg;
|
||||
}
|
||||
|
||||
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 { challengeSeedToData } = require('./challengeSeed-to-data');
|
||||
const { isObject } = require('lodash');
|
||||
|
||||
describe('challengeSeed-to-data plugin', () => {
|
||||
const plugin = challengeSeedToData();
|
||||
|
@ -21,9 +22,9 @@ describe('challengeSeed-to-data plugin', () => {
|
|||
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);
|
||||
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', () => {
|
||||
|
@ -32,7 +33,7 @@ describe('challengeSeed-to-data plugin', () => {
|
|||
const {
|
||||
data: { files }
|
||||
} = file;
|
||||
const testObject = files[0];
|
||||
const testObject = files.indexjs;
|
||||
expect(Object.keys(testObject).length).toEqual(7);
|
||||
expect(testObject).toHaveProperty('key');
|
||||
expect(typeof testObject['key']).toBe('string');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* global describe it expect beforeEach */
|
||||
const mockAST = require('./fixtures/challenge-html-ast.json');
|
||||
const solutionToData = require('./solution-to-data');
|
||||
const { isObject } = require('lodash');
|
||||
|
||||
describe('challengeSeed-to-data plugin', () => {
|
||||
const plugin = solutionToData();
|
||||
|
@ -24,10 +25,10 @@ describe('challengeSeed-to-data plugin', () => {
|
|||
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);
|
||||
|
||||
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', () => {
|
||||
|
|
Loading…
Reference in New Issue