-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3674 from openstax/handle_book_units
Handle books with units in the book section search
- Loading branch information
Showing
4 changed files
with
141 additions
and
6 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
exercises/specs/components/search/book-sections.spec.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import BookSections from '../../../src/components/search/book-sections'; | ||
import Books from '../../../src/models/books' | ||
import Search from '../../../src/models/search' | ||
|
||
describe('Search book sections', function() { | ||
|
||
describe('partsToOptions', function() { | ||
|
||
it('ignores units', () => { | ||
const search = new Search(); | ||
Books.ensureLoaded = jest.fn() | ||
const props = { search: search }; | ||
const bookSections = new BookSections(props); | ||
expect(bookSections.partsToOptions( | ||
[ | ||
{ | ||
id: 'db36053c-5281-42f4-90ec-afcc21ab28c3@18', | ||
title: '<span data-type="" itemprop="" class="os-text">Preface</span>', | ||
slug: 'preface', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-number"><span class="os-part-text">Unit </span>1</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">The Chemistry of Life</span>', | ||
contents: [ | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-number"><span class="os-part-text">Chapter </span>1</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">The Study of Life</span>', | ||
contents: [ | ||
{ | ||
id: '2230ab90-3137-4dcb-b6bd-72630222948c@10', | ||
title: '<span data-type="" itemprop="" class="os-text">Introduction</span>', | ||
slug: '1-introduction', | ||
}, | ||
{ | ||
id: 'ce6cfde4-1ac3-480f-aa0f-4777111f9e23@23', | ||
title: '<span class="os-number">1.1</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">The Science of Biology</span>', | ||
slug: '1-1-the-science-of-biology', | ||
}, | ||
{ | ||
id: '07dbec85-8530-4911-b863-5d73b5d7e211@18', | ||
title: '<span class="os-number">1.2</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">Themes and Concepts of Biology</span>', | ||
slug: '1-2-themes-and-concepts-of-biology', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-text">Key Terms</span>', | ||
slug: '1-key-terms', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-text">Chapter Summary</span>', | ||
slug: '1-chapter-summary', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-text">Visual Connection Questions</span>', | ||
slug: '1-visual-connection-questions', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-text">Review Questions</span>', | ||
slug: '1-review-questions', | ||
}, | ||
{ | ||
id: '[email protected]', | ||
title: '<span class="os-text">Critical Thinking Questions</span>', | ||
slug: '1-critical-thinking-questions', | ||
}, | ||
], | ||
slug: '1-the-study-of-life', | ||
}, | ||
], | ||
}, | ||
] | ||
)).toEqual([ | ||
{ | ||
label: '<span data-type="" itemprop="" class="os-text">Preface</span>', | ||
value: 'db36053c-5281-42f4-90ec-afcc21ab28c3', | ||
}, | ||
{ | ||
label: '<span class="os-number"><span class="os-part-text">Chapter </span>1</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">The Study of Life</span>', | ||
options: [ | ||
{ | ||
label: '<span data-type="" itemprop="" class="os-text">Introduction</span>', | ||
value: '2230ab90-3137-4dcb-b6bd-72630222948c', | ||
}, | ||
{ | ||
label: '<span class="os-number">1.1</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">The Science of Biology</span>', | ||
value: 'ce6cfde4-1ac3-480f-aa0f-4777111f9e23', | ||
}, | ||
{ | ||
label: '<span class="os-number">1.2</span><span class="os-divider"> </span><span data-type="" itemprop="" class="os-text">Themes and Concepts of Biology</span>', | ||
value: '07dbec85-8530-4911-b863-5d73b5d7e211', | ||
}, | ||
{ | ||
label: '<span class="os-text">Key Terms</span>', | ||
value: '761608a3-5b67-533e-a199-c03f0b88a95b', | ||
}, | ||
{ | ||
label: '<span class="os-text">Chapter Summary</span>', | ||
value: '0d3ce2c6-8ebe-5f8e-b3d4-1c91cfca2a91', | ||
}, | ||
{ | ||
label: '<span class="os-text">Visual Connection Questions</span>', | ||
value: '1c6c7f98-e992-536c-9769-cf24cefe451d', | ||
}, | ||
{ | ||
label: '<span class="os-text">Review Questions</span>', | ||
value: '3eec7061-a32e-529d-a594-b9f53aed0331', | ||
}, | ||
{ | ||
label: '<span class="os-text">Critical Thinking Questions</span>', | ||
value: 'bbe32ad1-f92d-5f62-b911-4fde45c04a58', | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters