Skip to content
Open
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
20 changes: 16 additions & 4 deletions __tests__/Layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ const patterns = [
codeES5: 'Code ES5 - Prototype',
codeES6: 'Code ES6 - Prototype',
answered: false,
answerId: null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

answerId is same as uuid in the store

correct: null
correct: null,
variants: [{
Copy link
Contributor Author

@Beraliv Beraliv May 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added variants and variantUuid for tests

uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
},

{
Expand All @@ -29,8 +35,14 @@ const patterns = [
codeES5: 'Code ES5 - Singleton',
codeES6: 'Code ES6 - Singleton',
answered: false,
answerId: null,
correct: null
correct: null,
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
}
];

Expand Down
34 changes: 26 additions & 8 deletions __tests__/middleware/submit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ const patterns = [
codeES5: 'Code ES5',
codeES6: 'Code ES6',
answered: false,
answerId: null,
correct: null
correct: null,
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
},

{
Expand All @@ -23,8 +29,14 @@ const patterns = [
codeES5: 'Code ES5',
codeES6: 'Code ES6',
answered: false,
answerId: null,
correct: null
correct: null,
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
}
];

Expand All @@ -45,23 +57,29 @@ describe('Submit middleware', () => {
payload: {
currentIndex: 0,
recentlyAnswered: {
answerId: 'abc123',
answered: true,
correct: true,
name: 'Prototype',
type: 'creational',
uuid: 'abc123'
uuid: 'abc123',
variantUuid: 'abc123'
},
remainingPatterns: [
{
answerId: null,
answered: false,
codeES5: 'Code ES5',
codeES6: 'Code ES6',
correct: null,
name: 'Singleton',
type: 'creational',
uuid: 'abc234'
uuid: 'abc234',
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
}
]
},
Expand Down
47 changes: 38 additions & 9 deletions __tests__/pages/Game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ const patterns = [
codeES5: 'Code ES5 - Prototype',
codeES6: 'Code ES6 - Prototype',
answered: false,
answerId: null,
correct: null
correct: null,
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
},

{
Expand All @@ -30,8 +36,14 @@ const patterns = [
codeES5: 'Code ES5 - Singleton',
codeES6: 'Code ES6 - Singleton',
answered: false,
answerId: null,
correct: null
correct: null,
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
}
];

Expand Down Expand Up @@ -161,8 +173,15 @@ describe('Game page - RESULTS', () => {
codeES5: 'Code ES5 - Prototype',
codeES6: 'Code ES6 - Prototype',
answered: true,
answerId: 'abc123',
correct: true
correct: true,
variantUuid: 'abc123',
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
},

{
Expand All @@ -172,8 +191,15 @@ describe('Game page - RESULTS', () => {
codeES5: 'Code ES5 - Singleton',
codeES6: 'Code ES6 - Singleton',
answered: true,
answerId: 'abc123',
correct: false
correct: false,
variantUuid: 'abc123',
variants: [{
uuid: 'abc234',
name: 'SIngleton'
}, {
uuid: 'abc123',
name: 'Prototype'
}]
}
];
const store = mockStore({
Expand Down Expand Up @@ -215,7 +241,10 @@ describe('Game page - RESULTS', () => {
});

it('reacts to button click', () => {
tree.find('button').simulate('click');
// button restart and 2 button with incorrect answers
expect(tree.find('button')).toHaveLength(3);
// button restart
tree.find('button#try_again').simulate('click');
const actions = store.getActions();
expect(actions).toMatchObject([{ type: RESTART }]);
});
Expand Down
92 changes: 84 additions & 8 deletions __tests__/pages/__snapshots__/Game.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ exports[`Game page - GAME - DARK style renders a <Code /> component 1`] = `
<Code
current={
Object {
"answerId": null,
"answered": false,
"codeES5": "Code ES5 - Prototype",
"codeES6": "Code ES6 - Prototype",
"correct": null,
"name": "Prototype",
"type": "creational",
"uuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
}
}
dispatch={[Function]}
Expand Down Expand Up @@ -364,14 +373,23 @@ exports[`Game page - GAME - DARK style renders a <ProgressBar /> component 1`] =
remaining={
Array [
Object {
"answerId": null,
"answered": false,
"codeES5": "Code ES5 - Singleton",
"codeES6": "Code ES6 - Singleton",
"correct": null,
"name": "SIngleton",
"type": "creational",
"uuid": "abc234",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
]
}
Expand Down Expand Up @@ -461,14 +479,23 @@ exports[`Game page - GAME - LIGHT style renders a <Code /> component 1`] = `
<Code
current={
Object {
"answerId": null,
"answered": false,
"codeES5": "Code ES5 - Prototype",
"codeES6": "Code ES6 - Prototype",
"correct": null,
"name": "Prototype",
"type": "creational",
"uuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
}
}
dispatch={[Function]}
Expand Down Expand Up @@ -763,14 +790,23 @@ exports[`Game page - GAME - LIGHT style renders a <ProgressBar /> component 1`]
remaining={
Array [
Object {
"answerId": null,
"answered": false,
"codeES5": "Code ES5 - Singleton",
"codeES6": "Code ES6 - Singleton",
"correct": null,
"name": "SIngleton",
"type": "creational",
"uuid": "abc234",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
]
}
Expand Down Expand Up @@ -987,24 +1023,44 @@ exports[`Game page - RESULTS renders a <Percentage /> component 1`] = `
answers={
Array [
Object {
"answerId": "abc123",
"answered": true,
"codeES5": "Code ES5 - Prototype",
"codeES6": "Code ES6 - Prototype",
"correct": true,
"name": "Prototype",
"type": "creational",
"uuid": "abc123",
"variantUuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
Object {
"answerId": "abc123",
"answered": true,
"codeES5": "Code ES5 - Singleton",
"codeES6": "Code ES6 - Singleton",
"correct": false,
"name": "SIngleton",
"type": "creational",
"uuid": "abc234",
"variantUuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
]
}
Expand Down Expand Up @@ -1078,24 +1134,44 @@ exports[`Game page - RESULTS renders a <Result /> component 1`] = `
answers={
Array [
Object {
"answerId": "abc123",
"answered": true,
"codeES5": "Code ES5 - Prototype",
"codeES6": "Code ES6 - Prototype",
"correct": true,
"name": "Prototype",
"type": "creational",
"uuid": "abc123",
"variantUuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
Object {
"answerId": "abc123",
"answered": true,
"codeES5": "Code ES5 - Singleton",
"codeES6": "Code ES6 - Singleton",
"correct": false,
"name": "SIngleton",
"type": "creational",
"uuid": "abc234",
"variantUuid": "abc123",
"variants": Array [
Object {
"name": "SIngleton",
"uuid": "abc234",
},
Object {
"name": "Prototype",
"uuid": "abc123",
},
],
},
]
}
Expand Down
Loading