Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
George Schneeloch committed Sep 24, 2015
1 parent bae4a41 commit b1d5cd0
Showing 1 changed file with 23 additions and 116 deletions.
139 changes: 23 additions & 116 deletions ui/jstests/test_manage_taxonomies.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
term={term}
repoSlug="repo"
updateTerm={updateTerm}
vocabularySlug={vocabulary.slug}
vocabulary={vocabulary}
refreshFromAPI={refreshFromAPI}
reportMessage={reportMessage}
ref={afterMount}
Expand Down Expand Up @@ -501,7 +501,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
component.forceUpdate(function () {
React.addons.TestUtils.Simulate.click(cancelButton);
component.forceUpdate(function () {
assert.equal(component.state.label, "test");
assert.equal(component.state.label, "TestB");
assert.equal(component.state.formatActionState, 'show');
//assert editbox is hide (UI reset)
var editTermBoxes = React.addons.TestUtils.
Expand All @@ -526,7 +526,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
term={term}
repoSlug="repo"
updateTerm={updateTerm}
vocabularySlug={vocabulary.slug}
vocabulary={vocabulary}
refreshFromAPI={refreshFromAPI}
ref={afterMount}
/>
Expand Down Expand Up @@ -823,9 +823,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: '',
vocabularyType: 'm',
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
var formNode = React.addons.TestUtils.
findRenderedDOMComponentWithClass(
Expand Down Expand Up @@ -872,9 +870,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: "TestA",
vocabularyType: "f",
learningResourceTypes: [],
multiTerms: true,
slug: '',
vocabularyInEdit: undefined
multiTerms: true
});
React.addons.TestUtils.Simulate.click(saveButton);
waitForAjax(1, function() {
Expand All @@ -888,9 +884,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: '',
vocabularyType: 'm',
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
// listing page was asked to update
assert.equal(refreshCount, 1);
Expand Down Expand Up @@ -936,9 +930,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: "TestB",
vocabularyType: "f",
learningResourceTypes: ['course'],
multiTerms: true,
slug: '',
vocabularyInEdit: undefined
multiTerms: true
});
React.addons.TestUtils.Simulate.click(saveButton);
waitForAjax(1, function() {
Expand All @@ -948,9 +940,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: '',
vocabularyType: 'm',
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
assert.equal(
saveVocabularyResponse.id,
Expand Down Expand Up @@ -984,9 +974,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: "TestC",
vocabularyType: "f",
learningResourceTypes: ["course"],
multiTerms: true,
slug: '',
vocabularyInEdit: undefined
multiTerms: true
});
//uncheck checkboxes
React.addons.TestUtils.Simulate.change(
Expand All @@ -1003,9 +991,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: "TestC",
vocabularyType: "f",
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
React.addons.TestUtils.Simulate.click(saveButton);
waitForAjax(1, function() {
Expand All @@ -1016,9 +1002,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: '',
vocabularyType: 'm',
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
assert.equal(
saveVocabularyResponse.id,
Expand Down Expand Up @@ -1346,32 +1330,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: 'TestB',
vocabularyType: 'f',
learningResourceTypes: [],
multiTerms: true,
slug: 'difficulty',
vocabularyInEdit: {
"id": 1,
"slug": "difficulty",
"name": "difficulty",
"description": "easy",
"vocabulary_type": "f",
"required": false,
"weight": 2147483647,
"learning_resource_types": [
"course"
],
"multi_terms": true,
"terms": [{
id: 1,
slug: 'easy',
label: 'easy',
weight: 1
}, {
id: 2,
slug: 'difficult',
label: 'difficult',
weight: 1
}]
}
multiTerms: true
});

// Press confirm in dialog.
Expand All @@ -1383,9 +1342,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: '',
vocabularyType: 'm',
learningResourceTypes: [],
multiTerms: false,
slug: '',
vocabularyInEdit: undefined
multiTerms: false
});
done();
});
Expand All @@ -1400,7 +1357,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
<AddVocabulary
refreshFromAPI={refreshFromAPI}
editVocabulary={editVocabulary}
vocabulary={vocabulary}
vocabularyInEdit={vocabulary}
repoSlug="repo4"
learningResourceTypes={propLearningResourceTypes}
updateParent={updateParent}
Expand Down Expand Up @@ -1498,32 +1455,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: 'TestB',
vocabularyType: 'f',
learningResourceTypes: [],
multiTerms: true,
slug: 'difficulty',
vocabularyInEdit: {
"id": 1,
"slug": "difficulty",
"name": "difficulty",
"description": "easy",
"vocabulary_type": "f",
"required": false,
"weight": 2147483647,
"learning_resource_types": [
"course"
],
"multi_terms": true,
"terms": [{
id: 1,
slug: 'easy',
label: 'easy',
weight: 1
}, {
id: 2,
slug: 'difficult',
label: 'difficult',
weight: 1
}]
}
multiTerms: true
};
assert.deepEqual(component.state, expected);

Expand All @@ -1545,7 +1477,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
<AddVocabulary
refreshFromAPI={refreshFromAPI}
editVocabulary={editVocabulary}
vocabulary={vocabulary}
vocabularyInEdit={vocabulary}
repoSlug="repo4"
learningResourceTypes={propLearningResourceTypes}
updateParent={updateParent}
Expand Down Expand Up @@ -1642,32 +1574,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
description: 'TestB',
vocabularyType: 'f',
learningResourceTypes: [],
multiTerms: true,
slug: 'difficulty',
vocabularyInEdit: {
"id": 1,
"slug": "difficulty",
"name": "difficulty",
"description": "easy",
"vocabulary_type": "f",
"required": false,
"weight": 2147483647,
"learning_resource_types": [
"course"
],
"multi_terms": true,
"terms": [{
id: 1,
slug: 'easy',
label: 'easy',
weight: 1
}, {
id: 2,
slug: 'difficult',
label: 'difficult',
weight: 1
}]
}
multiTerms: true
});

assert.deepEqual(
Expand All @@ -1687,7 +1594,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
<AddVocabulary
refreshFromAPI={refreshFromAPI}
editVocabulary={editVocabulary}
vocabulary={vocabulary}
vocabularyInEdit={vocabulary}
repoSlug="repo4"
learningResourceTypes={propLearningResourceTypes}
updateParent={updateParent}
Expand Down Expand Up @@ -1777,7 +1684,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
renderIntoDocument(
<AddVocabulary
editVocabulary={editVocabulary}
vocabulary={vocabulary}
vocabularyInEdit={vocabulary}
repoSlug="repo"
learningResourceTypes={propLearningResourceTypes}
refreshFromAPI={refreshFromAPI}
Expand Down Expand Up @@ -1869,7 +1776,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
renderIntoDocument(
<AddVocabulary
editVocabulary={editVocabulary}
vocabulary={vocabulary}
vocabularyInEdit={vocabulary}
repoSlug="repo"
learningResourceTypes={propLearningResourceTypes}
updateParent={updateParent}
Expand Down Expand Up @@ -1904,7 +1811,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
assert.deepEqual(component.state, {
vocabularies: [],
learningResourceTypes: [],
vocabularyInEdit: undefined,
editVocabId: undefined,
vocabMessage: undefined,
termsMessage: undefined
});
Expand Down Expand Up @@ -1956,7 +1863,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
function(assert) {
assert.ok(TaxonomyComponent, "class object not found");
var vocabularyWithoutTerms = {
"id": 2,
"id": 3,
"slug": "difficulty2",
"name": "difficulty2",
"description": "easy",
Expand All @@ -1973,7 +1880,7 @@ define(['QUnit', 'jquery', 'lodash', 'manage_taxonomies', 'react',
assert.deepEqual(component.state, {
vocabularies: [],
learningResourceTypes: [],
vocabularyInEdit: undefined,
editVocabId: undefined,
vocabMessage: undefined,
termsMessage: undefined
});
Expand Down

0 comments on commit b1d5cd0

Please sign in to comment.